-
Notifications
You must be signed in to change notification settings - Fork 20
205 lines (165 loc) · 5.99 KB
/
main.yml
File metadata and controls
205 lines (165 loc) · 5.99 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
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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
# Something seems to be setting this in the default GHA runners, which breaks bcvk
# as the default runner user doesn't have access
LIBVIRT_DEFAULT_URI: "qemu:///session"
jobs:
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Check build
run: cargo check --all-targets
- name: Run unit tests
run: cargo test --lib
build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup bootc Ubuntu environment
uses: bootc-dev/actions/bootc-ubuntu-setup@main
with:
libvirt: 'true'
- name: Install additional dependencies
run: sudo apt install -y go-md2man
- name: Extract image lists from Justfile
run: |
echo "PRIMARY_IMAGE=$(just --evaluate PRIMARY_IMAGE)" >> $GITHUB_ENV
echo "ALL_BASE_IMAGES=$(just --evaluate ALL_BASE_IMAGES)" >> $GITHUB_ENV
- name: Setup Rust
uses: bootc-dev/actions/setup-rust@main
- name: Build
run: just validate && just build
- name: Run unit tests
run: just unit
- name: Pull test images
run: just pull-test-images
- name: Create nextest archive
run: |
cargo nextest archive --release -p integration-tests --archive-file nextest-archive.tar.zst
env:
BCVK_PATH: ${{ github.workspace }}/target/release/bcvk
BCVK_PRIMARY_IMAGE: ${{ env.PRIMARY_IMAGE }}
BCVK_ALL_IMAGES: ${{ env.ALL_BASE_IMAGES }}
- name: Upload nextest archive
uses: actions/upload-artifact@v4
with:
name: nextest-archive
path: nextest-archive.tar.zst
retention-days: 7
- name: Upload bcvk binary for tests
uses: actions/upload-artifact@v4
with:
name: bcvk-binary-tests
path: target/release/bcvk
retention-days: 7
- name: Create bcvk archive
run: just archive
- name: Upload bcvk binary artifacts
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: bcvk-binary
path: |
target/bcvk-*.tar.gz
target/bcvk-*.tar.gz.sha256
retention-days: 7
publish-binary:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: read
packages: write
steps:
- name: Install ORAS CLI
run: |
# renovate: datasource=github-releases depName=oras-project/oras
VERSION=1.2.2
curl -LO https://github.com/oras-project/oras/releases/download/v${VERSION}/oras_${VERSION}_linux_amd64.tar.gz
tar -xzf oras_${VERSION}_linux_amd64.tar.gz
sudo mv oras /usr/local/bin/
- name: Download bcvk binary artifacts
uses: actions/download-artifact@v4
with:
name: bcvk-binary
- name: Login to GitHub Container Registry
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | oras login ghcr.io --username ${{ github.repository_owner }} --password-stdin
- name: Push binary as OCI artifact
run: |
for file in bcvk-*.tar.gz; do
ARCH=$(echo "$file" | sed 's/bcvk-\(.*\)-unknown-linux-gnu\.tar\.gz/\1/')
oras push "ghcr.io/bootc-dev/bcvk-binary:${ARCH}-latest" "$file:application/gzip" "${file}.sha256:text/plain"
done
integration-tests:
runs-on: ubuntu-24.04
needs: build
strategy:
fail-fast: false
matrix:
partition: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v4
- uses: bootc-dev/actions/bootc-ubuntu-setup@main
with:
libvirt: 'true'
- name: Extract image lists from Justfile
run: |
echo "PRIMARY_IMAGE=$(just --evaluate PRIMARY_IMAGE)" >> $GITHUB_ENV
echo "ALL_BASE_IMAGES=$(just --evaluate ALL_BASE_IMAGES)" >> $GITHUB_ENV
- name: Setup Rust
uses: bootc-dev/actions/setup-rust@main
- name: Pull test images
run: just pull-test-images
- name: Download nextest archive
uses: actions/download-artifact@v4
with:
name: nextest-archive
- name: Download bcvk binary
uses: actions/download-artifact@v4
with:
name: bcvk-binary-tests
path: target/release
- name: Make bcvk executable
run: chmod +x target/release/bcvk
- name: Run integration tests (partition ${{ matrix.partition }}/4)
run: |
# Clean up any leftover containers before starting
cargo run --release --bin test-cleanup -p integration-tests 2>/dev/null || true
# Run the partitioned tests
cargo nextest run --archive-file nextest-archive.tar.zst \
--profile integration \
--partition hash:${{ matrix.partition }}/4
# Clean up containers after tests complete
cargo run --release --bin test-cleanup -p integration-tests 2>/dev/null || true
env:
BCVK_PATH: ${{ github.workspace }}/target/release/bcvk
BCVK_PRIMARY_IMAGE: ${{ env.PRIMARY_IMAGE }}
BCVK_ALL_IMAGES: ${{ env.ALL_BASE_IMAGES }}
- name: Upload junit XML
if: always()
uses: actions/upload-artifact@v4
with:
name: integration-junit-xml-${{ matrix.partition }}
path: target/nextest/integration/junit.xml
retention-days: 7
# Sentinel job for required checks - configure this job name in repository settings
required-checks:
if: always()
needs: [build-macos, build, integration-tests]
runs-on: ubuntu-latest
steps:
- run: exit 1
if: >-
needs.build-macos.result != 'success' ||
needs.build.result != 'success' ||
needs.integration-tests.result != 'success'