diff --git a/.github/workflows/pr-main_l1.yaml b/.github/workflows/pr-main_l1.yaml index 00e2adc7ae2..19abf558d84 100644 --- a/.github/workflows/pr-main_l1.yaml +++ b/.github/workflows/pr-main_l1.yaml @@ -5,8 +5,6 @@ on: merge_group: pull_request: branches: ["**"] - paths-ignore: - - "crates/l2/**" # Behind a feature flag not used in this workflow permissions: contents: read @@ -17,10 +15,35 @@ concurrency: cancel-in-progress: true jobs: + detect-changes: + runs-on: ubuntu-latest + outputs: + run_tests: ${{ steps.finish.outputs.run_tests }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + run_tests: + - '!crates/l2/**' + - name: finish + id: finish + run: | + if [[ "${GITHUB_EVENT_NAME}" != "pull_request" ]]; then + echo "run_tests=true" >> "$GITHUB_OUTPUT" + else + echo "run_tests=${{ steps.filter.outputs.run_tests }}" >> "$GITHUB_OUTPUT" + fi + - name: Print result + run: echo "run_tests=${{ steps.finish.outputs.run_tests }}" + lint: # "Lint" is a required check, don't change the name name: Lint runs-on: ubuntu-latest + needs: detect-changes + if: ${{ needs.detect-changes.outputs.run_tests == 'true' }} steps: - name: Checkout sources uses: actions/checkout@v4 @@ -61,6 +84,8 @@ jobs: test: # "Test" is a required check, don't change the name name: Test + needs: detect-changes + if: ${{ needs.detect-changes.outputs.run_tests == 'true' }} runs-on: ubuntu-latest steps: - name: Checkout sources @@ -84,6 +109,8 @@ jobs: docker_build: name: Build Docker runs-on: ubuntu-latest + needs: detect-changes + if: ${{ needs.detect-changes.outputs.run_tests == 'true' }} steps: - uses: actions/checkout@v4 @@ -105,8 +132,8 @@ jobs: run-assertoor: name: Assertoor - ${{ matrix.name }} runs-on: ubuntu-latest - needs: [docker_build] - if: ${{ github.event_name != 'merge_group' }} + needs: [detect-changes, docker_build] + if: ${{ needs.detect-changes.outputs.run_tests == 'true' && github.event_name != 'merge_group' }} strategy: fail-fast: true matrix: @@ -147,8 +174,8 @@ jobs: run-hive: name: Hive - ${{ matrix.name }} runs-on: ubuntu-latest - needs: [docker_build] - if: ${{ github.event_name != 'merge_group' }} + needs: [detect-changes, docker_build] + if: ${{ needs.detect-changes.outputs.run_tests == 'true' && github.event_name != 'merge_group' }} strategy: fail-fast: false matrix: @@ -254,9 +281,9 @@ jobs: # "Integration Test" is a required check, don't change the name name: Integration Test runs-on: ubuntu-latest - needs: [run-assertoor, run-hive] + needs: [detect-changes, run-assertoor, run-hive] # Make sure this job runs even if the previous jobs failed or were skipped - if: ${{ always() && needs.run-assertoor.result != 'skipped' && needs.run-hive.result != 'skipped' }} + if: ${{ needs.detect-changes.outputs.run_tests == 'true' && always() && needs.run-assertoor.result != 'skipped' && needs.run-hive.result != 'skipped' }} steps: - name: Check if any job failed run: | @@ -273,7 +300,8 @@ jobs: reorg-tests: name: Reorg Tests runs-on: ubuntu-latest - if: ${{ github.event_name != 'merge_group' }} + needs: detect-changes + if: ${{ needs.detect-changes.outputs.run_tests == 'true' && github.event_name != 'merge_group' }} steps: - name: Checkout sources uses: actions/checkout@v4 diff --git a/.github/workflows/pr-main_l2.yaml b/.github/workflows/pr-main_l2.yaml index a51c26f6d07..a9b104cb7d6 100644 --- a/.github/workflows/pr-main_l2.yaml +++ b/.github/workflows/pr-main_l2.yaml @@ -4,13 +4,6 @@ on: branches: ["main"] pull_request: branches: ["**"] - paths: - - "crates/l2/**" - - "fixtures/**" - - "crates/blockchain/dev/**" - - "crates/vm/levm/**" - - ".github/workflows/pr-main_l2.yaml" - - "cmd/ethrex/l2/**" permissions: contents: read @@ -24,10 +17,40 @@ env: DOCKER_ETHREX_WORKDIR: /usr/local/bin jobs: + detect-changes: + runs-on: ubuntu-latest + outputs: + run_tests: ${{ steps.finish.outputs.run_tests }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + run_tests: + - "crates/l2/**" + - "fixtures/**" + - "crates/blockchain/dev/**" + - "crates/vm/levm/**" + - ".github/workflows/pr-main_l2.yaml" + - "cmd/ethrex/l2/**" + - name: finish + id: finish + run: | + if [[ "${GITHUB_EVENT_NAME}" != "pull_request" ]]; then + echo "run_tests=true" >> "$GITHUB_OUTPUT" + else + echo "run_tests=${{ steps.filter.outputs.run_tests }}" >> "$GITHUB_OUTPUT" + fi + - name: Print result + run: echo "run_tests=${{ steps.finish.outputs.run_tests }}" + lint: - # "Lint" is a required check, don't change the name - name: Lint + # "Lint L2" is a required check, don't change the name + name: Lint L2 runs-on: ubuntu-latest + needs: detect-changes + if: ${{ needs.detect-changes.outputs.run_tests == 'true' }} steps: - name: Checkout sources uses: actions/checkout@v4 @@ -69,6 +92,8 @@ jobs: build-docker: name: Build docker image runs-on: ubuntu-latest + needs: detect-changes + if: ${{ needs.detect-changes.outputs.run_tests == 'true' }} steps: - name: Checkout sources uses: actions/checkout@v4 @@ -94,6 +119,8 @@ jobs: build-docker-l2: name: Build docker image L2 runs-on: ubuntu-latest + needs: detect-changes + if: ${{ needs.detect-changes.outputs.run_tests == 'true' }} steps: - name: Checkout sources uses: actions/checkout@v4 @@ -119,7 +146,8 @@ jobs: integration-test: name: Integration Test - ${{ matrix.name }} runs-on: ubuntu-latest - needs: [build-docker, build-docker-l2] + needs: [detect-changes, build-docker, build-docker-l2] + if: ${{ needs.detect-changes.outputs.run_tests == 'true' }} strategy: matrix: include: @@ -309,7 +337,8 @@ jobs: integration-test-tdx: name: Integration Test - TDX runs-on: ubuntu-latest - needs: [build-docker, build-docker-l2] + needs: [detect-changes, build-docker, build-docker-l2] + if: ${{ needs.detect-changes.outputs.run_tests == 'true' }} steps: - name: Checkout sources uses: actions/checkout@v4 @@ -416,7 +445,8 @@ jobs: state-diff-test: name: State Reconstruction Tests runs-on: ubuntu-latest - needs: [build-docker, build-docker-l2] + needs: [detect-changes, build-docker, build-docker-l2] + if: ${{ needs.detect-changes.outputs.run_tests == 'true' }} steps: - name: Checkout sources uses: actions/checkout@v4 @@ -477,6 +507,8 @@ jobs: integration-test-l2-dev: name: Integration Test - L2 Dev runs-on: ubuntu-latest + needs: detect-changes + if: ${{ needs.detect-changes.outputs.run_tests == 'true' }} steps: - name: Checkout sources uses: actions/checkout@v4 @@ -531,18 +563,19 @@ jobs: # The purpose of this job is to add it as a required check in GitHub so that we don't have to add every individual job as a required check all-tests: - # "Integration Test" is a required check, don't change the name - name: Integration Test + # "Integration Test L2" is a required check, don't change the name + name: Integration Test L2 runs-on: ubuntu-latest needs: [ + detect-changes, integration-test, state-diff-test, integration-test-tdx, integration-test-l2-dev, ] # Make sure this job runs even if the previous jobs failed or were skipped - if: ${{ always() && needs.integration-test.result != 'skipped' && needs.state-diff-test.result != 'skipped' && needs.integration-test-tdx.result != 'skipped' && needs.integration-test-l2-dev.result != 'skipped' }} + if: ${{ needs.detect-changes.outputs.run_tests == 'true' && always() && needs.integration-test.result != 'skipped' && needs.state-diff-test.result != 'skipped' && needs.integration-test-tdx.result != 'skipped' && needs.integration-test-l2-dev.result != 'skipped' }} steps: - name: Check if any job failed run: |