Skip to content

Commit 9a8126e

Browse files
committed
ci: add reusable bootstrap and reusable foundry test workflows
1 parent 1b2fd7e commit 9a8126e

File tree

4 files changed

+124
-57
lines changed

4 files changed

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

.github/workflows/regular-mainnet.yml

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,7 @@ env:
1717

1818
jobs:
1919
bootstrap:
20-
name: Bootstrap environment
21-
runs-on: ubuntu-latest
22-
outputs:
23-
cache-path: ${{ steps.cache.outputs.path }}
24-
cache-key: ${{ steps.cache.outputs.key }}
25-
env:
26-
JUST_TAG: 1.24.0
27-
steps:
28-
- name: Build cache params
29-
id: cache
30-
run: |
31-
echo "path=$CACHE_PATH" >> "$GITHUB_OUTPUT"
32-
echo "$KEY_INPUT" | md5sum | awk '{print $1}' | xargs -I% echo "key=cargobin-%-${RUNNER_OS}" >> "$GITHUB_OUTPUT"
33-
env:
34-
CACHE_PATH: |
35-
~/.cargo/bin/
36-
KEY_INPUT: |
37-
just:${{env.JUST_TAG}}
38-
39-
- uses: actions/cache@v4
40-
id: get-cache
41-
with:
42-
path: ${{ steps.cache.outputs.path }}
43-
key: ${{ steps.cache.outputs.key }}
44-
45-
- name: Install just
46-
run: cargo install "just@$JUST_TAG"
47-
if: steps.get-cache.outputs.cache-hit != 'true'
20+
uses: ./.github/workflows/reusable-bootstrap.yml
4821

4922
test:
5023
name: Integration & Invariant tests
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Shared bootstrap for installing just with cache
2+
---
3+
name: Reusable bootstrap
4+
5+
on:
6+
workflow_call:
7+
outputs:
8+
cache-path:
9+
description: Path used for caching just binary.
10+
value: ${{ jobs.bootstrap.outputs.cache-path }}
11+
cache-key:
12+
description: Cache key for just binary.
13+
value: ${{ jobs.bootstrap.outputs.cache-key }}
14+
15+
jobs:
16+
bootstrap:
17+
name: Bootstrap environment
18+
runs-on: ubuntu-latest
19+
outputs:
20+
cache-path: ${{ steps.cache.outputs.path }}
21+
cache-key: ${{ steps.cache.outputs.key }}
22+
env:
23+
JUST_TAG: 1.24.0
24+
steps:
25+
- name: Build cache params
26+
id: cache
27+
run: |
28+
echo "path=$CACHE_PATH" >> "$GITHUB_OUTPUT"
29+
echo "$KEY_INPUT" | md5sum | awk '{print $1}' | xargs -I% echo "key=cargobin-%-${RUNNER_OS}" >> "$GITHUB_OUTPUT"
30+
env:
31+
CACHE_PATH: |
32+
~/.cargo/bin/
33+
KEY_INPUT: |
34+
just:${{env.JUST_TAG}}
35+
36+
- uses: actions/cache@v4
37+
id: get-cache
38+
with:
39+
path: ${{ steps.cache.outputs.path }}
40+
key: ${{ steps.cache.outputs.key }}
41+
42+
- name: Install just
43+
run: cargo install "just@$JUST_TAG"
44+
if: steps.get-cache.outputs.cache-hit != 'true'

.github/workflows/test.yml

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,8 @@ jobs:
2222
actions:
2323
uses: lidofinance/linters/.github/workflows/actions.yml@master
2424

25-
# Maybe to make it reusable workflow instead?
2625
bootstrap:
27-
name: Bootstrap environment
28-
runs-on: ubuntu-latest
29-
outputs:
30-
cache-path: ${{ steps.cache.outputs.path }}
31-
cache-key: ${{ steps.cache.outputs.key }}
32-
env:
33-
JUST_TAG: 1.24.0
34-
steps:
35-
- name: Build cache params
36-
id: cache
37-
run: |
38-
echo "path=$CACHE_PATH" >> "$GITHUB_OUTPUT"
39-
echo "$KEY_INPUT" | md5sum | awk '{print $1}' | xargs -I% echo "key=cargobin-%-${RUNNER_OS}" >> "$GITHUB_OUTPUT"
40-
env:
41-
CACHE_PATH: |
42-
~/.cargo/bin/
43-
KEY_INPUT: |
44-
just:${{env.JUST_TAG}}
45-
46-
- uses: actions/cache@v4
47-
id: get-cache
48-
with:
49-
path: ${{ steps.cache.outputs.path }}
50-
key: ${{ steps.cache.outputs.key }}
51-
52-
- name: Install just
53-
run: cargo install "just@$JUST_TAG"
54-
if: steps.get-cache.outputs.cache-hit != 'true'
26+
uses: ./.github/workflows/reusable-bootstrap.yml
5527

5628
linters:
5729
name: Linters

0 commit comments

Comments
 (0)