Skip to content

Commit c847fa2

Browse files
authored
Merge pull request #770 from mcattamoredhat/add-ci-make-rpm-2
ci: add Image Mode test automation without Packit
2 parents 3dacc46 + 0046847 commit c847fa2

14 files changed

Lines changed: 806 additions & 0 deletions
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
name: Image Mode CI Test
3+
4+
on:
5+
pull_request_target:
6+
types: [opened, synchronize, reopened]
7+
8+
jobs:
9+
check-pull-request:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Query author repository permissions
13+
uses: octokit/request-action@v2.x
14+
id: user_permission
15+
with:
16+
route: GET /repos/${{ github.repository }}/collaborators/${{ github.event.sender.login }}/permission
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
20+
- name: Check if user does have correct permissions
21+
if: contains('admin write', fromJson(steps.user_permission.outputs.data).permission)
22+
id: check_user_perm
23+
run: |
24+
echo "User '${{ github.event.sender.login }}' has permission '${{ fromJson(steps.user_permission.outputs.data).permission }}' allowed values: 'admin', 'write'"
25+
echo "allowed_user=true" >> $GITHUB_OUTPUT
26+
- name: Get information for pull request
27+
uses: octokit/request-action@v2.x
28+
id: pr-api
29+
with:
30+
route: GET /repos/${{ github.repository }}/pulls/${{ github.event.number }}
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
34+
outputs:
35+
allowed_user: ${{ steps.check_user_perm.outputs.allowed_user }}
36+
sha: ${{ fromJson(steps.pr-api.outputs.data).head.sha }}
37+
ref: ${{ fromJson(steps.pr-api.outputs.data).head.ref }}
38+
repo_url: ${{ fromJson(steps.pr-api.outputs.data).head.repo.html_url }}
39+
40+
RHEL-10-fdo-bootc:
41+
name: Test fdo RHEL-10.0 Image Mode
42+
needs: check-pull-request
43+
if: ${{ needs.check-pull-request.outputs.allowed_user == 'true' }}
44+
continue-on-error: true
45+
runs-on: ubuntu-latest
46+
47+
steps:
48+
- name: Run the tests
49+
uses: sclorg/testing-farm-as-github-action@v3.1.2
50+
with:
51+
compose: RHEL-10.0-Nightly
52+
api_key: ${{ secrets.TF_API_KEY }}
53+
git_url: ${{ needs.check-pull-request.outputs.repo_url }}
54+
git_ref: ${{ needs.check-pull-request.outputs.ref }}
55+
tmt_context: "arch=x86_64;distro=rhel-10-0"
56+
tmt_path: "./test/fmf"
57+
tmt_plan_regex: fdo-bootc
58+
tf_scope: private
59+
variables: "ARCH=x86_64;REPO_URL=${{ github.server_url }}/${{ github.repository }};REPO_NAME=${{ github.repository }};PR_NUMBER=${{ github.event.number }}"
60+
timeout: 90
61+
secrets: "QUAY_USERNAME=${{ secrets.QUAY_USERNAME }};QUAY_PASSWORD=${{ secrets.QUAY_PASSWORD }};STAGE_REDHAT_IO_USERNAME=${{ secrets.STAGE_REDHAT_IO_USERNAME }};STAGE_REDHAT_IO_TOKEN=${{ secrets.STAGE_REDHAT_IO_TOKEN }};DOWNLOAD_NODE=${{ secrets.DOWNLOAD_NODE }};REDHAT_IO_USERNAME=${{ secrets.REDHAT_IO_USERNAME }};REDHAT_IO_TOKEN=${{ secrets.REDHAT_IO_TOKEN }};SSH_KEY=${{ secrets.SSH_KEY }};SSH_PASSWORD=${{ secrets.SSH_PASSWORD }}"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
summary: FDO Image Mode test plan
2+
discover:
3+
how: fmf
4+
test: image-mode-onboarding
5+
prepare:
6+
- name: Prepare repository
7+
how: shell
8+
script: |
9+
git clone $REPO_URL /tmp/$REPO_NAME
10+
cd /tmp/$REPO_NAME
11+
git fetch origin pull/$PR_NUMBER/head:test-branch
12+
git checkout test-branch
13+
git submodule update --init
14+
execute:
15+
how: tmt
16+
provision:
17+
hardware:
18+
virtualization:
19+
is-supported: true
20+
cpu:
21+
processors: ">= 2"
22+
memory: ">= 6 GB"
23+
24+
/fdo-bootc:
25+
summary: Test fdo in rhel-10 Image Mode
26+
environment+:
27+
TEST_CASE: fdo-bootc
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
- hosts: image_mode_guest
3+
become: no
4+
vars:
5+
fdo_credential: "false"
6+
total_counter: "0"
7+
failed_counter: "0"
8+
9+
tasks:
10+
# check installed fido device onboard packages
11+
- name: fdo should be installed
12+
block:
13+
- name: fdo should be installed
14+
shell: rpm -qa | grep -E 'fdo|fido'
15+
16+
# check tpm device
17+
- name: check tpm device
18+
stat:
19+
path: /dev/tpm0
20+
ignore_errors: yes
21+
when: fdo_credential == "true"
22+
23+
# case: check fdo onboarding status
24+
# after fdo onboarding finished, /boot/device-credentials will be moved to /etc/device-credentials
25+
- name: check if fdo onboarding completed successfully
26+
block:
27+
- name: wait until the file /etc/device-credentials is present before continuing
28+
wait_for:
29+
path: /etc/device-credentials
30+
always:
31+
- set_fact:
32+
total_counter: "{{ total_counter | int + 1 }}"
33+
rescue:
34+
- name: failed count + 1
35+
set_fact:
36+
failed_counter: "{{ failed_counter | int + 1 }}"
37+
when: fdo_credential == "true"
38+
39+
# Check FDO status and task status
40+
- name: check fdo-client-linuxapp logs
41+
command: journalctl -u fdo-client-linuxapp
42+
register: result_fdo_client_linuxapp_journalctl
43+
become: yes
44+
when:
45+
- fdo_credential == "true"
46+
47+
- name: check secure device onboarding successful
48+
block:
49+
- assert:
50+
that:
51+
- "'Secure Device Onboarding DONE' in result_fdo_client_linuxapp_journalctl.stdout"
52+
fail_msg: "Secure Device Onboarding not successful"
53+
success_msg: "Secure Device Onboarding successful"
54+
always:
55+
- set_fact:
56+
total_counter: "{{ total_counter | int + 1 }}"
57+
rescue:
58+
- name: failed count + 1
59+
set_fact:
60+
failed_counter: "{{ failed_counter | int + 1 }}"
61+
when: fdo_credential == "true"
62+
63+
# Check FDO client avc log
64+
- name: check FDO client avc logs
65+
command: ausearch -m avc -m user_avc -m selinux_err -i
66+
ignore_errors: yes
67+
become: yes
68+
when:
69+
- fdo_credential == "true"
70+
71+
- assert:
72+
that:
73+
- failed_counter == "0"
74+
fail_msg: "Run {{ total_counter }} tests, but {{ failed_counter }} of them failed"
75+
success_msg: "Totally {{ total_counter }} test passed"

0 commit comments

Comments
 (0)