From a4ccab4137880df53aa9e4c1867758e903b7c26f Mon Sep 17 00:00:00 2001 From: Najib Ishaq Date: Thu, 18 Jul 2024 10:31:10 -0400 Subject: [PATCH] ci: ignoring tests if not tools were updated --- .github/workflows/package-filter.yml | 8 ++++++++ .github/workflows/package-tests.yml | 3 +++ 2 files changed, 11 insertions(+) diff --git a/.github/workflows/package-filter.yml b/.github/workflows/package-filter.yml index 6f4d3ca46..fc174e9c1 100644 --- a/.github/workflows/package-filter.yml +++ b/.github/workflows/package-filter.yml @@ -20,6 +20,9 @@ on: list: description: "The list of directories containing the updated packages" value: ${{ jobs.package-filter.outputs.list }} + num_packages: + description: "The number of updated packages" + value: ${{ jobs.package-filter.outputs.num_packages }} permissions: contents: read @@ -31,6 +34,7 @@ jobs: outputs: matrix: ${{ steps.package-filter.outputs.matrix }} list: ${{ steps.package-filter.outputs.list }} + num_packages: ${{ steps.package-filter.outputs.num_packages }} steps: - name: Checkout uses: actions/checkout@v4 @@ -41,6 +45,7 @@ jobs: - name: Find Updated Packages id: package-filter run: | + NUM_PACKAGES=0 PACKAGE_DIRS="" COMPANION_FILES="VERSION .bumpversion.cfg" @@ -123,6 +128,7 @@ jobs: fi fi + NUM_PACKAGES=$((NUM_PACKAGES+1)) PACKAGE_DIRS="$PACKAGE_DIRS ${pkg_dir}" fi done @@ -136,6 +142,7 @@ jobs: then echo "::error::No updated packages were found" && exit 1 fi + echo "The number of updated packages is $NUM_PACKAGES" # Convert the package directories to JSON for the output matrix JSON="{\"include\": [" @@ -160,3 +167,4 @@ jobs: # Set the output echo "matrix=$( echo "$JSON" )" >> $GITHUB_OUTPUT echo "list=$( echo "$PACKAGE_DIRS" )" >> $GITHUB_OUTPUT + echo "num_packages=$NUM_PACKAGES" >> $GITHUB_OUTPUT diff --git a/.github/workflows/package-tests.yml b/.github/workflows/package-tests.yml index 44f4a1c65..b6ae538d3 100644 --- a/.github/workflows/package-tests.yml +++ b/.github/workflows/package-tests.yml @@ -27,6 +27,7 @@ jobs: pre-commit: name: Pre-commit | ${{ matrix.package_name }} needs: package-filter + if: ${{ needs.package-filter.outputs.num_packages > 0 }} strategy: fail-fast: false matrix: ${{ fromJson(needs.package-filter.outputs.matrix) }} @@ -56,6 +57,7 @@ jobs: docker: name: Docker | Build ${{ matrix.package_name }} needs: package-filter + if: ${{ needs.package-filter.outputs.num_packages > 0 }} strategy: fail-fast: false matrix: ${{ fromJson(needs.package-filter.outputs.matrix) }} @@ -106,6 +108,7 @@ jobs: tests: name: Test | ${{ matrix.package_name }} needs: package-filter + if: ${{ needs.package-filter.outputs.num_packages > 0 }} strategy: fail-fast: false matrix: ${{ fromJson(needs.package-filter.outputs.matrix) }}