-
Notifications
You must be signed in to change notification settings - Fork 3
174 lines (145 loc) · 5.4 KB
/
test.yml
File metadata and controls
174 lines (145 loc) · 5.4 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Test
on:
push:
branches:
- main
pull_request:
env:
# When getting Rust dependencies, retry on network error:
CARGO_NET_RETRY: 10
# Use the local .curlrc
CURL_HOME: .
# Disable incremental compilation
CARGO_INCREMENTAL: 0
# These variables should be shared with WSL
WSLENV: CARGO_INCREMENTAL:CURL_HOME/p:CARGO_NET_RETRY:GITHUB_ENV/p:GITHUB_OUTPUT/p
defaults:
run:
shell: bash
jobs:
changes:
runs-on: ubuntu-latest
outputs:
src: ${{ steps.filter.outputs.src }}
permissions:
pull-requests: read
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
# 'src' is true when any changed file matches a positive pattern
# and does not match a negative pattern (! prefix).
filters: |
src:
- '**'
- '!**.md'
- '!docs/**'
- '!docs-site/**'
- '!npm/**'
discover:
needs: changes
if: needs.changes.outputs.src == 'true'
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- id: set-matrix
run: echo "matrix=$(python3 .github/scripts/test-matrix.py)" >> $GITHUB_OUTPUT
unit-tests:
name: Unit tests on ${{ matrix.os }}
needs: changes
if: needs.changes.outputs.src == 'true'
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Make the os matrix match .github/scripts/test-matrix.py so that
# we optimize caching
os: [ubuntu-22.04, macos-15, windows-2025]
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Setup image (Linux)
if: ${{ contains(matrix.os, 'ubuntu') }}
run: ./.github/scripts/provision-linux-build.sh
- uses: actions-rust-lang/setup-rust-toolchain@a0b538fa0b742a6aa35d6e2c169b4bd06d225a98 # v1.15.3
with:
cache-shared-key: ${{ runner.os }}-test
- uses: t1m0thyj/unlock-keyring@e481cdc8833d4417a58f40734e8f197183317047
if: ${{ contains(matrix.os, 'ubuntu') }}
- name: Run unit tests
run: cargo test --workspace --lib --bins
test:
name: ${{ matrix.test }} on ${{ matrix.os }}
# Wait until unit tests have run so we can reuse the cache
needs: [discover, unit-tests]
# Check discover's result (not changes.outputs.src) because this job
# needs discover's matrix output, which is only available when it ran.
if: needs.discover.result == 'success'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{fromJson(needs.discover.outputs.matrix)}}
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- uses: actions-rust-lang/setup-rust-toolchain@a0b538fa0b742a6aa35d6e2c169b4bd06d225a98 # v1.15.3
with:
cache-shared-key: ${{ runner.os }}-test
- name: Setup image (Linux)
if: ${{ contains(matrix.os, 'ubuntu') }}
run: ./.github/scripts/provision-linux-build.sh && ./.github/scripts/provision-linux-test.sh
- name: Setup image (macOS)
if: ${{ contains(matrix.os, 'macos') }}
run: ./.github/scripts/provision-macos-test.sh
- name: Setup image (Windows)
if: ${{ contains(matrix.os, 'windows') }}
run: .github/scripts/provision-windows-test.ps1
shell: pwsh
- name: Setup WSL2 (Windows)
if: ${{ contains(matrix.os, 'windows') }}
uses: Vampire/setup-wsl@6a8db447be7ed35f2f499c02c6e60ff77ef11278 # v6.0.0
with:
distribution: Ubuntu-22.04
- name: Setup Docker in WSL2 (Windows)
if: ${{ contains(matrix.os, 'windows') }}
run: .github/scripts/init-docker.sh
shell: wsl-bash_Ubuntu-22.04 {0}
- uses: t1m0thyj/unlock-keyring@e481cdc8833d4417a58f40734e8f197183317047
if: ${{ contains(matrix.os, 'ubuntu') }}
- name: Install mops
uses: dfinity/setup-mops@v1
- name: Verify mops installation
run: |
which mops
mops --version
- name: Install ic-wasm
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/dfinity/ic-wasm/releases/download/0.9.10/ic-wasm-installer.sh | sh
- name: Verify ic-wasm installation
run: |
which ic-wasm
ic-wasm --version
- name: Install wasm-tools
uses: taiki-e/install-action@3ae7038495f79cd771208b38319ff728a8b24538 # v2.67.3
with:
tool: wasm-tools
- name: Verify wasm-tools installation
run: |
which wasm-tools
wasm-tools --version
- name: Run ${{ matrix.test }}
# the macos runners do not support Docker
run: cargo test --test ${{ matrix.test }} -- ${{ contains(matrix.os, 'macos') && '--skip :docker:' || '' }}
env:
ICP_CLI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
aggregate:
name: test:required
if: always() && needs.changes.outputs.src == 'true'
runs-on: ubuntu-latest
needs: [changes, unit-tests, test]
steps:
- name: check unit-tests result
if: ${{ needs.unit-tests.result != 'success' }}
run: exit 1
- name: check test result
if: ${{ needs.test.result != 'success' }}
run: exit 1