From 666eac2df4593accb6ac9932ca38b476cdb6f437 Mon Sep 17 00:00:00 2001 From: Carlos Felix <63804190+carlosfelix2@users.noreply.github.com> Date: Mon, 9 Dec 2024 09:26:38 -0500 Subject: [PATCH] Skip PR workflows if no changes to files --- .github/workflows/pr_backend.yml | 32 +++++++++++++++++++++++-------- .github/workflows/pr_frontend.yml | 21 ++++++++++++++++++-- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pr_backend.yml b/.github/workflows/pr_backend.yml index 2b9c7ae4..ca36481a 100644 --- a/.github/workflows/pr_backend.yml +++ b/.github/workflows/pr_backend.yml @@ -1,17 +1,31 @@ name: Pull Request Backend on: pull_request: - paths: - - "data/**" concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number }} cancel-in-progress: true -env: - CENSUS_API_KEY: ${{ secrets.CENSUS_API_KEY }} - J40_VERSION_LABEL_STRING: ${{ vars.SCORE_VERSION }} jobs: + # JOB to run change detection + detect-be-changes: + runs-on: ubuntu-latest + # Required permissions + permissions: + pull-requests: read + # Set job outputs to values from filter step + outputs: + backend: ${{ steps.filter.outputs.backend }} + steps: + # For pull requests it's not necessary to checkout the code + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + backend: + - 'data/**' code-quality-checks: + needs: detect-be-changes + if: ${{ needs.detect-be-changes.outputs.backend == 'true' }} runs-on: ubuntu-latest defaults: run: @@ -48,7 +62,12 @@ jobs: run: poetry run pylint data_pipeline/ - name: Check library safety run: poetry run safety check --ignore 51457 --ignore 44715 --ignore 70612 + - name: Run unit tests + run: | + poetry run pytest data_pipeline/ generate-score-tiles: + needs: detect-be-changes + if: ${{ needs.detect-be-changes.outputs.backend == 'true' }} runs-on: ubuntu-latest defaults: run: @@ -84,9 +103,6 @@ jobs: sudo apt-get update sudo apt-get -y install gdal-bin ogrinfo --version - - name: Run unit tests - run: | - poetry run pytest data_pipeline/ - name: Cleanup Data run: | poetry run python3 -m data_pipeline.application data-cleanup diff --git a/.github/workflows/pr_frontend.yml b/.github/workflows/pr_frontend.yml index c0682062..70503d13 100644 --- a/.github/workflows/pr_frontend.yml +++ b/.github/workflows/pr_frontend.yml @@ -1,13 +1,30 @@ name: Pull Request Frontend on: pull_request: - paths: - - "client/**" concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number }} cancel-in-progress: true jobs: + # JOB to run change detection + detect-fe-changes: + runs-on: ubuntu-latest + # Required permissions + permissions: + pull-requests: read + # Set job outputs to values from filter step + outputs: + backend: ${{ steps.filter.outputs.frontend }} + steps: + # For pull requests it's not necessary to checkout the code + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + frontend: + - 'client/**' frontend-build: + needs: detect-fe-changes + if: ${{ needs.detect-fe-changes.outputs.frontend == 'true' }} runs-on: ubuntu-latest environment: PR defaults: