-
Notifications
You must be signed in to change notification settings - Fork 1
147 lines (127 loc) · 4.85 KB
/
Copy pathdevcontainer-cargo-test.yml
File metadata and controls
147 lines (127 loc) · 4.85 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
name: cargo test
# Two test paths exercise the integration suite:
#
# - test-prebuilt: bare-metal Linux runner, prebuilt BabbleSim binaries
# pulled from the nrf-sim-bridge GitHub Releases. Fast, runs on every
# push, every PR, and nightly.
#
# - test-source-build: full Zephyr/BabbleSim build from source inside the
# dev container (`cargo xtask docker-build` -> `cargo xtask zephyr-setup
# --build-from-source`). Slow but validates the Dockerfile and the
# Zephyr toolchain end-to-end. Nightly by default; can be run manually.
on:
push:
branches:
- main
- master
pull_request:
schedule:
- cron: '0 2 * * *' # 02:00 UTC nightly
workflow_dispatch:
inputs:
run_cargo_check:
description: Run cargo-check job
type: boolean
required: true
default: true
run_test_prebuilt:
description: Run prebuilt test job
type: boolean
required: true
default: true
run_test_source_build:
description: Run source-build test job
type: boolean
required: true
default: false
permissions:
contents: read
jobs:
cargo-check:
name: cargo check (host)
if: github.event_name != 'workflow_dispatch' || inputs.run_cargo_check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo check --workspace --all-targets
test-prebuilt:
name: cargo test (prebuilt, bare metal)
if: github.event_name != 'workflow_dispatch' || inputs.run_test_prebuilt
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# `cargo xtask zephyr-setup --prebuilt` only needs to download
# tarballs into external/, so the nrf submodule is not required.
with:
submodules: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install BabbleSim runtime deps
# libglib2.0-0 -> bs_2G4_phy_v1 links against glib at runtime
# socat -> spawn_zephyr_rpc_server_with_socat bridges PTY <-> Unix socket
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends libglib2.0-0 socat
- name: cargo xtask zephyr-setup --prebuilt
run: cargo xtask zephyr-setup --prebuilt
- name: cargo test --workspace --lib
run: cargo test --workspace --lib
- name: cargo test --test integration_test
# BabbleSim spawns real processes per test under /tmp/bs_<user>/;
# serialize to avoid sim_id collisions.
run: cargo test --test integration_test -- --test-threads=1
test-source-build:
name: cargo test (source build, devcontainer)
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.run_test_source_build)
runs-on: ubuntu-latest
steps:
- name: Free up disk space
run: |
sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/share/boost "$AGENT_TOOLSDIRECTORY"
docker system prune -af --volumes || true
df -h
- name: Add 8 GB of swap (Zephyr build can OOM otherwise)
run: |
sudo swapoff /swapfile 2>/dev/null || true
sudo rm -f /swapfile
sudo fallocate -l 8G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
free -h
- name: Checkout repository
# Source build needs the nrf submodule for west to resolve manifests.
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust toolchain (host, for `cargo xtask docker-build`)
uses: dtolnay/rust-toolchain@stable
- name: cargo xtask docker-build
run: cargo xtask docker-build
- name: Chown workspace to container UID 1000
run: sudo chown -R 1000:1000 "$GITHUB_WORKSPACE"
- name: cargo xtask zephyr-setup --build-from-source && cargo test
run: |
docker run --rm \
--platform linux/amd64 \
--memory=6g \
--memory-swap=14g \
-v "$GITHUB_WORKSPACE:/workspace" \
-w /workspace \
-e CARGO_HOME=/tmp/cargo \
-e CARGO_TARGET_DIR=/tmp/target \
nrf-sim-bridge:latest \
bash -lc '
set -euo pipefail
echo "=== cargo xtask zephyr-setup --build-from-source ==="
cargo xtask zephyr-setup --build-from-source
echo "=== cargo test --workspace --lib ==="
cargo test --workspace --lib
echo "=== cargo test --test integration_test ==="
cargo test --test integration_test -- --test-threads=1
'
- name: Restore workspace permissions for runner
if: always()
run: sudo chown -R runner:runner "$GITHUB_WORKSPACE"