-
Notifications
You must be signed in to change notification settings - Fork 5
225 lines (196 loc) · 7.79 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# 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-cache-changes:
# runs-on: ubuntu-latest
# outputs:
# should_build: ${{ steps.check_build.outputs.should_build }}
# libkrun_hash: ${{ steps.hash_libkrun.outputs.hash }}
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 2
# - name: Hash build_libkrun.sh
# id: hash_libkrun
# run: |
# HASH=$(sha256sum build_libkrun.sh | awk '{ print $1 }')
# echo "hash=$HASH" >> $GITHUB_OUTPUT
# echo "Calculated hash: $HASH"
# - name: Check if cache exists
# id: check_cache
# uses: actions/cache/restore@v4
# with:
# path: |
# build/libkrunfw/libkrunfw*.so*
# build/libkrun/target/release/libkrun*.so*
# key: ${{ runner.os }}-libkrun-${{ steps.hash_libkrun.outputs.hash }}
# - name: Check if build is needed
# id: check_build
# run: |
# if [ "${{ steps.check_cache.outputs.cache-hit }}" == 'true' ]; then
# echo "Cache hit, no need to build"
# echo "should_build=false" >> $GITHUB_OUTPUT
# elif [ $(git rev-list --count HEAD) -lt 2 ]; then
# echo "Only one commit in the repository, building libkrun"
# echo "should_build=true" >> $GITHUB_OUTPUT
# elif git diff --name-only HEAD^ HEAD | grep -qE 'build_libkrun.sh|.github/workflows/tests_and_checks.yml'; then
# echo "build_libkrun.sh or workflow file has changed, building libkrun"
# echo "should_build=true" >> $GITHUB_OUTPUT
# else
# echo "No relevant changes, no need to build"
# echo "should_build=false" >> $GITHUB_OUTPUT
# fi
# build-libkrun:
# needs: check-libkrun-cache-changes
# if: needs.check-libkrun-cache-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-cache-changes.outputs.libkrun_hash }}
# run-checks:
# needs: [check-libkrun-cache-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-cache-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
# # A hack to make `ld` find the libkrunfw because right now it seems to only look for libkrunfw.so.x
# # and not libkrunfw.so or libkrunfw.so.x.x.x even though their SONAME is libkrunfw.so.x
# - name: Create symlinks
# run: |
# cd build/libkrunfw
# objdump -p libkrunfw.so.4.4.2 | grep SONAME # sanity check
# ln -sf libkrunfw.so.4.4.2 libkrunfw.so.4
# ln -sf libkrunfw.so.4 libkrunfw.so
# - 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-cache-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-cache-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 }}
# # A hack to make `ld` find the libkrunfw because right now it seems to only look for libkrunfw.so.x
# # and not libkrunfw.so or libkrunfw.so.x.x.x even though their SONAME is libkrunfw.so.x
# - name: Create symlinks
# run: |
# cd build/libkrunfw
# objdump -p libkrunfw.so.4.4.2 | grep SONAME # sanity check
# ln -sf libkrunfw.so.4.4.2 libkrunfw.so.4
# ln -sf libkrunfw.so.4 libkrunfw.so
# - name: Run Tests
# run: |
# sudo -E bash -c 'export LIBRARY_PATH=${{ github.workspace }}/build/libkrunfw:${{ github.workspace }}/build/libkrun/target/release && \
# export LD_LIBRARY_PATH=${{ github.workspace }}/build/libkrunfw:${{ github.workspace }}/build/libkrun/target/release && \
# /home/runner/.cargo/bin/cargo test && \
# /home/runner/.cargo/bin/cargo test -- --ignored'