-
Notifications
You must be signed in to change notification settings - Fork 2
138 lines (133 loc) · 4.69 KB
/
test_hwlib_debian_build.yaml
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
name: Test build hwlib Rust package with sbuild
on:
push:
branches: [ main ]
paths:
- client/**
- Cargo.*
- ".github/workflows/test_hwlib_debian_build.yaml"
pull_request:
branches: [ main ]
paths:
- client/**
- Cargo.*
- ".github/workflows/test_hwlib_debian_build.yaml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
validate-version:
runs-on: [self-hosted, linux, large, noble, x64]
defaults:
run:
working-directory: client
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Get version from git tag
id: get-version
run: |
VERSION=$(git describe --tags --match 'v*.*.*' --dirty)
if [[ $VERSION == *-dirty ]]; then
echo "Version includes -dirty. Ensure working tree is clean before building."
exit 1
fi
# Extract base version (strip 'v', commit count, and hash)
BASE_VERSION=$(echo "$VERSION" | sed -E 's/^v([0-9]+\.[0-9]+\.[0-9]+)(-.*)?$/\1/')
echo "version=$BASE_VERSION" >> $GITHUB_OUTPUT
echo "Git tag base version: $BASE_VERSION"
- name: Check hwlib and hwctl Cargo versions
run: |
echo "Using Git tag version: ${{ steps.get-version.outputs.version }}"
for manifest in hwlib/Cargo.toml hwctl/Cargo.toml; do
CARGO_VERSION=$(cargo metadata --manifest-path "$manifest" --no-deps --format-version 1 | jq -r '.packages[0].version')
if [[ $CARGO_VERSION != ${{ steps.get-version.outputs.version }} ]]; then
echo "Version mismatch in $manifest: $CARGO_VERSION (expected ${{ steps.get-version.outputs.version }})"
exit 1
fi
done
- name: Check Debian changelog version
run: |
echo "Using Git tag version: ${{ steps.get-version.outputs.version }}"
DEBIAN_VERSION=$(dpkg-parsechangelog --show-field Version | cut -d'~' -f1)
if [[ $DEBIAN_VERSION != ${{ steps.get-version.outputs.version }} ]]; then
echo "Debian changelog version mismatch: $DEBIAN_VERSION (expected ${{ steps.get-version.outputs.version }})"
exit 1
fi
build:
runs-on: [self-hosted, linux, large, noble, x64]
defaults:
run:
working-directory: client
needs: [validate-version]
steps:
- name: Checkout the repository
uses: actions/checkout@v4
# Prevent lxd-agent from getting restarted on apt upgrades.
# https://warthogs.atlassian.net/browse/ISD-2139
- name: Disable lxd-agent restart
run: |
mkdir -p /etc/needrestart/conf.d
echo '$nrconf{override_rc}{qr(^lxd-agent.service$)} = 0;' | sudo tee /etc/needrestart/conf.d/lxdagent.conf
- name: Download dependencies
run: |
set -xeu
sudo apt update
sudo DEBIAN_FRONTEND=noninteractive apt install -y \
debhelper \
devscripts \
sbuild \
schroot \
debootstrap \
jq \
mmdebstrap \
uidmap \
sbuild-debian-developer-setup \
dh-cargo \
pkg-config \
libssl-dev
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Vendor the dependencies
run: |
cargo install cargo-vendor-filterer
./debian/vendor-rust.sh
- name: Generate checksums
run: ./debian/generate_checksums.py
- run: dpkg-buildpackage -us -uc -S
- name: Setup sbuild and build the package
run: |
set -xeu
mkdir -p ~/.cache/sbuild
echo
mmdebstrap --variant=buildd --components=main,restricted,universe oracular ~/.cache/sbuild/oracular-amd64.tar.zst
echo "Running sbuild-debian-developer-setup"
sudo sbuild-debian-developer-setup
sudo sbuild-adduser $USER
newgrp sbuild
echo "Creating ~/.sbuildrc"
cat <<'EOF' >> ~/.sbuildrc
$chroot_mode = 'unshare';
$run_autopkgtest = 0;
$autopkgtest_root_args = '';
$autopkgtest_opts = [ '--apt-upgrade', '--', 'unshare', '--release', '%r', '--arch', '%a' ];
EOF
sudo sbuild-update -udcar u
schroot -l | grep sbuild
PACKAGE_DSC=$(find ../ -name "*.dsc" | head -n 1)
if [ -z "$PACKAGE_DSC" ]; then
echo "No .dsc file found"
exit 1
fi
echo "Running sbuild for $PACKAGE_DSC"
sbuild $PACKAGE_DSC -d oracular -v
- run: lintian --pedantic --verbose