-
-
Notifications
You must be signed in to change notification settings - Fork 6
263 lines (226 loc) · 8.63 KB
/
CICD.yml
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
name: CICD
on:
push:
branches:
- master
- dev
paths:
- '.github/workflows/**'
- 'src/**'
- 'tests/**'
- 'crates/**'
- 'node-plugins/**'
- '*.rs'
- '*.toml'
- '*.ini'
- '*.lock'
pull_request:
branches:
- master
paths:
- '.github/workflows/**'
- 'src/**'
- 'tests/**'
- 'crates/**'
- 'node-plugins/**'
- '*.rs'
- '*.toml'
- '*.ini'
- '*.lock'
permissions:
contents: read
env:
RUSTFLAGS: -Dwarnings
jobs:
build-and-test-windows:
name: Build and Test on Windows
runs-on: windows-latest
strategy:
matrix:
target: [x86_64-pc-windows-msvc, x86_64-pc-windows-gnu]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install Python dependencies
run: pip install -r ./tests/requirements.txt
- name: Setup msys2 toolchains
if: endsWith(matrix.target, '-gnu')
uses: msys2/setup-msys2@v2
with:
release: false
install: mingw-w64-x86_64-gcc mingw-w64-i686-gcc
- name: Prepare env for windows
if: endsWith(matrix.target, '-gnu')
run: |
# Add symlinks to the target-specific GNU sysroots for Clang
New-Item -Path "C:\Program Files\LLVM\x86_64-w64-mingw32" -ItemType SymbolicLink -Value "C:\msys64\mingw64\x86_64-w64-mingw32"
New-Item -Path "C:\Program Files\LLVM\i686-w64-mingw32" -ItemType SymbolicLink -Value "C:\msys64\mingw64\i686-w64-mingw32"
# Add paths to GCC executables to PATH
echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\msys64\mingw32\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# Configure CC_<target> environment variables
echo "CC_x86_64_pc_windows_gnu=x86_64-w64-mingw32-gcc" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
echo "CC_i686_pc_windows_gnu=i686-w64-mingw32-gcc" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
# echo "HOST_CC=x86_64-w64-mingw32-gcc" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
components: llvm-tools-preview
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build
run: cargo build --profile ci --workspace --target ${{ matrix.target }} --features full
- name: Run Rust tests
run: cargo test run --workspace --no-fail-fast --features full --target ${{ matrix.target }} --profile ci
build-and-test-linux:
name: Build and Test on Linux (x86-64)
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64-unknown-linux-gnu]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install Python dependencies
run: pip install -r ./tests/requirements.txt
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
components: llvm-tools-preview
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build
run: cargo build --profile ci --workspace --target ${{ matrix.target }} --features full
env:
PYTHON_SYS_EXECUTABLE: ${{ env.PYTHON_SYS_EXECUTABLE }}
- name: Run Rust tests
run: cargo test run --workspace --no-fail-fast --features full --target ${{ matrix.target }} --profile ci
- name: Run Python tests
env:
EDGELINK_BUILD_TARGET: ${{ matrix.target }}
EDGELINK_BUILD_PROFILE: ci
run: pytest ./tests -v
build-and-test-on-arm-linux:
name: Build and Test on ARM Linux
runs-on: ubuntu-latest
strategy:
matrix:
target: [aarch64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf, armv7-unknown-linux-gnueabi]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
components: llvm-tools-preview
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install Python dependencies
run: pip install -r ./tests/requirements.txt
- name: Install dependencies
run: sudo apt-get -y install qemu-user qemu-user-static
- name: Install cross-compilation tools for ARM 64
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu libc-dev-arm64-cross
echo "EDGELINK_TOOLCHAIN_TRIPLE=aarch64-linux-gnu" >> $GITHUB_ENV
echo "EDGELINK_QEMU_CMD=qemu-aarch64-static" >> $GITHUB_ENV
- name: Install cross-compilation tools for ARM 32 (gnueabihf)
if: matrix.target == 'armv7-unknown-linux-gnueabihf'
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf libc-dev-armhf-cross
echo "EDGELINK_TOOLCHAIN_TRIPLE=arm-linux-gnueabihf" >> $GITHUB_ENV
echo "EDGELINK_QEMU_CMD=qemu-arm-static" >> $GITHUB_ENV
- name: Install cross-compilation tools for ARM 32 (gnueabi)
if: matrix.target == 'armv7-unknown-linux-gnueabi'
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabi libc-dev-armel-cross
echo "EDGELINK_TOOLCHAIN_TRIPLE=arm-linux-gnueabi" >> $GITHUB_ENV
echo "EDGELINK_QEMU_CMD=qemu-arm-static" >> $GITHUB_ENV
- name: Build
run: cargo build --profile ci --workspace --target ${{ matrix.target }} --features full --exclude edgelink-pymod
- name: Build tests without running
run: cargo test --profile ci --target ${{ matrix.target }} --features full --exclude edgelink-pymod --no-run --message-format=json | tee ./target/${{ matrix.target }}/ci/cargo-build-test.json
- name: Run unit tests in QEMU ARM
run: python3 ./scripts/cross-unittest.py ${{ env.EDGELINK_QEMU_CMD }} ${{ env.EDGELINK_TOOLCHAIN_TRIPLE }} ./target/${{ matrix.target }}/ci/cargo-build-test.json
env:
EDGELINK_TOOLCHAIN_TRIPLE: ${{ env.EDGELINK_TOOLCHAIN_TRIPLE }}
EDGELINK_QEMU_CMD: ${{ env.EDGELINK_QEMU_CMD }}
fmt:
name: Format checking
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: x86_64-unknown-linux-gnu
components: rustfmt
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Check code formatting
run: cargo fmt --check --all
clippy:
name: Format and Clippy
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: x86_64-unknown-linux-gnu
components: clippy
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Clippy
run: cargo clippy --all-features --tests --all