-
Notifications
You must be signed in to change notification settings - Fork 22
273 lines (245 loc) · 9.42 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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# Copyright 2020 Rainer Gerhards and Others
#
# https://github.com/rsyslog/rsyslog-pkg-ubuntu
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# References:
#
# https://help.github.com/en/github/managing-subscriptions-and-notifications-on-github/configuring-notifications#github-actions-notification-options
# https://github.com/settings/notifications
# https://software.opensuse.org//download.html?project=home%3Argerhards&package=rsyslog
---
name: CI PR runner
on:
pull_request:
jobs:
build:
runs-on: ubuntu-22.04
# Default: 360 minutes
timeout-minutes: 60
strategy:
# When set to true, cancel all in-progress jobs if any matrix job fails.
fail-fast: false
matrix:
release: [18.04, 20.04] # , 22.04]
steps:
- name: git checkout packging project
uses: actions/checkout@v1
- name: prep cache dir
run: mkdir ~/host
- name: cache build environment
uses: actions/cache@v2
with:
path: |
~/host/osbuild-packagecache
#~/host/build-root/**/!(dev|tmp|var)/
key: pkg_cache-${{ matrix.release }}-${{ github.ref }}-${{ github.sha }}
restore-keys: |
pkg_cache-${{ matrix.release }}-${{ github.ref }}-
pkg_cache-${{ matrix.release }}-
- name: change permissions for docker osc build
run: |
sudo chown -R root:root ~/host
- name: prep env
run: |
docker pull rsyslog/rsyslog_obs:basic
ls -l ~/host
docker run --rm --privileged -e PKG_PROJ -v ~/host:/host -v$(pwd):/work rsyslog/rsyslog_obs:basic \
bash -c "
export PKG_PROJ=../../..
mkdir _OBS
cd _OBS
git clone https://github.com/rsyslog/pkg_obs-clone.git
cd pkg_obs-clone/rsyslog
echo repair OBS wc
osc repairwc .
echo packaging ubuntu package defs for OBS
source ./build-ubuntu.sh
"
- name: build Ubuntu ${{ matrix.release }}
run: |
docker run --rm --privileged -e PKG_PROJ -e RELEASE=${{ matrix.release }} -v ~/host:/host -v$(pwd):/work rsyslog/rsyslog_obs:basic \
bash -c '
export PKG_PROJ=../../..
cd _OBS/pkg_obs-clone/rsyslog
osc build --trust-all-projects --local-package xUbuntu_$RELEASE x86_64
'
- name: post build permission fixup
run: |
sudo chown -R $(id -u):$(id -g) ~
- name: prepare repo creation
run: |
cd $GITHUB_WORKSPACE
mkdir debs-${{ matrix.release }}
cp ~/host/build-root/xUbuntu_${{ matrix.release }}-x86_64/usr/src/packages/DEBS/* debs-${{ matrix.release }}
pwd
ls -l
- name: save ${{ matrix.release }} DEBs
uses: actions/upload-artifact@v1
with:
name: debs-${{ matrix.release }}
path: debs-${{ matrix.release }}
check_20_04:
runs-on: ubuntu-22.04
needs: build
timeout-minutes: 30
steps:
- name: Download 20.04 debs
uses: actions/download-artifact@v1
with:
name: debs-20.04
- name: merge support libraries from OBS
run: |
mkdir tt
cd tt
wget -q http://download.opensuse.org/repositories/home:/rgerhards/xUbuntu_20.04/Packages
grep Filename: Packages | grep amd64 | grep -v rsyslog \
| sed 's/Filename: /wget -q http:\/\/download.opensuse.org\/repositories\/home:\/rgerhards\/xUbuntu_20.04\//' \
> tmp
source tmp # get .deb files
ls -l
mv *deb $GITHUB_WORKSPACE/debs-20.04
cd ..
rm -rf tt
- name: prepare local repository
run: |
cd debs-20.04
dpkg-scanpackages . /dev/null >Packages
cd $GITHUB_WORKSPACE
- name: check package install
run: |
docker run --rm -v $GITHUB_WORKSPACE/debs-20.04:/debs ubuntu:20.04 bash -c \
'
echo "deb [trusted=yes] file:///debs ./" >> /etc/apt/sources.list
apt-get update
apt-get install -y rsyslog rsyslog-improg rsyslog-imkmsg
'
check_VMs:
runs-on: ubuntu-${{ matrix.release }}
needs: build
# Default: 360 minutes
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
release: [20.04] #22.04
steps:
- name: Download ${{ matrix.release }} debs
uses: actions/download-artifact@v1
with:
name: debs-${{ matrix.release }}
- name: prepare local web server
run: |
sudo apt-get update
sudo apt-get install -y apache2 devscripts debsigs apt-utils
sudo mkdir /var/www/html/repo
sudo chmod o+rw /var/www/html/repo
- name: start local web server
run: |
sudo service apache2 start
- name: get support libraries from OBS
run: |
cd /var/www/html/repo
wget -q -r -np -l2 -A "dsc,l*.deb" --no-host --cut-dirs 4 http://download.opensuse.org/repositories/home:/rgerhards/xUbuntu_18.04/
ls -l
find .
- name: prepare gnupg signing key
run: |
cat >makegpg.conf <<EOF
%echo Generating a default key
Key-Type: RSA
Key-Length: 4096
Subkey-Type: RSA
Subkey-Length: 4096
Name-Real: RSYSLOG CI
Name-Comment: rsyslog
Name-Email: [email protected]
Expire-Date: 0
%no-ask-passphrase
%no-protection
%transient-key
# Do a commit here, so that we can later print "done" :-)
%commit
%echo done
EOF
gpg --batch --gen-key makegpg.conf
- name: prepare repository
run: |
export PKG_KEY=$(gpg --keyid-format short --list-keys [email protected] |grep pub|sed 's~^.*/~~' |sed 's~ 2.*$~~')
export PKG_KEY_LONG=$(gpg --keyid-format long --list-keys [email protected] |grep pub|sed 's~^.*/~~' |sed 's~ 2.*$~~')
echo "Generated temp GPG key: $PKG_KEY / $PKG_KEY_LONG"
cd /var/www/html/repo
cat >signdebs.sh <<EOF
#!/bin/bash
for debfile in ./amd64/*.deb
do
echo "Resigning file \$debfile: debsigs --sign=origin -k $PKG_KEY_LONG \$debfile"
debsigs --sign=origin -k $PKG_KEY_LONG \$debfile
done
EOF
chmod +x signdebs.sh
echo Output GPG Signing Key to Release.key:
gpg --armor --output Release.key --export [email protected]
ls -l $GITHUB_WORKSPACE/debs-${{ matrix.release }}
set -o pipefail
# Do not FAIL pipe on error below
set +e
mv $GITHUB_WORKSPACE/debs-${{ matrix.release }}/*deb amd64
mv $GITHUB_WORKSPACE/debs-${{ matrix.release }}/*dsc .
mv $GITHUB_WORKSPACE/debs-${{ matrix.release }}/*changes .
mv $GITHUB_WORKSPACE/debs-${{ matrix.release }}/*buildinfo . > /dev/null 2>&1
set -e
echo LIST changes files:
ls -al *changes
echo doing debsign
debsign --re-sign ./*.changes -k$PKG_KEY_LONG
debsign --re-sign ./*.dsc -k$PKG_KEY_LONG
ls -l ./amd64/*.deb
./signdebs.sh
dpkg-scanpackages . /dev/null >Packages
xz --keep Packages
apt-ftparchive release ./ > Release
gpg --output Release.gpg --armor --detach-sig Release
# binary format -> gpg --output Release.gpg --detach-sig Release
echo "LIST /var/www/html/repo"
ls -al /var/www/html/repo
echo Packages:
cat Packages
echo Current Dir:
ls -al
cd $GITHUB_WORKSPACE
- name: save ${{ matrix.release }} DEB Repo
uses: actions/upload-artifact@v1
with:
name: repo-${{ matrix.release }}
path: /var/www/html/repo
- name: install test new version
run: |
export PKG_KEY=$(gpg --keyid-format short --list-keys [email protected] |grep pub|sed 's~^.*/~~' |sed 's~ 2.*$~~')
export PKG_KEY_LONG=$(gpg --keyid-format long --list-keys [email protected] |grep pub|sed 's~^.*/~~' |sed 's~ 2.*$~~')
echo "Temp GPG key is: $PKG_KEY / $PKG_KEY_LONG"
# Add repository to local sources
echo "deb http://localhost/repo/ /" | sudo tee /etc/apt/sources.list.d/localhost.repo.list
wget -qO - http://localhost/repo/Release.key | sudo apt-key add -
# Perform apt update and install rsyslog packages
sudo apt-get clean
sudo apt-get update
sudo apt-cache search rsyslog
sudo apt-cache show rsyslog
sudo apt-get install -y rsyslog rsyslog-improg rsyslog-imkmsg
rsyslogd -v
sudo systemctl restart rsyslog
sudo systemctl status rsyslog
logger test1
tail -n20 /var/log/syslog
grep "test1" /var/log/syslog --count || { echo "test1 not logged into /var/log/syslog" >&2; exit 1; }