Skip to content

Commit c665931

Browse files
committed
add testing farm github action
1 parent 7b042f7 commit c665931

File tree

3 files changed

+242
-2
lines changed

3 files changed

+242
-2
lines changed
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
name: linux-qe-template
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
trigger-workflow-run-id:
7+
required: true
8+
type: string
9+
qe-type:
10+
description: type of test; allowed values e2e or integration
11+
required: true
12+
type: string
13+
preset:
14+
description: preset type only required if qe-type is e2e
15+
type: string
16+
17+
jobs:
18+
linux-qe:
19+
runs-on: [self-hosted, linux, testing-farm]
20+
permissions:
21+
statuses: write # needed to update commit status (pending/failure/sucess)
22+
checks: write # as documented in https://github.com/mikepenz/action-junit-report?tab=readme-ov-file#pr-run-permissions
23+
steps:
24+
- name: prepare env
25+
run: |
26+
sudo yum install podman openssh-server -y
27+
28+
commit_sha=$(cat gh_context.json | jq -r '.event.after')
29+
if [[ -z "${commit_sha}" ]] || [[ "${commit_sha}" == null ]]; then
30+
# on first PR creation .event.after is empty, then .sha is used as commit instead
31+
commit_sha=$(cat gh_context.json | jq -r '.event.pull_request.head.sha')
32+
fi
33+
echo "commit_sha=${commit_sha}" >> "$GITHUB_ENV"
34+
mkdir ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
35+
cd ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
36+
37+
# the target can only be accessed through a bastion (which can only be accessed from self-hosted runner)
38+
# as so we need to map the ssh-agent from the host to the containers used to access the target host
39+
ssh-keygen -t rsa -N '' -f id_rsa -q
40+
eval $(ssh-agent -s)
41+
echo $SSH_AUTH_SOCK > ssh_auth_sock
42+
echo $SSH_AGENT_PID > ssh_agent_pid
43+
ssh-add id_rsa
44+
45+
- name: reserve machine from testing farm
46+
working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
47+
env:
48+
TESTING_FARM_API_TOKEN: ${{ secrets.TESTING_FARM_API_TOKEN }}
49+
PULL_SECRET: ${{ secrets.PULL_SECRET }}
50+
run: |
51+
echo "${PULL_SECRET}" > pull-secret
52+
export TESTING_FARM_API_TOKEN=${TESTING_FARM_API_TOKEN}
53+
testing-farm reserve --compose Fedora-40 --duration 240 --arch aarch64 --hardware memory='>= 12 GB' --hardware virtualization.is-supported='true' --ssh-public-key id_rsa.pub --no-autoconnect | tee info
54+
machine=`tail -n 1 info`
55+
echo ${machine##*@} > host
56+
echo crctest > username
57+
echo proxy > bastion_username
58+
echo testing-farm.io > bastion_host
59+
request=`sed -n '4p' info`
60+
echo ${request:1} > requestid
61+
62+
# connect to the reserved machine, create a non-root user for testing
63+
${machine:1}
64+
new_user=crctest
65+
useradd $new_user
66+
echo "$new_user:redhat" | chpasswd
67+
usermod -aG wheel $new_user
68+
echo "$new_user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/crctest-users
69+
mkdir -p /home/$new_user/.ssh
70+
cp /root/.ssh/authorized_keys /home/$new_user/.ssh/
71+
chown $new_user /home/$new_user/.ssh/authorized_keys
72+
exit
73+
74+
- name: Download linux binary
75+
working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
76+
uses: actions/download-artifact@v4
77+
with:
78+
name: linux-binary
79+
run-id: ${{inputs.trigger-workflow-run-id}}
80+
github-token: ${{ github.token }}
81+
82+
- name: Download qe oci image
83+
working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
84+
id: download-qe-oci-image-artifact
85+
uses: actions/download-artifact@v4
86+
with:
87+
name: crc-${{inputs.qe-type}}-linux-arm64
88+
run-id: ${{inputs.trigger-workflow-run-id}}
89+
github-token: ${{ github.token }}
90+
91+
- name: Install CRC on host
92+
working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
93+
run: |
94+
podman run --rm -d --privileged --name crc-linux-install-${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} \
95+
-e TARGET_HOST=$(cat host) \
96+
-e TARGET_HOST_USERNAME=$(cat username) \
97+
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
98+
-e BASTION_HOST_USERNAME=$(cat bastion_username) \
99+
-e BASTION_HOST=$(cat bastion_host) \
100+
-e TARGET_FOLDER=crc-support \
101+
-e TARGET_CLEANUP='false' \
102+
-e OUTPUT_FOLDER=/data \
103+
-e DEBUG='true' \
104+
-e SSH_AUTH_SOCK=$(cat ssh_auth_sock) \
105+
-v "$(cat ssh_auth_sock):$(cat ssh_auth_sock)" \
106+
-v ${PWD}:/data:z \
107+
-v ${PWD}/crc:/opt/crc-support/crc:z \
108+
quay.io/crc-org/ci-crc-support:v2.0.0-dev-linux crc-support/run.sh \
109+
-targetPath "/root/crc-support" \
110+
-install 'true' \
111+
-aName 'crc' \
112+
-freshEnv 'false' \
113+
-download 'false'
114+
podman logs -f crc-linux-install-${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
115+
116+
- name: Run CRC ${{inputs.qe-type}} test
117+
working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
118+
run: |
119+
# load image
120+
podman load -i crc-${{inputs.qe-type}}-linux-arm64.tar
121+
# run
122+
cmd="crc-qe/run.sh -junitFilename crc-${{inputs.qe-type}}-junit.xml -targetFolder crc-qe"
123+
if [[ "${{inputs.qe-type}}" == "e2e" ]]; then
124+
if [[ "${{inputs.preset}}" == "microshift" ]]; then
125+
cmd="${cmd} -e2eTagExpression '@story_microshift'"
126+
else
127+
cmd="${cmd} -e2eTagExpression '~@minimal && ~@story_microshift'"
128+
fi
129+
fi
130+
podman run --rm -d --privileged --name crc-${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} \
131+
-e TARGET_HOST=$(cat host) \
132+
-e TARGET_HOST_USERNAME=$(cat username) \
133+
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
134+
-e BASTION_HOST_USERNAME=$(cat bastion_username) \
135+
-e BASTION_HOST=$(cat bastion_host) \
136+
-e TARGET_FOLDER=crc-qe \
137+
-e TARGET_RESULTS=results \
138+
-e OUTPUT_FOLDER=/data \
139+
-e DEBUG=true \
140+
-e SSH_AUTH_SOCK=$(cat ssh_auth_sock) \
141+
-v "$(cat ssh_auth_sock):$(cat ssh_auth_sock)" \
142+
-v $PWD/pull-secret:/opt/crc/pull-secret:z \
143+
-v $PWD:/data:z \
144+
quay.io/crcont/crc-${{inputs.qe-type}}:gh-linux-arm64 \
145+
${cmd}
146+
podman logs -f crc-${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
147+
148+
- name: Test Report
149+
working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
150+
id: test-report
151+
uses: mikepenz/action-junit-report@v4
152+
if: always()
153+
with:
154+
fail_on_failure: true
155+
include_passed: true
156+
detailed_summary: true
157+
require_tests: true
158+
report_paths: '**/*.xml'
159+
160+
- name: Upload e2e results
161+
working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
162+
uses: actions/upload-artifact@v4
163+
if: always()
164+
with:
165+
name: linux-${{inputs.qe-type}}-${{inputs.preset}}
166+
path: |
167+
**/*.xml
168+
**/*.results
169+
**/*.log
170+
171+
- name: Update status of the PR check
172+
if: always()
173+
run: |
174+
set -xuo
175+
# Status msg
176+
data="{\"state\":\"success\""
177+
if [[ ${{steps.test-report.outcome}} != "success" ]]; then
178+
data="{\"state\":\"failure\""
179+
fi
180+
data="${data},\"description\":\"Finished ${{inputs.qe-type}}-${{inputs.preset}} on Linux\""
181+
data="${data},\"context\":\"${{ env.status_context }}\""
182+
data="${data},\"target_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
183+
# Create status by API call
184+
curl -L -v -X POST \
185+
-H "Accept: application/vnd.github+json" \
186+
-H "Authorization: Bearer ${{ github.token }}" \
187+
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.commit_sha }} \
188+
-d "${data}"
189+
190+
- name: Return machine and clear env
191+
env:
192+
TESTING_FARM_API_TOKEN: ${{ secrets.TESTING_FARM_API_TOKEN }}
193+
working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
194+
run: |
195+
export TESTING_FARM_API_TOKEN=${TESTING_FARM_API_TOKEN}
196+
testing-farm cancel $(cat requestid)
197+
kill $(cat ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}/ssh_agent_pid)
198+
cd ..
199+
rm -r ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
200+
201+
202+

.github/workflows/linux-qe-test.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: tester-linux
2+
3+
on:
4+
workflow_run:
5+
workflows: [Build Windows artifacts]
6+
types:
7+
- completed
8+
9+
jobs:
10+
linux-qe:
11+
if: |
12+
github.event.workflow_run.conclusion == 'success' &&
13+
github.event.workflow_run.event == 'pull_request' &&
14+
github.event.workflow_run.triggering_actor != 'dependabot[bot]'
15+
uses: crc-org/crc/.github/workflows/linux-qe-template.yml@main
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
qe-type: ['e2e','integration']
20+
preset: ['openshift', 'microshift', 'all']
21+
exclude:
22+
- qe-type: 'e2e'
23+
preset: 'all'
24+
- qe-type: 'integration'
25+
preset: 'openshift'
26+
- qe-type: 'integration'
27+
preset: 'microshift'
28+
with:
29+
trigger-workflow-run-id: ${{ github.event.workflow_run.id }}
30+
qe-type: ${{matrix.qe-type}}
31+
preset: ${{matrix.preset}}
32+
secrets: inherit

.github/workflows/windows-artifacts.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ jobs:
4040
with:
4141
name: windows-installer
4242
path: "./out/windows-amd64/crc-windows-installer.zip"
43+
- name: Build Linux binary
44+
run: |
45+
make out/linux-arm64/crc
46+
- name: Upload linux binary
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: linux-binary
50+
path: "./out/linux-arm64/crc"
4351
build-qe:
4452
runs-on: ubuntu-latest
4553
strategy:
@@ -50,8 +58,6 @@ jobs:
5058
exclude:
5159
- arch: 'arm64'
5260
os: 'windows'
53-
- arch: 'arm64'
54-
os: 'linux'
5561
steps:
5662
- name: Check out repository code
5763
uses: actions/checkout@v4

0 commit comments

Comments
 (0)