-
-
Notifications
You must be signed in to change notification settings - Fork 25
250 lines (246 loc) · 9.75 KB
/
ci.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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
name: CADR CI
on:
workflow_dispatch:
push:
branches: [ master, bullseye ]
pull_request:
branches: [ master, bullseye ]
env:
USER_NAME: user
BUILD_DIR: /home/user/cadr-build
IMAGE_NAME: cadr/cadr
CONTAINER_NAME: cadr
CI_SCRIPT: ci/build.sh
PODMAN_CMD: "sudo -E XDG_RUNTIME_DIR= podman"
SPAWN_CONTAINER: "$PODMAN_CMD run --tmpfs /tmp --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro --privileged --systemd=true -d -v $PWD:$BUILD_DIR --name=$CONTAINER_NAME $IMAGE_NAME"
EXECUTE_CMD: "$PODMAN_CMD exec -u $USER_NAME -i $CONTAINER_NAME"
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
sources: ${{ steps.list-sources.outputs.sources }}
steps:
- uses: actions/checkout@v2
- name: Check CADR image cache
id: cache-cadr-image
uses: actions/cache@v3
env:
cache-name: cache-cadr-image
with:
path: CADR_image.tar
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Dockerfile', 'debcrafter-version', 'tests/data/microsoft_apt.list', 'tests/data/microsoft_key.gpg') }}
lookup-only: true
- name: Build CADR Running Environment Image
if: steps.cache-cadr-image.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get upgrade podman
$PODMAN_CMD build -t $IMAGE_NAME .
$PODMAN_CMD save $IMAGE_NAME > CADR_image.tar
- name: Install jq
run: sudo apt-get install -y jq
- name: List sources
id: list-sources
run: echo "::set-output name=sources::$(ls build_rules/*.yaml | grep -v remir | sed -e 's:^build_rules/::' -e 's/\.yaml$//' | jq -R -s -c 'split("\n")[:-1]')"
build:
needs: prepare
if: ${{ success() }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
source: ${{ fromJson(needs.prepare.outputs.sources) }}
steps:
- uses: actions/checkout@v2
- name: Fetch CADR image cache
id: cache-cadr-image
uses: actions/cache/restore@v3
env:
cache-name: cache-cadr-image
with:
path: CADR_image.tar
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Dockerfile', 'debcrafter-version', 'tests/data/microsoft_apt.list', 'tests/data/microsoft_key.gpg') }}
- name: Load Running Environment Image
run: |
$PODMAN_CMD load < CADR_image.tar
mkdir build
- name: Spawn Podman Container to Prepare Running Environment
run: |
eval $SPAWN_CONTAINER
- name: Get cache key
id: get-cache-key
run: |
eval $EXECUTE_CMD bash "${BUILD_DIR}/ci/get_cache_key.sh" "${{ matrix.source }}" >> $GITHUB_OUTPUT
- name: Fetch package cache
id: cache-packages
uses: actions/cache@v3
env:
cache-name: cache-packages
with:
path: packages
key: packages-${{ steps.get-cache-key.outputs.packages-cache-key }}
- name: Build packages
if: steps.cache-packages.outputs.cache-hit != 'true'
run: |
eval $EXECUTE_CMD bash "${BUILD_DIR}/$CI_SCRIPT" "${{ matrix.source }}"
sudo mkdir -p -m 777 packages
sudo mv -n build/*.deb packages
- name: Upload Debian Packages Just Built to Artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.source }}
path: packages
- name: Check SHA256
run: |
sudo chown -R $USER build
cd packages
for file in *.deb
do
sha256sum $file > ${file}.sha256sum
cat $file.sha256sum
done
# Yes, this downloading of the cache and then uploding artifact is silly. I didn't figure out how to do it better, feel free to send a PR!
- name: Upload SHA256 of Debian Packages Just Built to Artifact
uses: actions/upload-artifact@v2
with:
name: CADR_debs_sha256sum
path: packages/*.deb.sha256sum
- name: Fix the Dir Permission for Post checkout
run: |
sudo chown -R $USER $PWD
test:
needs: [build, prepare]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: ["bitcoind", "bitcoin-mainnet", "bitcoin-regtest",
"bitcoin-pruned-mainnet", "bitcoin-fullchain-mainnet", "bitcoin-fullchain-regtest",
"bitcoin-txindex-mainnet", "bitcoin-zmq-mainnet", "bitcoin-zmq-regtest",
"bitcoin-rpc-proxy", "bitcoin-rpc-proxy-mainnet", "bitcoin-rpc-proxy-regtest",
"bitcoin-timechain-mainnet", "electrs", "electrs-mainnet", "electrs-regtest",
"btcpayserver", "btcpayserver-system-mainnet", "btcpayserver-system-regtest",
"lnd", "lnd-system-mainnet", "lnd-system-regtest","lnd-unlocker-system-mainnet",
"lnd-unlocker-system-mainnet", "selfhost",
"selfhost-nginx", "selfhost-onion", "selfhost-clearnet",
"selfhost-clearnet-certbot", "tor-hs-patch-config", "thunderhub",
"thunderhub-system-mainnet", "thunderhub-system-regtest", "btc-rpc-explorer-mainnet",
"lndconnect", "selfhost-dashboard-bin", "selfhost-dashboard", "btc-transmuter",
"btc-transmuter-system-mainnet", "btc-transmuter-system-regtest"]
steps:
- uses: actions/checkout@v2
- name: Setup Test Prefix
run: |
echo "TEST_PREFIX=sudo chown -R $USER_NAME $BUILD_DIR && cd $BUILD_DIR && make BUILD_DIR=$BUILD_DIR/build" >> $GITHUB_ENV
- name: Prepare Podman Container Running Environment
run: |
sudo apt-get update
sudo apt-get upgrade podman
- name: Fetch CADR image cache
id: cache-cadr-image
uses: actions/cache/restore@v3
env:
cache-name: cache-cadr-image
with:
path: CADR_image.tar
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Dockerfile', 'debcrafter-version', 'tests/data/microsoft_apt.list', 'tests/data/microsoft_key.gpg') }}
- name: Load Running Environment Image
run: |
$PODMAN_CMD load < CADR_image.tar
mkdir build
- name: Download Pre-built Debian Packages
uses: thecodenebula/download-artifact@e9e49e9bbce8ff2b901957ee034714cab099644a
with:
#name: ${{ join(fromJson(needs.prepare.outputs.sources), '\n') }}
path: packages
- name: Test CADR Basic
run: |
mkdir -p build
mv packages/*/*.deb build/
eval $SPAWN_CONTAINER
eval $EXECUTE_CMD bash -c "\"$TEST_PREFIX test-here-basic-${{ matrix.package }}\""
$PODMAN_CMD rm -f $CONTAINER_NAME
- name: Test CADR Upgrade
run: |
eval $SPAWN_CONTAINER
eval $EXECUTE_CMD bash -c "\"$TEST_PREFIX SPLIT_STRATEGY=upgrade test-here-upgrade-${{ matrix.package }}\""
- name: Fix the Dir Permission for Post checkout
run: |
sudo chown -R $USER $PWD
test-multi-package:
needs: [build, prepare]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test: ["btcpayserver-regtest", "electrum"]
steps:
- uses: actions/checkout@v2
- name: Setup Test Prefix
run: |
echo "TEST_PREFIX=sudo chown -R $USER_NAME $BUILD_DIR && cd $BUILD_DIR && make BUILD_DIR=$BUILD_DIR/build" >> $GITHUB_ENV
- name: Prepare Podman Container Running Environment
run: |
sudo apt-get update
sudo apt-get upgrade podman
- name: Fetch CADR image cache
id: cache-cadr-image
uses: actions/cache/restore@v3
env:
cache-name: cache-cadr-image
with:
path: CADR_image.tar
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Dockerfile', 'debcrafter-version', 'tests/data/microsoft_apt.list', 'tests/data/microsoft_key.gpg') }}
- name: Load Running Environment Image
run: |
$PODMAN_CMD load < CADR_image.tar
mkdir build
- name: Download Pre-built Debian Packages
uses: thecodenebula/download-artifact@e9e49e9bbce8ff2b901957ee034714cab099644a
with:
#name: ${{ join(fromJson(needs.prepare.outputs.sources), '\n') }}
path: packages
- name: Test multi-package CADR integration
run: |
mkdir -p build
mv packages/*/*.deb build/
eval $SPAWN_CONTAINER
eval $EXECUTE_CMD bash -c "\"$TEST_PREFIX test-here-multi-package-${{ matrix.test }}\""
$PODMAN_CMD rm -f $CONTAINER_NAME
- name: Fix the Dir Permission for Post checkout
run: |
sudo chown -R $USER $PWD
info:
needs: [prepare]
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v2
- name: Setup Test Prefix
run: |
echo "TEST_PREFIX=sudo chown -R $USER_NAME $BUILD_DIR && cd $BUILD_DIR && make BUILD_DIR=$BUILD_DIR/build" >> $GITHUB_ENV
- name: Prepare Podman Container Running Environment
run: |
sudo apt-get update
sudo apt-get upgrade podman
- name: Fetch CADR image cache
id: cache-cadr-image
uses: actions/cache/restore@v3
env:
cache-name: cache-cadr-image
with:
path: CADR_image.tar
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Dockerfile', 'debcrafter-version', 'tests/data/microsoft_apt.list', 'tests/data/microsoft_key.gpg') }}
- name: Load Running Environment Image
run: |
$PODMAN_CMD load < CADR_image.tar
mkdir build
- name: Print packages
run: |
eval $SPAWN_CONTAINER
eval $EXECUTE_CMD bash -c "echo $USER"
$PODMAN_CMD rm -f $CONTAINER_NAME
- name: Fix the Dir Permission for Post checkout
run: |
sudo chown -R $USER $PWD