-
Notifications
You must be signed in to change notification settings - Fork 261
Expand file tree
/
Copy pathcall.test-ethereum-contracts.yml
More file actions
130 lines (109 loc) · 4.04 KB
/
call.test-ethereum-contracts.yml
File metadata and controls
130 lines (109 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Reusable Workflow | Test Ethereum Contracts
on:
workflow_call:
inputs:
run-coverage-tests:
required: true
type: boolean
jobs:
# When this scrip is written, it is the only way to preparing conditional matrix:
# Ref: https://stackoverflow.com/questions/65384420/how-do-i-make-a-github-action-matrix-element-conditional
matrix-prep:
name: Preparing Conditional Strategy Matrix
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set matrix variable
id: set-matrix
run: |
if [ "${{ inputs.run-coverage-tests }}" == "true" ];then
echo "matrix={\"node-version\": [24]}" >> "$GITHUB_OUTPUT"
else
echo "matrix={\"node-version\": [20, 22, 24]}" >> "$GITHUB_OUTPUT"
fi
test-ethereum-contracts:
name: Test ethereum-contracts
needs: [matrix-prep]
runs-on: ubuntu-22.04
strategy:
matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }}
fail-fast: false
env:
DEV_SHELL_NAME: ci-node${{ matrix.node-version }}
defaults:
run:
shell: nix develop .#${{ env.DEV_SHELL_NAME }} -c bash -xe {0}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set cache key prefix
id: set-cache-key-prefix
run: |
if [ "${{ inputs.run-coverage-tests }}" == false ]; then
v=ethereum-contracts-${{ env.DEV_SHELL_NAME }}-test-
else
v=ethereum-contracts-${{ env.DEV_SHELL_NAME }}-coverage-
fi
echo "cache_key_prefix=$v" >> "$GITHUB_OUTPUT"
shell: bash
- name: Setup workflow base
id: base
uses: ./.github/actions/setup-workflow-base
with:
package-name: ethereum-contracts
cache-key-prefix: ${{ steps.set-cache-key-prefix.outputs.cache_key_prefix }}
dev-shell-name: ${{ env.DEV_SHELL_NAME }}
- name: Install dependencies
if: steps.base.outputs.cache-hit != 'true'
run: |
yarn install --frozen-lockfile
solc --version
forge --version
npx tsc --version
npx hardhat --version
- name: Lint and build
if: steps.base.outputs.cache-hit != 'true'
run: |
yarn lint
yarn build
- name: Run test suite
if: steps.base.outputs.cache-hit != 'true' && inputs.run-coverage-tests == false
run: |
echo "FOUNDRY_PROFILE=ci" >> $GITHUB_ENV
yarn test
cat testing-benchmark.json
working-directory: ./packages/ethereum-contracts
env:
HARDHAT_TEST_JOBS: 4
HARDHAT_RUN_PARALLEL: 1
- name: Run coverage test
if: steps.base.outputs.cache-hit != 'true' && inputs.run-coverage-tests == true
run: |
echo "FOUNDRY_PROFILE=ci" >> $GITHUB_ENV
yarn test-coverage
working-directory: ./packages/ethereum-contracts
# NOTE: currently coverage report is not working properly in parallel mode.
#
# Upstream issue: https://github.com/NomicFoundation/hardhat/issues/4310
# Though more likely, it is an issue to https://github.com/sc-forks/solidity-coverage
env:
# NOTE: 4 workers would overwhelm the free-tier github runner
NODE_OPTIONS: --max_old_space_size=4096
IS_COVERAGE_TEST: true
HARDHAT_TEST_JOBS: 2
HARDHAT_RUN_PARALLEL: 0
- name: Clean up and merge coverage artifacts
if: steps.base.outputs.cache-hit != 'true' && inputs.run-coverage-tests == true
run: ./tasks/coverage-cleanup.sh
working-directory: ./packages/ethereum-contracts
- name: Create coverage artifact
if: inputs.run-coverage-tests == true
uses: actions/upload-artifact@v4
with:
name: ethereum-contracts-coverage
path: |
packages/ethereum-contracts/coverage/