-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (136 loc) · 4.65 KB
/
build-test.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: Build and test
on:
push:
schedule:
- cron: "0 0 7 * *"
jobs:
ubuntu:
runs-on: ubuntu-22.04
container:
image: ubuntu:22.04
env:
ARCH: ubuntu2204
UNPRIVILEGED: ubuntu
TEST_OUTPUT_DIR: /tmp/tests
WORKDIR: /tmp/workdir
steps:
- name: Install minimal dependencies
run: |
apt-get update
apt-get install -y --no-install-recommends git sudo gettext-base ca-certificates
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create an unprivileged user
run: |
useradd -m $UNPRIVILEGED
chown -R $UNPRIVILEGED:$UNPRIVILEGED .
echo "$UNPRIVILEGED ALL = NOPASSWD: $(which apt-get)" | tee -a /etc/sudoers
- name: Build package
run: sudo -u $UNPRIVILEGED --preserve-env=WORKDIR env SUDO=sudo build/ubuntu/mk
- name: Archive source package
uses: actions/upload-artifact@v4
with:
name: source-package.${{github.sha}}.${{env.ARCH}}
retention-days: 7
path: build/ubuntu/out/*.tar
- name: Install package
run: apt-get install -y ./build/ubuntu/out/*.deb
- name: Test system installation
run: |
export TOOLS=$(readlink -f "$WORKDIR"/*/tools)
run() {
sudo -u $UNPRIVILEGED --preserve-env=TEST_OUTPUT_DIR,TOOLS \
env SUT=$(which $1) SHOW_IDS=1 \
tools/test-harness -c $1
}
run hlua
run hpython
run hnode
run hsh
- name: Archive test results
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: tests.${{github.sha}}.${{env.ARCH}}
retention-days: 7
path: "${{env.TEST_OUTPUT_DIR}}/*-tests-*.tar.gz"
archlinux:
runs-on: ubuntu-22.04
container:
image: archlinux:latest
env:
ARCH: archlinux
UNPRIVILEGED: arch
TEST_OUTPUT_DIR: /tmp/tests
steps:
- name: Install minimal dependencies
run: pacman -Suy --noconfirm sudo fakeroot binutils which wget git diffutils
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create an unprivileged user
run: |
useradd -m $UNPRIVILEGED
chown -R $UNPRIVILEGED:$UNPRIVILEGED .
tee -a /etc/sudoers.d/$UNPRIVILEGED <<< "$UNPRIVILEGED ALL = NOPASSWD: $(which pacman)"
- name: Generate nodejs-shared's PKGBUILD
id: nodejs_shared_pkgbuild
run: |
PKG=$(build/archlinux/nodejs-shared/PKGBUILD.gen)
echo "pkg=$PKG" >> "$GITHUB_OUTPUT"
- name: Archive nodejs-shared's PKGBUILD
uses: actions/upload-artifact@v4
with:
name: nodejs-shared.PKGBUILD
retention-days: 7
path: "build/archlinux/nodejs-shared/PKGBUILD.shared"
- name: Restore nodejs-shared package
id: nodejs_shared_cache
uses: actions/cache/restore@v4
with:
path: build/archlinux/nodejs-shared/${{ steps.nodejs_shared_pkgbuild.outputs.pkg }}
key: ${{ steps.nodejs_shared_pkgbuild.outputs.pkg }}
- name: Build nodejs-shared
if: steps.nodejs_shared_cache.outputs.cache-hit != 'true'
run: sudo -u $UNPRIVILEGED build/archlinux/nodejs-shared/build
- name: Cache nodejs-shared package
if: steps.nodejs_shared_cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: build/archlinux/nodejs-shared/${{ steps.nodejs_shared_pkgbuild.outputs.pkg }}
key: ${{ steps.nodejs_shared_pkgbuild.outputs.pkg }}
- name: Install nodejs-shared
run: pacman -U --noconfirm build/archlinux/nodejs-shared/${{ steps.nodejs_shared_pkgbuild.outputs.pkg }}
- name: Create PKGBUILD
run: sudo -u $UNPRIVILEGED build/archlinux/mk
- name: Archive PKGBUILD
uses: actions/upload-artifact@v4
with:
name: PKGBUILD.${{github.sha}}
retention-days: 7
path: "build/archlinux/PKGBUILD"
- name: Build package
run: sudo -u $UNPRIVILEGED makepkg -si --noconfirm
working-directory: build/archlinux
- name: Test system installation
run: |
export TOOLS=$(readlink -f build/archlinux/src/*/tools)
run() {
sudo -u $UNPRIVILEGED --preserve-env=TEST_OUTPUT_DIR,TOOLS \
env SUT=$(which $1) SHOW_IDS=1 \
tools/test-harness -c $1
}
run hlua
run hpython
run hnode
run hsh
- name: Archive test results
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: tests.${{github.sha}}.${{env.ARCH}}
retention-days: 7
path: "${{env.TEST_OUTPUT_DIR}}/*-tests-*.tar.gz"