Skip to content

Commit 52ab4de

Browse files
authored
ci: add regression composite action (#642)
## Description - add composite GitHub Action `.github/actions/regression-tests` so external workflows can build and run repo tests while controlling fork setup on their side an example: lidofinance/scripts#544 ## Checklist - [x] Appropriate PR labels applied - [ ] Test coverage maintained (`just coverage`) - [x] No need to add/update tests - [ ] Tests are added/updated - [ ] Documentation maintained - [x] No need to update - [ ] Updated
1 parent d521f55 commit 52ab4de

File tree

2 files changed

+101
-14
lines changed

2 files changed

+101
-14
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: "Regression tests"
2+
description: "Checkout and run regression tests for community-staking-module"
3+
4+
inputs:
5+
rpc_url:
6+
description: "RPC URL injected as RPC_URL env for fork tests."
7+
required: true
8+
repository:
9+
description: "Repository to checkout (owner/repo)."
10+
required: false
11+
default: "lidofinance/community-staking-module"
12+
ref:
13+
description: "Git ref of the repository to test."
14+
required: false
15+
default: "main"
16+
path:
17+
description: "Path to checkout the repository."
18+
required: false
19+
default: "community-staking-module"
20+
21+
runs:
22+
using: "composite"
23+
steps:
24+
- name: Checkout community-staking-module
25+
uses: actions/checkout@v4
26+
with:
27+
repository: ${{ inputs.repository }}
28+
ref: ${{ inputs.ref }}
29+
path: ${{ inputs.path }}
30+
31+
- name: Set env vars
32+
shell: bash
33+
working-directory: ${{ inputs.path }}
34+
run: |
35+
echo "FOUNDRY_VERSION=$(head .foundryref)" >> "$GITHUB_ENV"
36+
echo "JUST_TAG=1.24.0" >> "$GITHUB_ENV"
37+
38+
- name: Cache just
39+
id: just-cache
40+
uses: actions/cache@v4
41+
with:
42+
path: ~/.cargo/bin/
43+
key: cargobin-${{ runner.os }}-just-${{ env.JUST_TAG }}
44+
45+
- name: Install just
46+
shell: bash
47+
run: |
48+
if ! command -v just >/dev/null 2>&1; then
49+
cargo install "just@${JUST_TAG}"
50+
fi
51+
52+
- name: Install Foundry
53+
uses: foundry-rs/foundry-toolchain@v1
54+
with:
55+
version: ${{ env.FOUNDRY_VERSION }}
56+
57+
- name: Install node
58+
uses: actions/setup-node@v4
59+
with:
60+
node-version-file: "${{ inputs.path }}/.nvmrc"
61+
cache: yarn
62+
cache-dependency-path: "${{ inputs.path }}/**/yarn.lock"
63+
64+
- name: Install dependencies
65+
shell: bash
66+
working-directory: ${{ inputs.path }}
67+
run: just deps
68+
69+
- name: Build
70+
shell: bash
71+
working-directory: ${{ inputs.path }}
72+
run: just build
73+
74+
- name: Run regression tests
75+
shell: bash
76+
working-directory: ${{ inputs.path }}
77+
run: just test-integration
78+
env:
79+
RPC_URL: ${{ inputs.rpc_url }}
80+
CHAIN: mainnet
81+
DEPLOY_CONFIG: ./artifacts/mainnet/upgrade-v2-mainnet.json
82+
FOUNDRY_PROFILE: ci

.github/workflows/regular-mainnet.yml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,23 @@ jobs:
4646
run: cargo install "just@$JUST_TAG"
4747
if: steps.get-cache.outputs.cache-hit != 'true'
4848

49-
test:
50-
name: Integration & Invariant tests
49+
regression-tests:
50+
name: Regression tests
5151
runs-on: ubuntu-latest
5252
needs: bootstrap
5353
steps:
5454
- uses: actions/checkout@v4
5555
with:
5656
persist-credentials: false
5757

58-
- name: Set FOUNDRY_VERSION
59-
run: echo "FOUNDRY_VERSION=$(head .foundryref)" >> "$GITHUB_ENV"
60-
6158
- uses: actions/cache@v4
6259
with:
6360
path: ${{ needs.bootstrap.outputs.cache-path }}
6461
key: ${{ needs.bootstrap.outputs.cache-key }}
6562

63+
- name: Set FOUNDRY_VERSION
64+
run: echo "FOUNDRY_VERSION=$(head .foundryref)" >> "$GITHUB_ENV"
65+
6666
- name: Install Foundry
6767
uses: foundry-rs/foundry-toolchain@v1
6868
with:
@@ -78,17 +78,22 @@ jobs:
7878
- name: Install dependencies
7979
run: just deps
8080

81-
# TODO: Remove `continue-on-error` after making the contracts fit.
82-
- name: Build
83-
run: just build --sizes
84-
continue-on-error: true
85-
86-
- name: Run post-vote tests
87-
run: just test-post-voting
81+
- name: Start mainnet fork
8882
env:
89-
CHAIN: mainnet
90-
DEPLOY_CONFIG: ./artifacts/mainnet/deploy-mainnet.json
9183
RPC_URL: ${{ secrets.RPC_URL_MAINNET }}
84+
run: just make-fork &
85+
86+
- name: Run regression tests
87+
uses: ./.github/actions/regression-tests
88+
with:
89+
repository: ${{ github.repository }}
90+
ref: v2.0 # Run the stable v2.0 release tests
91+
path: community-staking-module-v2
92+
rpc_url: http://127.0.0.1:8545
93+
94+
- name: Kill fork
95+
if: always()
96+
run: just kill-fork
9297

9398
- name: Echo embeds to the env variable
9499
if: ${{ failure() && (github.event_name == 'schedule' || inputs.notify) }}

0 commit comments

Comments
 (0)