forked from fdo-rs/fido-device-onboard-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
201 lines (189 loc) · 7.15 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
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
on:
push:
branches:
- main
pull_request:
name: Continuous integration
jobs:
docs:
name: Test docs building
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/jekyll-build-pages@main
with:
source: ./docs
verbose: true
containers:
name: Build containers
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build containers
uses: ./.github/actions/build_containers
check-spelling:
name: Check spelling
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check spelling
uses: codespell-project/actions-codespell@master
with:
builtin: clear,rare,usage,code,en-GB_to_en-US
check_filenames: true
check_hidden: true
ignore_words_file: .github/spellcheck-ignore
skip: "./docs/Gemfile.lock,./docs/_config.yml,./.github,./.git,./vendor"
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- run: cargo fmt --all -- --check
gofmt:
name: Gofmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: if [ "$(gofmt -d -s -l . | tee /dev/stderr | wc -l)" -gt 0 ]; then exit 1; fi
clippy:
name: Clippy
runs-on: ubuntu-latest
container: fedora:latest
steps:
- uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
- name: Install deps
run: |
dnf install -y make gcc openssl openssl-devel findutils golang git tpm2-tss-devel clevis cryptsetup-devel clang-devel
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
- run: cargo clippy -- -D warnings -D clippy::panic -D clippy::todo
build_and_test:
runs-on: ubuntu-latest
container: fedora:latest
steps:
- name: Install deps
run: |
dnf install -y make gcc openssl openssl-devel findutils golang git tpm2-tss-devel swtpm swtpm-tools git clevis clevis-luks cryptsetup cryptsetup-devel clang-devel cracklib-dicts sqlite sqlite-devel libpq libpq-devel
- uses: actions/checkout@v3
with:
persist-credentials: false
- name: Fix git trust
run: git config --global --add safe.directory /__w/fido-device-onboard-rs/fido-device-onboard-rs
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Build
run: cargo build --workspace
- name: Run tests
env:
FDO_PRIVILEGED: true
PER_DEVICE_SERVICEINFO: false
SQLITE_MANUFACTURER_DATABASE_URL: ../ci-manufacturer-db.sqlite
SQLITE_OWNER_DATABASE_URL: ../ci-owner-db.sqlite
SQLITE_RENDEZVOUS_DATABASE_URL: ../ci-rendezvous-db.sqlite
run: |
# prep for database tests
cargo install --force diesel_cli --no-default-features --features sqlite
diesel migration run --migration-dir ./migrations/migrations_manufacturing_server_sqlite --database-url ./ci-manufacturer-db.sqlite
diesel migration run --migration-dir ./migrations/migrations_owner_onboarding_server_sqlite --database-url ./ci-owner-db.sqlite
diesel migration run --migration-dir ./migrations/migrations_rendezvous_server_sqlite --database-url ./ci-rendezvous-db.sqlite
# run tests
cargo test --workspace
# delete sqlite databases
rm -f ./ci-manufacturer-db.sqlite ./ci-owner-db.sqlite ./ci-rendezvous-db.sqlite
- name: Check aio
run: |
mkdir aio-dir/
./target/debug/fdo-admin-tool aio --directory aio-dir/ &
AIO_PID=$!
sleep 5
if [ -d /proc/$AIO_PID ]; then rm -rf aio-dir; else exit 1; fi
# This is primarily to ensure that changes to fdo_data.h are committed,
# which is critical for determining whether any stability changes were made
# during the PR review.
- name: Ensure building did not change any code
run: |
git diff --exit-code
postgres_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Run test
run: test/fdo-postgres.sh
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 'latest'
- name: Install commitlint dependencies
run: npm install commitlint
- uses: wagoid/commitlint-github-action@v5
env:
NODE_PATH: ${{ github.workspace }}/node_modules
with:
configFile: .github/commitlint.config.js
failOnWarnings: true
manpages:
name: Test man page generation
runs-on: ubuntu-latest
container: fedora:latest
steps:
- uses: actions/checkout@v3
- name: install deps
run: |
dnf install -y make python3-docutils
- name: generate man pages
run: make man
devcontainer_test:
name: Test Devcontainer Creation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install devcontainer CLI
run: npm install -g @vscode/dev-container-cli
- name: Build devcontainer
run: devcontainer build --image-name devcontainer-fdo-rs .
- name: Test building in devcontainer
run: docker run --rm -v `pwd`:/code:z --workdir /code --user root devcontainer-fdo-rs cargo build --workspace --verbose
- name: Test testing in devcontainer
run: |
docker run -d -v `pwd`:/code:z --workdir /code --user root -e SQLITE_MANUFACTURER_DATABASE_URL='../ci-manufacturer-db.sqlite' -e SQLITE_OWNER_DATABASE_URL='../ci-owner-db.sqlite' -e SQLITE_RENDEZVOUS_DATABASE_URL='../ci-rendezvous-db.sqlite' --name tests devcontainer-fdo-rs sleep infinity
docker exec --user root tests cargo build --lib --bins --workspace --verbose
docker exec --user root tests diesel migration run --migration-dir ./migrations/migrations_manufacturing_server_sqlite --database-url ./ci-manufacturer-db.sqlite
docker exec --user root tests diesel migration run --migration-dir ./migrations/migrations_owner_onboarding_server_sqlite --database-url ./ci-owner-db.sqlite
docker exec --user root tests diesel migration run --migration-dir ./migrations/migrations_rendezvous_server_sqlite --database-url ./ci-rendezvous-db.sqlite
docker exec --user root tests cargo test -- --ignored
docker stop tests
docker rm tests