Skip to content

Commit 42eecff

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

File tree

3 files changed

+239
-2
lines changed

3 files changed

+239
-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 --ssh-public-key id_rsa.pub --no-autoconnect | tee info
54+
machine=`tail -n 1 info`
55+
echo ${machine##*@} > host
56+
echo root > username
57+
echo proxy > bastion_username
58+
echo testing-farm.io > bastion_host
59+
60+
- name: Download linux binary
61+
working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: linux-binary
65+
run-id: ${{inputs.trigger-workflow-run-id}}
66+
github-token: ${{ github.token }}
67+
68+
- name: Download qe oci image
69+
working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
70+
id: download-qe-oci-image-artifact
71+
uses: actions/download-artifact@v4
72+
with:
73+
name: crc-${{inputs.qe-type}}-linux-arm64
74+
run-id: ${{inputs.trigger-workflow-run-id}}
75+
github-token: ${{ github.token }}
76+
77+
- name: Install CRC on host
78+
working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
79+
run: |
80+
podman run --rm -d --privileged --name crc-linux-install-${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} \
81+
-e TARGET_HOST=$(cat host) \
82+
-e TARGET_HOST_USERNAME=$(cat username) \
83+
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
84+
-e BASTION_HOST_USERNAME=$(cat bastion_username) \
85+
-e BASTION_HOST=$(cat bastion_host) \
86+
-e TARGET_FOLDER=crc-support \
87+
-e TARGET_CLEANUP='false' \
88+
-e OUTPUT_FOLDER=/data \
89+
-e DEBUG='true' \
90+
-e SSH_AUTH_SOCK=$(cat ssh_auth_sock) \
91+
-v "$(cat ssh_auth_sock):$(cat ssh_auth_sock)" \
92+
-v ${PWD}:/data:z \
93+
-v ${PWD}/crc:/opt/crc-support/crc:z \
94+
quay.io/crc-org/ci-crc-support:v2.0.0-dev-linux crc-support/run.sh \
95+
-targetPath "/root/crc-support" \
96+
-install 'true' \
97+
-aName 'crc' \
98+
-freshEnv 'false' \
99+
-download 'false'
100+
podman logs -f crc-linux-install-${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
101+
102+
- name: Run CRC ${{inputs.qe-type}} test
103+
working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
104+
run: |
105+
# load image
106+
podman load -i crc-${{inputs.qe-type}}-linux-arm64.tar
107+
# run
108+
cmd="crc-qe/run.sh -junitFilename crc-${{inputs.qe-type}}-junit.xml -targetFolder crc-qe"
109+
if [[ "${{inputs.qe-type}}" == "e2e" ]]; then
110+
if [[ "${{inputs.preset}}" == "microshift" ]]; then
111+
cmd="${cmd} -e2eTagExpression '@story_microshift'"
112+
else
113+
cmd="${cmd} -e2eTagExpression '~@minimal && ~@story_microshift'"
114+
fi
115+
fi
116+
podman run --rm -d --privileged --name crc-${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} \
117+
-e TARGET_HOST=$(cat host) \
118+
-e TARGET_HOST_USERNAME=$(cat username) \
119+
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
120+
-e BASTION_HOST_USERNAME=$(cat bastion_username) \
121+
-e BASTION_HOST=$(cat bastion_host) \
122+
-e TARGET_FOLDER=crc-qe \
123+
-e TARGET_RESULTS=results \
124+
-e OUTPUT_FOLDER=/data \
125+
-e DEBUG=true \
126+
-e SSH_AUTH_SOCK=$(cat ssh_auth_sock) \
127+
-v "$(cat ssh_auth_sock):$(cat ssh_auth_sock)" \
128+
-v $PWD/pull-secret:/opt/crc/pull-secret:z \
129+
-v $PWD:/data:z \
130+
quay.io/crcont/crc-${{inputs.qe-type}}:gh-linux-arm64 \
131+
${cmd}
132+
podman logs -f crc-${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
133+
134+
- name: Test Report
135+
working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
136+
id: test-report
137+
uses: mikepenz/action-junit-report@v4
138+
if: always()
139+
with:
140+
fail_on_failure: true
141+
include_passed: true
142+
detailed_summary: true
143+
require_tests: true
144+
report_paths: '**/*.xml'
145+
146+
- name: Upload e2e results
147+
working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
148+
uses: actions/upload-artifact@v4
149+
if: always()
150+
with:
151+
name: linux-${{inputs.qe-type}}-${{inputs.preset}}
152+
path: |
153+
**/*.xml
154+
**/*.results
155+
**/*.log
156+
157+
- name: Update status of the PR check
158+
if: always()
159+
run: |
160+
set -xuo
161+
# Status msg
162+
data="{\"state\":\"success\""
163+
if [[ ${{steps.test-report.outcome}} != "success" ]]; then
164+
data="{\"state\":\"failure\""
165+
fi
166+
data="${data},\"description\":\"Finished ${{inputs.qe-type}}-${{inputs.preset}} on Linux\""
167+
data="${data},\"context\":\"${{ env.status_context }}\""
168+
data="${data},\"target_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
169+
# Create status by API call
170+
curl -L -v -X POST \
171+
-H "Accept: application/vnd.github+json" \
172+
-H "Authorization: Bearer ${{ github.token }}" \
173+
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.commit_sha }} \
174+
-d "${data}"
175+
176+
- name: Return machine from testing farm
177+
working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
178+
run: |
179+
podman run --rm -d --privileged --name crc-linux-return-${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} \
180+
-e TARGET_HOST=$(cat host) \
181+
-e TARGET_HOST_USERNAME=$(cat username) \
182+
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
183+
-e BASTION_HOST_USERNAME=$(cat bastion_username) \
184+
-e BASTION_HOST=$(cat bastion_host) \
185+
-e TARGET_FOLDER=crc-support \
186+
-e TARGET_CLEANUP='false' \
187+
-e OUTPUT_FOLDER=/data \
188+
-e DEBUG='true' \
189+
-e SSH_AUTH_SOCK=$(cat ssh_auth_sock) \
190+
-v "$(cat ssh_auth_sock):$(cat ssh_auth_sock)" \
191+
-v ${PWD}:/data:z \
192+
quay.io/rhqp/crc-support:v0.5.1-linux return2testingfarm
193+
podman logs -f crc-linux-return-${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
194+
195+
- name: Env clear
196+
working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
197+
run: |
198+
kill $(cat ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}/ssh_agent_pid)
199+
cd ..
200+
rm -r ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}
201+
202+

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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: ${{ github.event.workflow_run.conclusion == 'success' }}
12+
uses: crc-org/crc/.github/workflows/linux-qe-template.yml@main
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
qe-type: ['e2e','integration']
17+
preset: ['openshift', 'microshift', 'all']
18+
exclude:
19+
- qe-type: 'e2e'
20+
preset: 'all'
21+
- qe-type: 'integration'
22+
preset: 'openshift'
23+
- qe-type: 'integration'
24+
preset: 'microshift'
25+
with:
26+
trigger-workflow-run-id: ${{ github.event.workflow_run.id }}
27+
qe-type: ${{matrix.qe-type}}
28+
preset: ${{matrix.preset}}
29+
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)