From d5f0b20d783bf19083fe854897d5e8f9c11d9757 Mon Sep 17 00:00:00 2001 From: Jost Berthold Date: Mon, 15 Apr 2024 22:02:16 +1000 Subject: [PATCH] use path filters to determine change set and select tests to run (#3808) Part of #3800 * Determines change sets using simple directory / file filters * Skips running kore integration tests if no changes were detected --- .github/workflows/test.yml | 54 +++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e8eed7227..449bfcc75d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -136,6 +136,7 @@ jobs: nix-integration: name: 'Nix / Integration' + needs: formatting runs-on: [self-hosted, linux, normal] steps: - name: Check out code @@ -160,15 +161,60 @@ jobs: name: k-framework skipPush: true - - name: Run booster integration Tests + - uses: dorny/paths-filter@v3 + id: changes + with: + filters: | + kore: + - 'kore/**' + kore_rpc_types: + - 'kore-rpc-types/**' + booster: + - 'booster/**' + dev_tools: + - 'dev-tools/**' + project: + - 'stack.yaml*' + - 'cabal.project*' + - 'Makefile' + - '*.mk' + - 'flake.nix' + - 'deps/*' + - scripts/booster-integration-tests.sh + kore_tests: + - 'test/**' + + - name: Build + run: GC_DONT_GC=1 nix build .#kore-exec .#kore-rpc-booster + + - name: Cache Cabal package database and store + uses: actions/cache@v4 + with: + path: | + ~/.cabal/packages + ~/.cabal/store + key: cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('cabal.project') }}-${{ hashFiles('cabal.project.freeze') }}-${{ hashFiles('kore/kore.cabal') }}-${{ hashFiles('kore-rpc-types/kore-rpc-types.cabal') }}-${{ hashFiles('booster/hs-backend-booster.cabal') }} + restore-keys: | + cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('cabal.project') }}-${{ hashFiles('cabal.project.freeze') }}-${{ hashFiles('kore/kore.cabal') }}-${{ hashFiles('kore-rpc-types/kore-rpc-types.cabal') }} + cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('cabal.project') }}-${{ hashFiles('cabal.project.freeze') }}-${{ hashFiles('kore/kore.cabal') }} + cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('cabal.project') }}-${{ hashFiles('cabal.project.freeze') }} + cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('cabal.project') }} + cabal-nix-${{ runner.os }}-ghc-${{ env.ghc_version }} + + - name: Run unit tests + if: ${{ steps.changes.outputs.booster == 'true' || steps.changes.outputs.kore == 'true' || steps.changes.outputs.project == 'true' }} + run: GC_DONT_GC=1 nix develop .#cabal --command bash -c "cabal update && cabal build all && cabal test --enable-tests --test-show-details=direct kore-test unit-tests" + + - name: Run booster integration tests + if: ${{ (steps.changes.outputs.booster == 'true' || steps.changes.outputs.kore_rpc_types == 'true' || steps.changes.outputs.project == 'true') }} run: | GC_DONT_GC=1 nix develop .#cabal --command bash -c "scripts/booster-integration-tests.sh" - name: Run kore integration tests - # FIXME do not run this unless anything has changed in a relevant directory - # see https://github.com/dorny/paths-filter + # do not run this unless anything has changed in a relevant directory + if: ${{ (steps.changes.outputs.kore == 'true' || steps.changes.outputs.kore_rpc_types == 'true' || steps.changes.outputs.kore_tests == 'true' || steps.changes.outputs.project == 'true') }} run: | - nix develop github:runtimeverification/k/v$(cat deps/k_release)#kore-integration-tests \ + GC_DONT_GC=1 nix develop github:runtimeverification/k/v$(cat deps/k_release)#kore-integration-tests \ --override-input haskell-backend . --update-input haskell-backend \ --command bash -c "cd test && make -j2 --output-sync test"