Skip to content

Commit 2d81e70

Browse files
authored
Merge pull request #526 from henrywang/container_ci
CI: Add FDO container integration test CI
2 parents 6862761 + 93fb699 commit 2d81e70

12 files changed

Lines changed: 1192 additions & 4 deletions

.github/workflows/integration.yaml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
---
2+
name: FDO container test
3+
4+
on:
5+
issue_comment:
6+
types:
7+
- created
8+
9+
jobs:
10+
pr-info:
11+
if: ${{ github.event.issue.pull_request &&
12+
(startsWith(github.event.comment.body, '/test-all') ||
13+
startsWith(github.event.comment.body, '/test-container')) }}
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Query author repository permissions
17+
uses: octokit/request-action@v2.x
18+
id: user_permission
19+
with:
20+
route: GET /repos/${{ github.repository }}/collaborators/${{ github.event.sender.login }}/permission
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
# restrict running of tests to users with admin or write permission for the repository
25+
# see https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#get-repository-permissions-for-a-user
26+
- name: Check if user does have correct permissions
27+
if: contains('admin write', fromJson(steps.user_permission.outputs.data).permission)
28+
id: check_user_perm
29+
run: |
30+
echo "User '${{ github.event.sender.login }}' has permission '${{ fromJson(steps.user_permission.outputs.data).permission }}' allowed values: 'admin', 'write'"
31+
echo "allowed_user=true" >> $GITHUB_OUTPUT
32+
- name: Get information for pull request
33+
uses: octokit/request-action@v2.x
34+
id: pr-api
35+
with:
36+
route: GET /repos/${{ github.repository }}/pulls/${{ github.event.issue.number }}
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
40+
outputs:
41+
allowed_user: ${{ steps.check_user_perm.outputs.allowed_user }}
42+
sha: ${{ fromJson(steps.pr-api.outputs.data).head.sha }}
43+
44+
pre-fido-container:
45+
needs: pr-info
46+
if: ${{ needs.pr-info.outputs.allowed_user == 'true' }} &&
47+
(startsWith(github.event.comment.body, '/test-all') ||
48+
startsWith(github.event.comment.body, '/test-container'))}}
49+
runs-on: ubuntu-latest
50+
env:
51+
STATUS_NAME: fido-container-test
52+
53+
steps:
54+
- name: Get Current Job Log URL
55+
id: job-log-url
56+
run: |
57+
JOB_HTML_URL=$(curl --get -Ss -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/fedora-iot/fido-device-onboard-rs/actions/runs/${GITHUB_RUN_ID}/jobs?per_page=30" | jq -r --arg job_name "pre-fido-container" '.jobs | map(select(.name == "pre-fido-container")) | .[0].html_url')
58+
echo "html_url=$JOB_HTML_URL" >> $GITHUB_OUTPUT
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
62+
- name: Create in-progress status
63+
uses: octokit/request-action@v2.x
64+
with:
65+
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}'
66+
context: ${{ env.STATUS_NAME }}
67+
state: pending
68+
description: 'CentOS Stream 9 - Runner has been deploying...'
69+
target_url: ${{ steps.job-log-url.outputs.html_url }}
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
73+
fido-container:
74+
needs: [pr-info, pre-fido-container]
75+
if: ${{ needs.pr-info.outputs.allowed_user == 'true' }} &&
76+
(startsWith(github.event.comment.body, '/test-all') ||
77+
startsWith(github.event.comment.body, '/test-container'))}}
78+
runs-on: [kite, x86_64, gcp, centos-stream-9, medium]
79+
env:
80+
STATUS_NAME: fido-container-test
81+
82+
steps:
83+
- name: Get Current Job Log URL
84+
id: job-log-url
85+
run: |
86+
JOB_HTML_URL=$(curl --get -Ss -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/fedora-iot/fido-device-onboard-rs/actions/runs/${GITHUB_RUN_ID}/jobs?per_page=30" | jq -r --arg job_name "fido-container" '.jobs | map(select(.name == "fido-container")) | .[0].html_url')
87+
echo "html_url=$JOB_HTML_URL" >> $GITHUB_OUTPUT
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
91+
- name: Create in-progress status
92+
uses: octokit/request-action@v2.x
93+
with:
94+
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}'
95+
context: ${{ env.STATUS_NAME }}
96+
state: pending
97+
description: 'CentOS Stream 9 - Test has been running...'
98+
target_url: ${{ steps.job-log-url.outputs.html_url }}
99+
env:
100+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
102+
- name: Install required packages
103+
run: sudo dnf install -y make gcc openssl openssl-devel findutils golang git tpm2-tss-devel swtpm swtpm-tools git clevis clevis-luks cryptsetup cryptsetup-devel clang-devel cracklib-dicts rust-toolset rpmdevtools python3-docutils createrepo_c podman buildah skopeo
104+
105+
- name: Clone repository
106+
uses: actions/checkout@v3
107+
with:
108+
ref: ${{ needs.pr-info.outputs.sha }}
109+
fetch-depth: 0
110+
111+
- name: Build fido containers
112+
uses: ./.github/actions/build_containers
113+
114+
- name: Build fido PRM pakcages
115+
run: make rpm
116+
117+
- name: Prepare
118+
run: |
119+
sudo mkdir -p /var/www/html/source
120+
sudo cp ./rpmbuild/RPMS/x86_64/* /var/www/html/source/ 2>/dev/null || :
121+
sudo createrepo_c /var/www/html/source
122+
sudo ls -al /var/www/html/source
123+
124+
- name: Run fdo-container.sh test
125+
run: ./fdo-container.sh
126+
working-directory: tests
127+
timeout-minutes: 100
128+
129+
- name: Set non cancelled result status
130+
if: ${{ !cancelled() }}
131+
uses: octokit/request-action@v2.x
132+
with:
133+
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}'
134+
context: ${{ env.STATUS_NAME }}
135+
state: ${{ job.status }}
136+
description: 'CentOS Stream 9 - Test got ${{ job.status }}'
137+
target_url: ${{ steps.job-log-url.outputs.html_url }}
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
141+
- name: Set cancelled result status
142+
if: ${{ cancelled() }}
143+
uses: octokit/request-action@v2.x
144+
with:
145+
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}'
146+
context: ${{ env.STATUS_NAME }}
147+
state: ${{ job.status }}
148+
description: 'CentOS Stream 9 - Test got error'
149+
target_url: ${{ steps.job-log-url.outputs.html_url }}
150+
env:
151+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
152+
153+
- uses: actions/upload-artifact@v3
154+
if: ${{ always() }}
155+
with:
156+
name: fido-container
157+
path: |
158+
*.json
159+
*.log

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ VENDOR_TARBALL=rpmbuild/SOURCES/fido-device-onboard-rs-$(COMMIT)-vendor.tar.gz
4242

4343
$(RPM_SPECFILE):
4444
mkdir -p $(CURDIR)/rpmbuild/SPECS
45-
(echo "%global commit $(COMMIT)"; git show HEAD:fido-device-onboard.spec) > $(RPM_SPECFILE)
45+
sed "s/%{url}\/archive\/v%{version}\/%{name}-rs-%{version}.tar.gz/%{name}-rs-$(COMMIT).tar.gz/; s/%{name}-rs-%{version}-vendor-patched.tar.xz/%{name}-rs-$(COMMIT)-vendor.tar.gz/; s/%autosetup -p1 -n %{name}-rs-%{version}/%autosetup -p1 -n %{name}-rs-$(COMMIT)/" fido-device-onboard.spec > $(RPM_SPECFILE)
4646

4747
$(RPM_TARBALL):
4848
mkdir -p $(CURDIR)/rpmbuild/SOURCES
4949
git archive --prefix=fido-device-onboard-rs-$(COMMIT)/ --format=tar.gz HEAD > $(RPM_TARBALL)
5050
cp ./make-vendored-tarfile.sh rpmbuild/SOURCES/make-vendored-tarfile.sh
5151

5252
$(VENDOR_TARBALL):
53-
./make-vendored-tarfile.sh $(COMMIT) $(VENDOR_TARBALL)
53+
./make-vendored-tarfile.sh $(VENDOR_TARBALL)
5454

5555
.PHONY: srpm
5656
srpm: $(RPM_SPECFILE) $(RPM_TARBALL) $(VENDOR_TARBALL)

make-vendored-tarfile.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#/bin/bash
22
set -x
3-
ver=$1
3+
vendor_tarball=$1
44
cargo vendor
55
# Various vendor cleanups
66
pushd vendor
@@ -11,4 +11,4 @@ rm -rf winapi-x86_64-pc-windows-gnu/lib/*
1111
rm -rf winapi-i686-pc-windows-gnu/lib/*
1212
rm -rf vcpkg/test-data
1313
popd #vendor
14-
tar cjf fido-device-onboard-rs-$ver-vendor-patched.tar.xz vendor/
14+
tar cjf $vendor_tarball vendor/

0 commit comments

Comments
 (0)