From a805af02c15ae5ea32474ebed4f20ab2c96010af Mon Sep 17 00:00:00 2001 From: Slava <20563034+veaceslavdoina@users.noreply.github.com> Date: Mon, 27 Nov 2023 13:32:13 +0200 Subject: [PATCH] Run C-Tests on master commits (#636) https://github.com/codex-storage/cs-codex-dist-tests/pull/84 --- .github/workflows/docker-dist-tests.yml | 2 + .github/workflows/docker-reusable.yml | 67 +++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/.github/workflows/docker-dist-tests.yml b/.github/workflows/docker-dist-tests.yml index 40dbacfd..e6e0973b 100644 --- a/.github/workflows/docker-dist-tests.yml +++ b/.github/workflows/docker-dist-tests.yml @@ -28,4 +28,6 @@ jobs: nat_ip_auto: true tag_latest: ${{ github.ref_name == github.event.repository.default_branch || startsWith(github.ref, 'refs/tags/') }} tag_suffix: dist-tests + continuous_tests_list: PeersTest HoldMyBeerTest + continuous_tests_duration: 12h secrets: inherit diff --git a/.github/workflows/docker-reusable.yml b/.github/workflows/docker-reusable.yml index 6c566dfc..1fe15f1e 100644 --- a/.github/workflows/docker-reusable.yml +++ b/.github/workflows/docker-reusable.yml @@ -44,9 +44,20 @@ on: description: Suffix for Docker images tag required: false type: string + continuous_tests_list: + default: '' + description: Continuous Tests list + required: false + type: string + continuous_tests_duration: + default: 48h + description: Continuous Tests duration + required: false + type: string env: + # Build DOCKER_FILE: ${{ inputs.docker_file }} DOCKER_REPO: ${{ inputs.docker_repo }} MAKE_PARALLEL: ${{ inputs.make_parallel }} @@ -55,6 +66,12 @@ env: TAG_LATEST: ${{ inputs.tag_latest }} TAG_SHA: ${{ inputs.tag_sha }} TAG_SUFFIX: ${{ inputs.tag_suffix }} + # Tests + CONTINUOUS_TESTS_SOURCE: codex-storage/cs-codex-dist-tests + CONTINUOUS_TESTS_BRANCH: master + CONTINUOUS_TESTS_LIST: ${{ inputs.continuous_tests_list }} + CONTINUOUS_TESTS_DURATION: ${{ inputs.continuous_tests_duration }} + CONTINUOUS_TESTS_NAMEPREFIX: c-tests-ci jobs: @@ -135,6 +152,8 @@ jobs: publish: name: Publish multi-platform image runs-on: ubuntu-latest + outputs: + version: ${{ steps.meta.outputs.version }} needs: build steps: - name: Docker - Variables @@ -197,3 +216,51 @@ jobs: - name: Docker - Inspect image run: | docker buildx imagetools inspect ${{ env.DOCKER_REPO }}:${{ steps.meta.outputs.version }} + + + # Compute Continuous Tests inputs + compute-tests-inputs: + name: Compute Continuous Tests list + if: ${{ inputs.continuous_tests_list != '' && github.ref_name == github.event.repository.default_branch }} + runs-on: ubuntu-latest + needs: publish + outputs: + source: ${{ steps.compute.outputs.source }} + branch: ${{ steps.compute.outputs.branch }} + codexdockerimage: ${{ steps.compute.outputs.codexdockerimage }} + nameprefix: ${{ steps.compute.outputs.nameprefix }} + continuous_tests_list: ${{ steps.compute.outputs.continuous_tests_list }} + continuous_tests_duration: ${{ steps.compute.outputs.continuous_tests_duration }} + continuous_tests_workflow: ${{ steps.compute.outputs.continuous_tests_workflow }} + workflow_source: ${{ steps.compute.outputs.workflow_source }} + steps: + - name: Compute Continuous Tests list + id: compute + run: | + echo "source=${{ format('{0}/{1}', github.server_url, env.CONTINUOUS_TESTS_SOURCE) }}" >> "$GITHUB_OUTPUT" + echo "branch=${{ env.CONTINUOUS_TESTS_BRANCH }}" >> "$GITHUB_OUTPUT" + echo "codexdockerimage=${{ inputs.docker_repo }}:${{ needs.publish.outputs.version }}" >> "$GITHUB_OUTPUT" + echo "nameprefix=$(awk '{ print tolower($0) }' <<< ${{ env.CONTINUOUS_TESTS_NAMEPREFIX }})" >> "$GITHUB_OUTPUT" + echo "continuous_tests_list=$(jq -cR 'split(" ")' <<< '${{ env.CONTINUOUS_TESTS_LIST }}')" >> "$GITHUB_OUTPUT" + echo "continuous_tests_duration=${{ env.CONTINUOUS_TESTS_DURATION }}" >> "$GITHUB_OUTPUT" + echo "workflow_source=${{ env.CONTINUOUS_TESTS_SOURCE }}" >> "$GITHUB_OUTPUT" + + + # Run Continuous Tests + run-tests: + name: Run Continuous Tests + needs: [publish, compute-tests-inputs] + strategy: + max-parallel: 1 + matrix: + tests: ${{ fromJSON(needs.compute-tests-inputs.outputs.continuous_tests_list) }} + uses: codex-storage/cs-codex-dist-tests/.github/workflows/continuous-tests.yaml@master + with: + source: ${{ needs.compute-tests-inputs.outputs.source }} + branch: ${{ needs.compute-tests-inputs.outputs.branch }} + codexdockerimage: ${{ needs.compute-tests-inputs.outputs.codexdockerimage }} + nameprefix: ${{ needs.compute-tests-inputs.outputs.nameprefix }}-${{ matrix.tests }}-${{ needs.compute-tests-inputs.outputs.continuous_tests_duration }} + tests_filter: ${{ matrix.tests }} + tests_target_duration: ${{ needs.compute-tests-inputs.outputs.continuous_tests_duration }} + workflow_source: ${{ needs.compute-tests-inputs.outputs.workflow_source }} + secrets: inherit