From adf3dd4b6f8c2388f27cf280a5240a2bf6c69a1f Mon Sep 17 00:00:00 2001 From: Abdul Rabbani <58230246+abdulrabbani00@users.noreply.github.com> Date: Fri, 17 Jun 2022 09:45:53 -0400 Subject: [PATCH] Update CICD pipeline to skip duplicate tests (#95) * Update CICD pipeline to skip duplicate tests * fix dependencies * Fix other dep --- .github/workflows/on-pr.yaml | 7 ------ .../{publish.yaml => on-publish-pr.yml} | 25 +++++++++++++++++++ .github/workflows/tests.yml | 18 ------------- 3 files changed, 25 insertions(+), 25 deletions(-) delete mode 100644 .github/workflows/on-pr.yaml rename .github/workflows/{publish.yaml => on-publish-pr.yml} (68%) diff --git a/.github/workflows/on-pr.yaml b/.github/workflows/on-pr.yaml deleted file mode 100644 index e164ac8..0000000 --- a/.github/workflows/on-pr.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: Docker Build - -on: [pull_request] - -jobs: - run-tests: - uses: ./.github/workflows/tests.yml diff --git a/.github/workflows/publish.yaml b/.github/workflows/on-publish-pr.yml similarity index 68% rename from .github/workflows/publish.yaml rename to .github/workflows/on-publish-pr.yml index bb2954c..ff4cd8b 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/on-publish-pr.yml @@ -2,12 +2,33 @@ name: Publish Docker image on: release: types: [published] + pull_request: jobs: + pre_job: + # continue-on-error: true # Uncomment once integration is finished + runs-on: ubuntu-latest + # Map a step output to a job output + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@v4 + with: + # All of these options are optional, so you can remove them if you are happy with the defaults + concurrent_skipping: "never" + skip_after_successful_duplicate: "true" + do_not_skip: '["workflow_dispatch", "schedule"]' run-tests: + if: ${{ needs.pre_job.outputs.should_skip != 'true' }} + needs: pre_job uses: ./.github/workflows/tests.yml build: name: Run docker build runs-on: ubuntu-latest + if: | + always() && + (needs.run-tests.result == 'success' || needs.run-tests.result == 'skipped') && + github.event_name == 'release' needs: run-tests steps: - uses: actions/checkout@v2 @@ -25,6 +46,10 @@ jobs: push_to_registries: name: Push Docker image to Docker Hub runs-on: ubuntu-latest + if: | + always() && + (needs.build.result == 'success') && + github.event_name == 'release' needs: build steps: - name: Get the version diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f136db2..17ed729 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,24 +7,8 @@ env: GOPATH: /tmp/go jobs: - pre_job: - # continue-on-error: true # Uncomment once integration is finished - runs-on: ubuntu-latest - # Map a step output to a job output - outputs: - should_skip: ${{ steps.skip_check.outputs.should_skip }} - steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@v4 - with: - # All of these options are optional, so you can remove them if you are happy with the defaults - concurrent_skipping: "never" - skip_after_successful_duplicate: "true" - do_not_skip: '["workflow_dispatch", "schedule"]' build: name: Run docker build - needs: pre_job - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -34,8 +18,6 @@ jobs: statediff-unit-test: name: Run statediff unit tests runs-on: ubuntu-latest - needs: pre_job - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} env: GO111MODULE: on steps: