From 72756afc6292911a241baebde19216870ebb66ae Mon Sep 17 00:00:00 2001 From: AdityaPat_ <126982848+AdityaP700@users.noreply.github.com> Date: Fri, 24 Jan 2025 03:13:56 +0530 Subject: [PATCH] fix: skip unnecessary test runs for bot-generated and non-critical PRs --- .../pr-testing-with-test-project.yml | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-testing-with-test-project.yml b/.github/workflows/pr-testing-with-test-project.yml index 7c543f907..29a6b2e06 100644 --- a/.github/workflows/pr-testing-with-test-project.yml +++ b/.github/workflows/pr-testing-with-test-project.yml @@ -1,13 +1,37 @@ -#This workflow runs the tests in the test projects to make sure the generator works as a library where it is a Node dependency along with the template. name: Test using test project on: pull_request: types: [opened, reopened, synchronize, ready_for_review] + paths: + - 'package.json' + - 'package-lock.json' + - 'apps/' + - 'packages/' + - '.github/workflows/' + - '!/*.md' + - '!docs/**' jobs: + should-test: + runs-on: ubuntu-latest + outputs: + run_tests: ${{ steps.check.outputs.run_tests }} + steps: + - name: Check if tests should run + id: check + run: | + # Skip for bot PRs with specific titles + if [[ "${{ github.actor }}" == "asyncapi-bot" && "${{ github.event.pull_request.title }}" =~ ^(ci:\ update|chore\(release\):) ]] || \ + [[ "${{ github.actor }}" == "allcontributors[bot]" && "${{ github.event.pull_request.title }}" =~ ^docs: ]]; then + echo "run_tests=false" >> $GITHUB_OUTPUT + else + echo "run_tests=true" >> $GITHUB_OUTPUT + fi + test: - if: github.event.pull_request.draft == false + needs: should-test + if: needs.should-test.outputs.run_tests == 'true' && github.event.pull_request.draft == false name: Test generator as dependency with Node ${{ matrix.node }} runs-on: ubuntu-latest strategy: @@ -16,6 +40,7 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 + - name: Run test run: NODE_IMAGE_TAG=${{ matrix.node }} docker compose up --abort-on-container-exit --remove-orphans --force-recreate working-directory: ./apps/generator/test/test-project