-
Notifications
You must be signed in to change notification settings - Fork 223
138 lines (133 loc) · 6.07 KB
/
debian.yml
File metadata and controls
138 lines (133 loc) · 6.07 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
# This action originally modeled off of the Debian build action:
# https://salsa.debian.org/wouter/ola/-/blob/a38a396f6994b2b1af8efec9e208aee4e67f77aa/.gitlab-ci.yml
name: debian
on: [push, pull_request]
permissions:
contents: read
jobs:
debian-build:
name: 'Debian Build ${{ matrix.image_tag }} ${{ matrix.architecture }}'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image_tag: [bullseye, bookworm, trixie, forky, sid]
architecture: [amd64]
container: debian:${{ matrix.image_tag }}
steps:
- name: Get number of CPU cores
run: echo "NUM_CPU_CORES=$(grep -c processor /proc/cpuinfo)" >> $GITHUB_OUTPUT
id: num-cpu-cores
- name: Update package database
run: apt-get update -y
# See comments beginning at
# https://github.com/actions/runner/issues/763#issuecomment-1435474884
# Without Git, actions/checkout@v4 will resort to REST and will not
# create a .git folder or .git.config. The Problem Matcher looks for
# .git/config to find where the root of the repo is, so it must be
# present.
- name: Install Git and lsb-release
run: apt-get -y install git lsb-release
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all tags for generating OLA_BUILD_NAME
persist-credentials: false
- name: Generate build name
shell: bash
run: |
chown root:root . # workaround Git security precaution, see https://github.com/actions/runner-images/issues/6775
export OLA_BUILD_NAME=$(./scripts/build_name.sh)
# No docker number tag for testing, so must use lsb_release
export OLA_DEBIAN_BUILD_VERSION=$(./scripts/build_name.sh --debian)
echo "OLA_BUILD_NAME=$OLA_BUILD_NAME" >> $GITHUB_OUTPUT
echo "OLA_BUILD_NAME=$OLA_BUILD_NAME" >> $GITHUB_ENV # Set build name globally so that modifications don't cause -dirty
echo "OLA_DEBIAN_BUILD_VERSION=$OLA_DEBIAN_BUILD_VERSION" >> $GITHUB_OUTPUT
echo "Build name: $OLA_BUILD_NAME"
echo "Debian Build Version: $OLA_DEBIAN_BUILD_VERSION"
id: generate-build-name
- name: Install build tools
run: apt-get -y install devscripts adduser fakeroot sudo equivs
- name: Create Debian version for build
shell: bash
run: |
DEBFULLNAME="GitHub Actions" DEBEMAIL=actions@github.com \
debchange --force-bad-version \
--newversion ${{ steps.generate-build-name.outputs.OLA_DEBIAN_BUILD_VERSION }} \
"GitHub Actions Build \
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
- name: Install build dependencies
run: mk-build-deps -t "apt-get -y -o Debug::pkgProblemResolver=yes --no-install-recommends" -i -r
- name: Set up build user
run: |
adduser --disabled-password --gecos "" builduser
chown -R builduser:builduser .
chown builduser:builduser ..
- name: Build
run: sudo -u builduser env "OLA_BUILD_NAME=$OLA_BUILD_NAME" dpkg-buildpackage -v${{ steps.generate-build-name.outputs.OLA_DEBIAN_BUILD_VERSION }} -b -rfakeroot -j${{ steps.num-cpu-cores.outputs.NUM_CPU_CORES }}
- name: Move built files
if: always()
run: |
mkdir built
dcmd mv ../*ges built/
- name: Display structure of built files
if: always()
run: ls -alR
working-directory: built
- name: SHA256 built files
if: always()
shell: bash
run: find . -type f -exec sha256sum {} \;
working-directory: built
- uses: actions/upload-artifact@v4
if: always()
with:
name: ola-built-debian-${{ matrix.image_tag }}-${{ steps.generate-build-name.outputs.OLA_DEBIAN_BUILD_VERSION }}_${{ matrix.architecture }}
path: ./built
debian-test:
name: 'Debian Test ${{ matrix.image_tag }} ${{ matrix.architecture }}'
needs: debian-build
if: "always()" # Run if some builds fail but ensure they all complete first
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image_tag: [bullseye, bookworm, trixie, forky, sid]
architecture: [amd64]
container: debian:${{ matrix.image_tag }}
steps:
- name: Update package database
run: apt-get update -y
- name: Install Git and lsb-release
run: apt-get -y install git lsb-release
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all tags for generating OLA_DEBIAN_BUILD_VERSION
persist-credentials: false
- name: Generate build name # Job step outputs can't be passed between builds for matrix jobs, so we re-generate
shell: bash
run: |
chown root:root . # workaround Git security precaution, see https://github.com/actions/runner-images/issues/6775
# No docker number tag for testing, so must use lsb_release
export OLA_DEBIAN_BUILD_VERSION=$(./scripts/build_name.sh --debian)
echo "OLA_DEBIAN_BUILD_VERSION=$OLA_DEBIAN_BUILD_VERSION" >> $GITHUB_OUTPUT
echo "Debian Build Version: $OLA_DEBIAN_BUILD_VERSION"
id: generate-build-name
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: ola-built-debian-${{ matrix.image_tag }}-${{ steps.generate-build-name.outputs.OLA_DEBIAN_BUILD_VERSION }}_${{ matrix.architecture }}
path: built
- name: Display structure of artifact files
run: ls -alR
working-directory: built
- name: Update package database
run: apt-get update -y
- name: Install test tools
run: apt-get -y install autopkgtest
- name: Test
run: autopkgtest --output-dir=test-output built/*ges -- null
- uses: actions/upload-artifact@v4
if: always() # Always upload the test output, even on failed tests
with:
name: ola-test-output-debian-${{ matrix.image_tag }}-${{ steps.generate-build-name.outputs.OLA_DEBIAN_BUILD_VERSION }}_${{ matrix.architecture }}
path: test-output