-
Notifications
You must be signed in to change notification settings - Fork 5
206 lines (175 loc) · 6.25 KB
/
tests_and_checks.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
name: 🧪 Tests and Checks
on:
push:
branches: [ main ]
pull_request:
branches: [ '**' ]
workflow_dispatch:
inputs:
force_build_libkrun:
description: 'Force build libkrun'
required: false
type: boolean
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-libkrun-changes:
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check_files.outputs.should_build }}
libkrun_hash: ${{ steps.hash_libkrun.outputs.hash }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check if relevant files have changed
id: check_files
run: |
if [ $(git rev-list --count HEAD) -lt 2 ]; then
echo "Only one commit in the repository, building libkrun"
echo "should_build=true" >> $GITHUB_OUTPUT
else
git diff --name-only HEAD^ HEAD | grep -q 'build_libkrun.sh' && echo "should_build=true" >> $GITHUB_OUTPUT || echo "should_build=false" >> $GITHUB_OUTPUT
fi
- name: Hash build_libkrun.sh
id: hash_libkrun
run: echo "hash=$(sha256sum build_libkrun.sh | awk '{ print $1 }')" >> $GITHUB_OUTPUT
build-libkrun:
needs: check-libkrun-changes
if: needs.check-libkrun-changes.outputs.should_build == 'true' || github.event.inputs.force_build_libkrun == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update -qqy
sudo apt-get install -y jq libelf-dev build-essential flex bison libssl-dev libncurses5-dev python3-pip
pip3 install --user pyelftools
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Build libkrun
run: |
./build_libkrun.sh --no-cleanup --force-build
- name: Cache libkrun
uses: actions/cache/save@v4
with:
path: |
build/libkrunfw/libkrunfw*.so*
build/libkrun/target/release/libkrun*.so*
key: ${{ runner.os }}-libkrun-${{ needs.check-libkrun-changes.outputs.libkrun_hash }}
run-checks:
needs: [check-libkrun-changes, build-libkrun]
if: always()
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust-toolchain:
- stable
- nightly
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Cache Project
uses: Swatinem/rust-cache@v2
- name: Restore libkrun cache
uses: actions/cache/restore@v4
with:
path: |
build/libkrunfw/libkrunfw*.so*
build/libkrun/target/release/libkrun*.so*
key: ${{ runner.os }}-libkrun-${{ needs.check-libkrun-changes.outputs.libkrun_hash }}
- name: Install Rust Toolchain
uses: actions-rs/toolchain@v1
with:
override: true
components: rustfmt, clippy
toolchain: ${{ matrix.rust-toolchain }}
- name: Check Format
uses: actions-rs/cargo@v1
with:
args: --all -- --check
command: fmt
toolchain: ${{ matrix.rust-toolchain }}
- name: Run Linter
uses: actions-rs/cargo@v1
with:
args: --all -- -D warnings
command: clippy
toolchain: ${{ matrix.rust-toolchain }}
- name: Check Advisories
if: ${{ matrix.rust-toolchain == 'stable' }}
uses: EmbarkStudios/cargo-deny-action@v2
with:
command: check advisories
continue-on-error: true
- name: Check Bans, Licenses, and Sources
if: ${{ matrix.rust-toolchain == 'stable' }}
uses: EmbarkStudios/cargo-deny-action@v2
with:
command: check bans licenses sources
- name: Test Release
if: ${{ matrix.rust-toolchain == 'stable' && github.event_name == 'push' }}
run: |
LIBRARY_PATH=${{ github.workspace }}/build/libkrunfw:${{ github.workspace }}/build/libkrun/target/release:${{ env.LIBRARY_PATH }} \
LD_LIBRARY_PATH=${{ github.workspace }}/build/libkrunfw:${{ github.workspace }}/build/libkrun/target/release:${{ env.LD_LIBRARY_PATH }} \
cargo build --release
run-tests:
needs: [check-libkrun-changes, build-libkrun]
if: always()
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust-toolchain:
- stable
- nightly
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Environment Packages
run: |
sudo apt-get update -qqy
sudo apt-get install jq
- name: Cache Project
uses: Swatinem/rust-cache@v2
- name: Restore libkrun cache
uses: actions/cache/restore@v4
with:
path: |
build/libkrunfw/libkrunfw*.so*
build/libkrun/target/release/libkrun*.so*
key: ${{ runner.os }}-libkrun-${{ needs.check-libkrun-changes.outputs.libkrun_hash }}
- name: Print Cache
run: tree -L 2 build/
- name: Install Rust Toolchain
uses: actions-rs/toolchain@v1
with:
override: true
toolchain: ${{ matrix.rust-toolchain }}
# >>>> DEBUG START >>>>>
- name: Check SONAME
run: |
cd ${{ github.workspace }}/build/libkrunfw
objdump -p libkrunfw.so.4.4.2 | grep SONAME
- name: Create symlinks
run: |
cd ${{ github.workspace }}/build/libkrunfw
ln -sf libkrunfw.so.4.4.2 libkrunfw.so.4
ln -sf libkrunfw.so.4 libkrunfw.so
- name: Check libkrun.so dependencies
run: |
ldd ${{ github.workspace }}/build/libkrun/target/release/libkrun.so | grep libkrunfw
# <<<< DEBUG END <<<<
- name: Run Tests
run: |
LIBRARY_PATH=${{ github.workspace }}/build/libkrunfw:${{ github.workspace }}/build/libkrun/target/release:${{ env.LIBRARY_PATH }} \
LD_LIBRARY_PATH=${{ github.workspace }}/build/libkrunfw:${{ github.workspace }}/build/libkrun/target/release:${{ env.LD_LIBRARY_PATH }} \
cargo test --all-features