-
Notifications
You must be signed in to change notification settings - Fork 5
176 lines (147 loc) · 5.56 KB
/
test.yml
File metadata and controls
176 lines (147 loc) · 5.56 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
175
176
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:
discover:
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 }}
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
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.rustup/
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.os }}-cargo-${{ hashFiles('rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }}
- name: Setup image (Linux)
if: ${{ contains(matrix.os, 'ubuntu') }}
run: ./.github/scripts/provision-linux-build.sh
- 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]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{fromJson(needs.discover.outputs.matrix)}}
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.rustup/
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.os }}-cargo-${{ hashFiles('rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }}
- name: Setup image (Linux)
if: ${{ contains(matrix.os, 'ubuntu') }}
run: ./.github/scripts/provision-linux-build.sh
- 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 network launcher
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ !contains(matrix.os, 'windows') }}
run: |
VERSION=v11.0.0
OS=""
ARCH=""
# Map runner.os → release suffix
if [[ "${{ runner.os }}" == "Linux" ]]; then
OS="linux"
elif [[ "${{ runner.os }}" == "macOS" ]]; then
OS="darwin"
else
echo "Unsupported OS: ${{ runner.os }}"
exit 1
fi
# Detect architecture
case "$(uname -m)" in
x86_64) ARCH="x86_64" ;;
arm64|aarch64) ARCH="arm64" ;;
*)
echo "Unsupported architecture: $(uname -m)"
exit 1
;;
esac
PERCENT_VERSION=$(printf '%s' "$VERSION" |jq -sRr @uri)
URL="https://github.com/dfinity/icp-cli-network-launcher/releases/download/${PERCENT_VERSION}/icp-cli-network-launcher-${ARCH}-${OS}-${PERCENT_VERSION}.tar.gz"
DEST="/opt/icp-cli-network-launcher"
echo "Downloading $URL"
curl -L "$URL" -H "Authorization: Bearer ${GITHUB_TOKEN}" -o icp-cli-network-launcher.tar.gz
tar -xzf icp-cli-network-launcher.tar.gz
sudo mv icp-cli-network-launcher-${ARCH}-${OS}-${VERSION} "$DEST"
echo "Installed network launcher to $DEST"
echo "ICP_CLI_NETWORK_LAUNCHER_PATH=$DEST/icp-cli-network-launcher" >> "$GITHUB_ENV"
- name: Run ${{ matrix.test }}
# the macos runners do not support Docker
run: cargo test --test ${{ matrix.test }} -- ${{ contains(matrix.os, 'macos') && '--skip :docker:' || '' }}
aggregate:
name: test:required
if: ${{ always() }}
runs-on: ubuntu-latest
needs: [unit-tests, test]
steps:
- name: check result
if: ${{ needs.unit-tests.result != 'success' || needs.test.result != 'success' }}
run: exit 1