-
Notifications
You must be signed in to change notification settings - Fork 2
162 lines (146 loc) · 5.65 KB
/
ci.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
name: CI
on:
pull_request:
push:
branches:
- main
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build_and_test_nix:
name: Build and test
timeout-minutes: 30
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
name: [ubuntu-latest, macOS-arm-latest]
rust: [stable]
include:
- name: ubuntu-latest
os: ubuntu-latest
release-os: linux
release-arch: amd64
runner: [self-hosted, linux, X64]
- name: macOS-arm-latest
os: macOS-latest
release-os: darwin
release-arch: aarch64
runner: [self-hosted, macOS, ARM64]
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install ${{ matrix.rust }} rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: install cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: nextest
- name: run tests
run: |
cargo nextest run --all-features --lib --bins --tests --no-fail-fast
env:
RUST_LOG: "TRACE"
- name: build
run: |
cargo build --release
cargo run --features headers --bin generate_headers --release
cc -o main{,.c} -L target/release -l iroh_net_ffi -lSystem -lc -lm
- name: test run
run: |
./main server --json > server_output.json &
# Wait for the server to start
sleep 2
# Read the second line of the file
line=$(sed -n '2p' server_output.json)
# Check if the line is empty
if [[ -z "$line" ]]; then
echo "Error: server_output.json does not have at least 2 lines"
exit 1
fi
# Parse the JSON
json_output=$(echo $line | jq .)
# Store variables
node_id=$(echo $json_output | jq -r '.node_id')
derp=$(echo $json_output | jq -r '.derp')
addrs=$(echo $json_output | jq -r '.addrs[]')
./main client $node_id $derp ${addrs[@]}
sleep 1
# Read the last line of the file
last_line=$(tail -n 1 server_output.json)
# Parse the JSON
json_output=$(echo $last_line | jq -r '.data')
# Ensure json_output is as expected
if [[ "$json_output" != "hello world from C" ]]; then
echo "Error: Unexpected output"
exit 1
fi
echo "Success"
- name: check headers
run: |
cp irohnet.h irohnet.h.orig
./target/release/generate_headers
diff_output=$(diff irohnet.h irohnet.h.orig)
# Check if the diff_output is not empty
if [[ -n "$diff_output" ]]; then
echo "Error: Differences were found compared to the checked in headers"
exit 1
fi
env:
CARGO_CRATE_NAME: iroh-net-ffi
cargo_deny:
timeout-minutes: 30
name: cargo deny
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1
with:
arguments: --all-features
command: check
command-arguments: "-Dwarnings"
check_fmt_and_docs:
timeout-minutes: 30
name: Checking fmt and docs
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: "sccache"
SCCACHE_GHA_ENABLED: "on"
steps:
- uses: actions/checkout@master
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Install sccache
uses: mozilla-actions/[email protected]
- name: fmt
run: cargo fmt --all -- --check
- name: Docs
run: cargo doc --workspace --all-features --no-deps --document-private-items
clippy_check:
timeout-minutes: 30
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: "sccache"
SCCACHE_GHA_ENABLED: "on"
steps:
- uses: actions/checkout@master
# Can be switched back to stable once 1.75 lands
# https://github.com/rust-lang/cargo/issues/12115#issuecomment-1768170381
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2023-12-06
components: clippy
- name: Install sccache
uses: mozilla-actions/[email protected]
# TODO: We have a bunch of platform-dependent code so should
# probably run this job on the full platform matrix
- name: clippy check (all features)
run: cargo clippy --workspace --all-features --all-targets --bins --tests --benches
- name: clippy check (no features)
run: cargo clippy --workspace --no-default-features --lib --bins --tests
- name: clippy check (default features)
run: cargo clippy --workspace --all-targets