Skip to content

Commit ea29eed

Browse files
authored
feat(ci): run unit test jobs on arm64 machines additionally (#12864)
* chore: move test metadata retrieval to a new Go CLI tool * ci: install go before retrieving test group metadata * ci: run unit tests on arm64 machines * ci: fix the packages metadata * ci: cache deps per runner os and arch * chore: rename name to testGroupName where applicable * chore: add createPackagePath helper * chore: turn runners into an enumerated type * chore: sort testGroupNamesToRunners * chore: rename find/getIntegrationTestGroups * chore: use for-loop to get unit and other test groups * chore: reorganize the ci cli * chore: rename list test groups * chore: restore the runner selection * chore: resolve pull request review comments
1 parent 2cb2608 commit ea29eed

File tree

3 files changed

+467
-156
lines changed

3 files changed

+467
-156
lines changed

.github/workflows/test.yml

Lines changed: 66 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -24,155 +24,24 @@ jobs:
2424
name: Discover Test Groups
2525
runs-on: ubuntu-latest
2626
outputs:
27-
groups: ${{ steps.test.outputs.groups }}
27+
test_group_execution_contexts: ${{ steps.list_test_group_execution_contexts.outputs.test_group_execution_contexts }}
2828
steps:
2929
- uses: actions/checkout@v4
3030
with:
3131
submodules: 'recursive'
3232
fetch-depth: 0
33-
- id: test
34-
env:
35-
# Unit test groups other than unit-rest
36-
utests: |
37-
[
38-
{"name": "unit-cli", "packages": ["./cli/...", "./cmd/...", "./api/..."]},
39-
{"name": "unit-storage", "packages": ["./storage/...", "./extern/..."]},
40-
{"name": "unit-node", "packages": ["./node/..."]}
41-
]
42-
# Other tests that require special configuration
43-
otests: |
44-
[
45-
{
46-
"name": "multicore-sdr",
47-
"packages": ["./storage/sealer/ffiwrapper"],
48-
"go_test_flags": "-run=TestMulticoreSDR",
49-
"test_rustproofs_logs": "1"
50-
}, {
51-
"name": "conformance",
52-
"packages": ["./conformance"],
53-
"go_test_flags": "-run=TestConformance",
54-
"skip_conformance": "0"
55-
}
56-
]
57-
# Mapping from test group names to custom runner labels
58-
# The jobs default to running on the default hosted runners (4 CPU, 16 RAM).
59-
# We use self-hosted xlarge (4 CPU, 8 RAM; and large - 2 CPU, 4 RAM) runners
60-
# to extend the available runner capacity (60 default hosted runners).
61-
# We use self-hosted 4xlarge (16 CPU, 32 RAM; and 2xlarge - 8 CPU, 16 RAM) self-hosted
62-
# to support resource intensive jobs.
63-
runners: |
64-
{
65-
"itest-niporep_manual": ["self-hosted", "linux", "x64", "4xlarge"],
66-
"itest-sector_pledge": ["self-hosted", "linux", "x64", "4xlarge"],
67-
"itest-worker": ["self-hosted", "linux", "x64", "4xlarge"],
68-
"itest-manual_onboarding": ["self-hosted", "linux", "x64", "4xlarge"],
69-
70-
"itest-gateway": ["self-hosted", "linux", "x64", "2xlarge"],
71-
"itest-sector_import_full": ["self-hosted", "linux", "x64", "2xlarge"],
72-
"itest-sector_import_simple": ["self-hosted", "linux", "x64", "2xlarge"],
73-
"itest-wdpost": ["self-hosted", "linux", "x64", "2xlarge"],
74-
"unit-storage": ["self-hosted", "linux", "x64", "2xlarge"],
75-
76-
"itest-cli": ["self-hosted", "linux", "x64", "xlarge"],
77-
"itest-deals_invalid_utf8_label": ["self-hosted", "linux", "x64", "xlarge"],
78-
"itest-decode_params": ["self-hosted", "linux", "x64", "xlarge"],
79-
"itest-dup_mpool_messages": ["self-hosted", "linux", "x64", "xlarge"],
80-
"itest-eth_account_abstraction": ["self-hosted", "linux", "x64", "xlarge"],
81-
"itest-eth_api": ["self-hosted", "linux", "x64", "xlarge"],
82-
"itest-eth_balance": ["self-hosted", "linux", "x64", "xlarge"],
83-
"itest-eth_bytecode": ["self-hosted", "linux", "x64", "xlarge"],
84-
"itest-eth_config": ["self-hosted", "linux", "x64", "xlarge"],
85-
"itest-eth_conformance": ["self-hosted", "linux", "x64", "xlarge"],
86-
"itest-eth_deploy": ["self-hosted", "linux", "x64", "xlarge"],
87-
"itest-eth_fee_history": ["self-hosted", "linux", "x64", "xlarge"],
88-
"itest-eth_transactions": ["self-hosted", "linux", "x64", "xlarge"],
89-
"itest-fevm_address": ["self-hosted", "linux", "x64", "xlarge"],
90-
"itest-fevm_events": ["self-hosted", "linux", "x64", "xlarge"],
91-
"itest-gas_estimation": ["self-hosted", "linux", "x64", "xlarge"],
92-
"itest-get_messages_in_ts": ["self-hosted", "linux", "x64", "xlarge"],
93-
"itest-lite_migration": ["self-hosted", "linux", "x64", "xlarge"],
94-
"itest-lookup_robust_address": ["self-hosted", "linux", "x64", "xlarge"],
95-
"itest-mempool": ["self-hosted", "linux", "x64", "xlarge"],
96-
"itest-mpool_msg_uuid": ["self-hosted", "linux", "x64", "xlarge"],
97-
"itest-mpool_push_with_uuid": ["self-hosted", "linux", "x64", "xlarge"],
98-
"itest-msgindex": ["self-hosted", "linux", "x64", "xlarge"],
99-
"itest-multisig": ["self-hosted", "linux", "x64", "xlarge"],
100-
"itest-net": ["self-hosted", "linux", "x64", "xlarge"],
101-
"itest-nonce": ["self-hosted", "linux", "x64", "xlarge"],
102-
"itest-path_detach_redeclare": ["self-hosted", "linux", "x64", "xlarge"],
103-
"itest-pending_deal_allocation": ["self-hosted", "linux", "x64", "xlarge"],
104-
"itest-remove_verifreg_datacap": ["self-hosted", "linux", "x64", "xlarge"],
105-
"itest-sector_miner_collateral": ["self-hosted", "linux", "x64", "xlarge"],
106-
"itest-sector_numassign": ["self-hosted", "linux", "x64", "xlarge"],
107-
"itest-self_sent_txn": ["self-hosted", "linux", "x64", "xlarge"],
108-
"itest-verifreg": ["self-hosted", "linux", "x64", "xlarge"],
109-
"multicore-sdr": ["self-hosted", "linux", "x64", "xlarge"],
110-
"unit-node": ["self-hosted", "linux", "x64", "xlarge"]
111-
}
112-
# A list of test groups that require Proof Parameters to be fetched
113-
parameters: |
114-
[
115-
"conformance",
116-
"itest-api",
117-
"itest-direct_data_onboard_verified",
118-
"itest-direct_data_onboard",
119-
"itest-manual_onboarding",
120-
"itest-niporep_manual",
121-
"itest-net",
122-
"itest-path_detach_redeclare",
123-
"itest-sealing_resources",
124-
"itest-sector_import_full",
125-
"itest-sector_import_simple",
126-
"itest-sector_pledge",
127-
"itest-sector_unseal",
128-
"itest-wdpost_no_miner_storage",
129-
"itest-wdpost_worker_config",
130-
"itest-wdpost",
131-
"itest-worker",
132-
"multicore-sdr",
133-
"unit-cli",
134-
"unit-storage"
135-
]
33+
- id: list_test_group_execution_contexts
13634
run: |
137-
# Create a list of integration test groups
138-
itests="$(
139-
find ./itests -name "*_test.go" | \
140-
jq -R '{
141-
"name": "itest-\(. | split("/") | .[2] | sub("_test.go$";""))",
142-
"packages": [.]
143-
}' | jq -s
144-
)"
145-
146-
# Create a list of packages that are covered by the integration and unit tests
147-
packages="$(jq -n --argjson utests "$utests" '$utests | map(.packages) | flatten | . + ["./itests/..."]')"
148-
149-
# Create a new group for the unit tests that are not yet covered
150-
rest="$(
151-
find . -name "*_test.go" | cut -d/ -f2 | sort | uniq | \
152-
jq -R '"./\(.)/..."' | \
153-
jq -s --argjson p "$packages" '{"name": "unit-rest", "packages": (. - $p)}'
154-
)"
155-
156-
# Combine the groups for integration tests, unit tests, the new unit-rest group, and the other tests
157-
groups="$(jq -n --argjson i "$itests" --argjson u "$utests" --argjson r "$rest" --argjson o "$otests" '$i + $u + [$r] + $o')"
158-
159-
# Apply custom runner labels to the groups
160-
groups="$(jq -n --argjson g "$groups" --argjson r "$runners" '$g | map(. + {"runner": (.name as $n | $r | .[$n]) })')"
161-
162-
# Apply the needs_parameters flag to the groups
163-
groups="$(jq -n --argjson g "$groups" --argjson p "$parameters" '$g | map(. + {"needs_parameters": ([.name] | inside($p)) })')"
164-
165-
# Output the groups
166-
echo "groups=$groups"
167-
echo "groups=$(jq -nc --argjson g "$groups" '$g')" >> $GITHUB_OUTPUT
35+
echo "test_group_execution_contexts<<EOF" >> $GITHUB_OUTPUT
36+
go run ./cmd/ci/main.go --json list-test-group-execution-contexts | jq -r '.msg' | tee -a $GITHUB_OUTPUT
37+
echo "EOF" >> $GITHUB_OUTPUT
16838
cache:
16939
name: Cache Dependencies
170-
runs-on: ubuntu-latest
171-
outputs:
172-
fetch_params_key: ${{ steps.fetch_params.outputs.key }}
173-
fetch_params_path: ${{ steps.fetch_params.outputs.path }}
174-
make_deps_key: ${{ steps.make_deps.outputs.key }}
175-
make_deps_path: ${{ steps.make_deps.outputs.path }}
40+
runs-on: ${{ matrix.runner }}
41+
strategy:
42+
matrix:
43+
# We need to cache for each architecture we support: x86_64 and arm64
44+
runner: [ubuntu-latest, ubuntu-24.04-arm]
17645
steps:
17746
- uses: actions/checkout@v4
17847
with:
@@ -230,35 +99,76 @@ jobs:
23099
with:
231100
key: ${{ steps.make_deps.outputs.key }}
232101
path: ${{ steps.make_deps.outputs.path }}
102+
- env:
103+
fetch_params_key: ${{ steps.fetch_params.outputs.key }}
104+
fetch_params_path: ${{ steps.fetch_params.outputs.path }}
105+
make_deps_key: ${{ steps.make_deps.outputs.key }}
106+
make_deps_path: ${{ steps.make_deps.outputs.path }}
107+
file: jobs.cache.${{ runner.os }}.${{ runner.arch }}.outputs.json
108+
run: |
109+
jq -n '{
110+
"fetch_params_key": env.fetch_params_key,
111+
"fetch_params_path": env.fetch_params_path,
112+
"make_deps_key": env.make_deps_key,
113+
"make_deps_path": env.make_deps_path
114+
}' | tee -a "$file"
115+
- uses: actions/upload-artifact@v4
116+
with:
117+
name: jobs.cache.${{ runner.os }}.${{ runner.arch }}.outputs
118+
path: jobs.cache.${{ runner.os }}.${{ runner.arch }}.outputs.json
233119
test:
234120
needs: [discover, cache]
235-
name: Test (${{ matrix.name }})
236-
runs-on: ${{ github.repository_owner == 'filecoin-project' && matrix.runner || 'ubuntu-latest' }}
121+
name: Test (${{ matrix.name }}) ${{ toJson(matrix.runner) }}
122+
runs-on: ${{ matrix.runner }}
237123
strategy:
238124
fail-fast: false
239125
matrix:
240-
include: ${{ fromJson(needs.discover.outputs.groups) }}
126+
include: ${{ fromJson(needs.discover.outputs.test_group_execution_contexts) }}
241127
steps:
242128
- uses: actions/checkout@v4
243129
with:
244130
submodules: 'recursive'
245131
fetch-depth: 0
246132
- uses: ./.github/actions/install-system-dependencies
247133
- uses: ./.github/actions/install-go
134+
- id: group
135+
run: |
136+
echo "metadata<<EOF" >> $GITHUB_OUTPUT
137+
go run ./cmd/ci/main.go --json get-test-group-metadata --name "${{ matrix.name }}" | jq -r '.msg' | tee -a $GITHUB_OUTPUT
138+
echo "EOF" >> $GITHUB_OUTPUT
248139
- name: Install gotestsum
249140
run: go install gotest.tools/gotestsum@latest
141+
- id: artifact
142+
uses: actions/download-artifact@v4
143+
with:
144+
name: jobs.cache.${{ runner.os }}.${{ runner.arch }}.outputs
145+
- id: cache
146+
env:
147+
file: jobs.cache.${{ runner.os }}.${{ runner.arch }}.outputs.json
148+
run: |
149+
echo "make_deps_key=$(jq -r .make_deps_key "$file")" | tee -a $GITHUB_OUTPUT
150+
echo "make_deps_path<<EOF" | tee -a $GITHUB_OUTPUT
151+
jq -r .make_deps_path "$file" | tee -a $GITHUB_OUTPUT
152+
echo "EOF" | tee -a $GITHUB_OUTPUT
153+
154+
echo "fetch_params_key=$(jq -r .fetch_params_key "$file")" | tee -a $GITHUB_OUTPUT
155+
echo "fetch_params_path<<EOF" | tee -a $GITHUB_OUTPUT
156+
jq -r .fetch_params_path "$file" | tee -a $GITHUB_OUTPUT
157+
echo "EOF" | tee -a $GITHUB_OUTPUT
158+
159+
rm "$file"
250160
- name: Restore cached make deps outputs
251161
uses: actions/cache/restore@v4
252162
with:
253-
key: ${{ needs.cache.outputs.make_deps_key }}
254-
path: ${{ needs.cache.outputs.make_deps_path }}
163+
key: ${{ steps.cache.outputs.make_deps_key }}
164+
path: ${{ steps.cache.outputs.make_deps_path }}
255165
fail-on-cache-miss: true
256-
- if: ${{ matrix.needs_parameters }}
166+
- if: ${{ fromJson(steps.group.outputs.metadata).needs_parameters }}
257167
name: Restore cached fetch params outputs
258168
uses: actions/cache/restore@v4
259169
with:
260-
key: ${{ needs.cache.outputs.fetch_params_key }}
261-
path: ${{ needs.cache.outputs.fetch_params_path }}
170+
key: ${{ steps.cache.outputs.fetch_params_key }}
171+
path: ${{ steps.cache.outputs.fetch_params_path }}
262172
fail-on-cache-miss: true
263173
# TODO: Install statediff (used to be used for conformance)
264174
- name: Create temporary directory for reports
@@ -270,22 +180,22 @@ jobs:
270180
NAME: ${{ matrix.name }}
271181
LOTUS_SRC_DIR: ${{ github.workspace }}
272182
REPORTS_PATH: ${{ steps.reports.outputs.path }}
273-
SKIP_CONFORMANCE: ${{ matrix.skip_conformance || '1' }}
274-
TEST_RUSTPROOFS_LOGS: ${{ matrix.test_rustproofs_logs || '0' }}
275-
FORMAT: ${{ matrix.format || 'standard-verbose' }}
276-
PACKAGES: ${{ join(matrix.packages, ' ') }}
183+
SKIP_CONFORMANCE: ${{ fromJson(steps.group.outputs.metadata).skip_conformance && '1' || '0' }}
184+
TEST_RUSTPROOFS_LOGS: ${{ fromJson(steps.group.outputs.metadata).test_rustproofs_logs && '1' || '0' }}
185+
FORMAT: ${{ fromJson(steps.group.outputs.metadata).format || 'standard-verbose' }}
186+
PACKAGES: ${{ join(fromJson(steps.group.outputs.metadata).packages, ' ') }}
277187
run: |
278188
gotestsum \
279189
--format "$FORMAT" \
280190
--junitfile "$REPORTS_PATH/$NAME.xml" \
281191
--jsonfile "$REPORTS_PATH/$NAME.json" \
282192
--packages="$PACKAGES" \
283-
-- ${{ matrix.go_test_flags || '' }}
193+
-- ${{ fromJson(steps.group.outputs.metadata).go_test_flags || '' }}
284194
- name: Modify junit.xml for BuildPulse
285195
env:
286196
NAME: ${{ matrix.name }}
287197
REPORTS_PATH: ${{ steps.reports.outputs.path }}
288-
PACKAGES: ${{ join(matrix.packages, ' ') }}
198+
PACKAGES: ${{ join(fromJson(steps.group.outputs.metadata).packages, ' ') }}
289199
if: always()
290200
run: |
291201
# Modify test suite name and classname attributes in JUnit XML for better grouping
@@ -303,7 +213,7 @@ jobs:
303213
- if: success() || failure()
304214
uses: actions/upload-artifact@v4
305215
with:
306-
name: ${{ matrix.name }}
216+
name: ${{ matrix.name }}-${{ runner.os }}-${{ runner.arch }}
307217
path: |
308218
${{ steps.reports.outputs.path }}/${{ matrix.name }}.xml
309219
${{ steps.reports.outputs.path }}/${{ matrix.name }}.json

cmd/ci/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Lotus CI Tool
2+
3+
The Lotus CI Tool is a CLI (Command Line Interface) utility designed to facilitate interactions with the Lotus metadata. This tool allows users to retrieve version information in either JSON or text format which is required in the Lotus CI environment.
4+
5+
## Features
6+
7+
- List all test group execution contexts.
8+
- Get the metadata for a test group.
9+
10+
## Installation
11+
12+
To install the Lotus CI Tool, you need to have Go installed on your system.
13+
14+
1. Build the tool:
15+
```sh
16+
go build -o ci ./cmd/ci
17+
```
18+
19+
## Usage
20+
21+
The `ci` tool provides several commands and options to interact with.
22+
23+
### Commands
24+
25+
- **List Test Group Execution Contexts**: List all test group execution contexts.
26+
```sh
27+
./ci list-test-group-execution-contexts
28+
```
29+
- **Get Test Group Metadata**: Get the metadata for a test group.
30+
```sh
31+
./ci get-test-group-metadata --name "unit-cli"
32+
```
33+
34+
### Global Options
35+
36+
- **--json**: Format output as JSON.
37+
```sh
38+
./ci --json
39+
```
40+
41+
## Examples
42+
43+
List all test group execution contexts with JSON formatted output:
44+
```sh
45+
./ci --json list-test-group-execution-contexts
46+
```
47+
48+
Get the metadata for a test group with JSON formatted output:
49+
```sh
50+
./ci --json get-test-group-metadata --name "unit-cli"
51+
```

0 commit comments

Comments
 (0)