From 87cc11e150c2f06b46ffdbd9d0f90c1171c647a7 Mon Sep 17 00:00:00 2001 From: Sam Barnes Date: Sat, 19 Aug 2023 08:35:14 -0600 Subject: [PATCH 1/2] ci: auto-discover all strategies and matrix forge tests across them --- .github/workflows/contracts.yml | 22 +++++++++++++++++++--- .gitignore | 2 ++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index 137c973..6dbbc89 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -6,8 +6,25 @@ on: pull_request: jobs: + # Discover all strategies in the project + strategy-list: + name: Strategy list + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v2 + - id: set-matrix + run: echo "::set-output name=matrix::$(ls ./crates/strategies | jq -R -s -c 'split("\n")[:-1]')" + + # Matrix across all discovered strategies tests: runs-on: ubuntu-latest + needs: [strategy-list] + strategy: + fail-fast: false + matrix: + target: ${{ fromJson(needs.strategy-list.outputs.matrix) }} env: ETH_MAINNET_HTTP: https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf steps: @@ -21,6 +38,5 @@ jobs: - name: Foundry version run: forge --version - # We need to run tests for every strategy independently - - name: Run Opensea Sudo Arb tests - run: forge test --root ./crates/strategies/opensea-sudo-arb/contracts + - name: Run ${{ matrix.target }} tests + run: forge test --root ./crates/strategies/${{ matrix.target }}/contracts diff --git a/.gitignore b/.gitignore index 7a8469f..9613d14 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ monitoring/grafana/data/ # Dotenv file .env + +.idea/ From 554523729f10d3a0431704b0abc8def15f2c1d8a Mon Sep 17 00:00:00 2001 From: Sam Barnes Date: Sat, 19 Aug 2023 08:56:11 -0600 Subject: [PATCH 2/2] fix: use non-deprecated output syntax --- .github/workflows/contracts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index 6dbbc89..bd0f801 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@v2 - id: set-matrix - run: echo "::set-output name=matrix::$(ls ./crates/strategies | jq -R -s -c 'split("\n")[:-1]')" + run: echo "matrix=$(ls ./crates/strategies | jq -R -s -c 'split("\n")[:-1]')" >> "$GITHUB_OUTPUT" # Matrix across all discovered strategies tests: