From afdc65f86def893ead987d210e04d57b331c8e56 Mon Sep 17 00:00:00 2001 From: Samir Kamal <1954121+skamril@users.noreply.github.com> Date: Wed, 14 Aug 2024 17:55:31 +0200 Subject: [PATCH] debug --- .github/workflows/main.yml | 59 +++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 386fcaead7..1fc40aeb4c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,29 @@ jobs: ## Python ################################################################ + check-backend-changes: + runs-on: ubuntu-20.04 + outputs: + should-run: ${{ steps.check-changes.outputs.should-run }} + steps: + - name: Checkout GitHub repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Ensure full history is fetched + - name: Check if backend files have changed + id: check-changes + run: | + git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1 + if git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD | grep -Eq '^antarest/|^tests/|^resources/|^requirements.*\.txt$'; then + echo "Backend files have changed" + echo "should-run=true" >> $GITHUB_OUTPUT + else + echo "No backend files have changed" + echo "should-run=false" >> $GITHUB_OUTPUT + fi + python-lint: + if: ${{ needs.check-backend-changes.outputs.should-run == 'true' }} runs-on: ubuntu-20.04 steps: - name: Checkout GitHub repo (+ download lfs dependencies) @@ -44,6 +66,7 @@ jobs: mypy --install-types --non-interactive python-test: + if: ${{ needs.check-backend-changes.outputs.should-run == 'true' }} runs-on: ${{ matrix.os }} strategy: max-parallel: 9 @@ -78,8 +101,30 @@ jobs: ## npm ################################################################ + check-frontend-changes: + runs-on: ubuntu-20.04 + outputs: + should-run: ${{ steps.check-changes.outputs.should-run }} + steps: + - name: Checkout GitHub repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Ensure full history is fetched + - name: Check if front-end files have changed + id: check-changes + run: | + git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1 + if git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD | grep -q '^webapp/'; then + echo "Front-end files have changed" + echo "should-run=true" >> $GITHUB_OUTPUT + else + echo "No front-end files in have changed" + echo "should-run=false" >> $GITHUB_OUTPUT + fi + npm-setup: - if: ${{ contains(github.event.pull_request.files.*.filename, 'webapp/') }} + needs: check-frontend-changes + if: ${{ needs.check-frontend-changes.outputs.should-run == 'true' }} runs-on: ubuntu-20.04 steps: - name: Checkout GitHub repo @@ -102,8 +147,8 @@ jobs: working-directory: webapp npm-lint: - if: ${{ contains(github.event.pull_request.files.*.filename, 'webapp/') }} - needs: npm-setup + needs: [check-frontend-changes, npm-setup] + if: ${{ needs.check-frontend-changes.outputs.should-run == 'true' }} runs-on: ubuntu-20.04 steps: - name: Checkout GitHub repo @@ -123,8 +168,8 @@ jobs: working-directory: webapp npm-test: - if: ${{ contains(github.event.pull_request.files.*.filename, 'webapp/') }} - needs: npm-setup + needs: [check-frontend-changes, npm-setup] + if: ${{ needs.check-frontend-changes.outputs.should-run == 'true' }} runs-on: ubuntu-20.04 steps: - name: Checkout GitHub repo @@ -144,8 +189,8 @@ jobs: working-directory: webapp npm-build: - if: ${{ contains(github.event.pull_request.files.*.filename, 'webapp/') }} - needs: npm-setup + needs: [check-frontend-changes, npm-setup] + if: ${{ needs.check-frontend-changes.outputs.should-run == 'true' }} runs-on: ubuntu-20.04 steps: - name: Checkout GitHub repo