-
Notifications
You must be signed in to change notification settings - Fork 387
178 lines (157 loc) · 7.7 KB
/
kickstart-tests.yml
File metadata and controls
178 lines (157 loc) · 7.7 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
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
# Run kickstart tests in a PR triggered by a "/kickstart-test <launch args>" comment from an organization member.
name: kickstart-tests
on:
issue_comment:
types: [created]
jobs:
pr-info:
if: startsWith(github.event.comment.body, '/kickstart-test')
runs-on: ubuntu-latest
steps:
- name: Query comment author repository permissions
uses: octokit/request-action@v2.x
id: user_permission
with:
route: GET /repos/${{ github.repository }}/collaborators/${{ github.event.sender.login }}/permission
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# restrict running of tests to users with admin or write permission for the repository
# see https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#get-repository-permissions-for-a-user
# store output if user is allowed in allowed_user job output so it has to be checked in downstream job
- name: Check if user does have correct permissions
if: contains('admin write', fromJson(steps.user_permission.outputs.data).permission)
id: check_user_perm
run: |
echo "User '${{ github.event.sender.login }}' has permission '${{ fromJson(steps.user_permission.outputs.data).permission }}' allowed values: 'admin', 'write'"
echo "::set-output name=allowed_user::true"
- name: Get information for pull request
uses: octokit/request-action@v2.x
id: pr_api
with:
route: GET /repos/${{ github.repository }}/pulls/${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Parse launch arguments
id: parse_launch_args
run: |
# extract first line and cut out the "/kickstart-tests" first word
LAUNCH_ARGS=$(echo '${{ github.event.comment.body }}' | sed -n '1 s/^[^ ]* *//p')
echo "::set-output name=launch_args::${LAUNCH_ARGS}"
outputs:
allowed_user: ${{ steps.check_user_perm.outputs.allowed_user }}
base_ref: ${{ fromJson(steps.pr_api.outputs.data).base.ref }}
sha: ${{ fromJson(steps.pr_api.outputs.data).head.sha }}
launch_args: ${{ steps.parse_launch_args.outputs.launch_args }}
run:
needs: pr-info
# only do this for master for now; once we have RHEL 8/9 boot.iso builds working, also support these
if: needs.pr-info.outputs.base_ref == 'master' && needs.pr-info.outputs.allowed_user == 'true' && needs.pr-info.outputs.launch_args != ''
runs-on: [self-hosted, kstest]
timeout-minutes: 300
env:
LORAX_BUILD_CONTAINER: fedora:rawhide
STATUS_NAME: kickstart-test
steps:
# we post statuses manually as this does not run from a pull_request event
# https://developer.github.com/v3/repos/statuses/#create-a-status
- name: Create in-progress status
uses: octokit/request-action@v2.x
with:
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}'
context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.launch_args }}'
state: pending
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# self-hosted runners don't do this automatically; also useful to keep stuff around for debugging
# need to run sudo as the launch script and the container create root/other user owned files
- name: Clean up previous run
run: |
sudo podman ps -q --all --filter='ancestor=kstest-runner' | xargs -tr sudo podman rm -f
sudo podman volume rm --all || true
sudo rm -rf * .git
- name: Update container images used here
run: |
sudo podman pull ${{ env.LORAX_BUILD_CONTAINER }}
sudo podman pull quay.io/rhinstaller/kstest-runner:latest
- name: Clone repository
uses: actions/checkout@v2
with:
ref: ${{ needs.pr-info.outputs.sha }}
fetch-depth: 0
- name: Rebase to current master
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git log --oneline -1 origin/master
git rebase origin/master
- name: Check out kickstart-tests
uses: actions/checkout@v2
with:
repository: rhinstaller/kickstart-tests
path: kickstart-tests
- name: Ensure http proxy is running
run: sudo kickstart-tests/containers/squid.sh start
# This is really fast, but does not catch file removals or dracut changes
# maybe this becomes opt-in via a magic comment for efficiency reasons?
# if you use this, add `--updates ../updates.img` to the launch command line below
#- name: Build updates.img
# run: |
# scripts/makeupdates
# gzip -cd updates.img | cpio -tv
- name: Build boot.iso from Rawhide and this branch
run: |
mkdir -p kickstart-tests/data/images
# We have to pre-create loop devices because they are not namespaced in kernel so
# podman can't access newly created ones. That caused failures of tests when runners
# were rebooted.
sudo mknod -m 0660 /dev/loop0 b 7 0 2> /dev/null || true
sudo mknod -m 0660 /dev/loop1 b 7 1 2> /dev/null || true
# /var/tmp tmpfs speeds up lorax and avoids https://bugzilla.redhat.com/show_bug.cgi?id=1906364
sudo podman run -i --rm --privileged --tmpfs /var/tmp:rw,mode=1777 -v `pwd`:/source:ro -v `pwd`/kickstart-tests/data/images:/images:z ${{ env.LORAX_BUILD_CONTAINER }} <<EOF
set -eux
# /source from host is read-only, build in a copy
cp -a /source/ /tmp/
cd /tmp/source
# install build dependencies and lorax
./scripts/testing/install_dependencies.sh -y
dnf install -y createrepo_c lorax
# build RPMs and repo for it; bump version so that it's higher than rawhide's
sed -ri '/AC_INIT/ s/\[[0-9.]+\]/[999999999]/' configure.ac
./autogen.sh
./configure
make rpms
createrepo_c result/build/01-rpm-build/
# build boot.iso with our rpms
. /etc/os-release
lorax -p Fedora -v \$VERSION_ID -r \$VERSION_ID -s http://pubmirror2.math.uh.edu/fedora-buffet/fedora/linux/development/rawhide/Everything/x86_64/os/ -s file://\$PWD/result/build/01-rpm-build/ lorax
cp lorax/images/boot.iso /images/
EOF
- name: Clean up after lorax
if: always()
run: |
sudo losetup -d /dev/loop0 2> /dev/null || true
sudo losetup -d /dev/loop1 2> /dev/null || true
- name: Run kickstart tests with ${{ needs.pr-info.outputs.launch_args }} in container
working-directory: kickstart-tests
run: |
sudo TEST_JOBS=16 containers/runner/launch --skip-testtypes 'rhel-only,knownfailure' ${{ needs.pr-info.outputs.launch_args }}
- name: Collect logs
if: always()
uses: actions/upload-artifact@v2
with:
name: 'logs'
# skip the /anaconda subdirectories, too large
path: |
kickstart-tests/data/logs/kstest.log
kickstart-tests/data/logs/kstest-*/*.log
- name: Set result status
if: always()
uses: octokit/request-action@v2.x
with:
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}'
context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.launch_args }}'
state: ${{ job.status }}
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}