Skip to content

Commit 99f2515

Browse files
committed
workflows: add LAVA test workflows
Add boot test job for rb3gen2. The job is executed on hardware in LAVA LAB. Tests are scheduled after daily build, push build and PR build. Tests scheduled after PR will use the test job templates from the main branch. This is caused by workflow trigger "on_workflow_run". This trigger was used to prevent leaking of LAVA token to forked repositories. Signed-off-by: Milosz Wasilewski <[email protected]>
1 parent 63e3353 commit 99f2515

File tree

6 files changed

+315
-1
lines changed

6 files changed

+315
-1
lines changed

.github/workflows/build-daily.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ permissions:
1313
jobs:
1414
build-daily:
1515
uses: ./.github/workflows/debos.yml
16+
test-daily:
17+
uses: ./.github/workflows/test.yml
18+
needs: build-nightly
19+
secrets: inherit
20+
with:
21+
url: ${{ needs.build-daily.outputs.artifacts_url }}

.github/workflows/build-on-pr.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,22 @@ on:
44
pull_request:
55

66
permissions:
7-
contents: read
7+
checks: write # required by test reporting action
8+
pull-requests: write # required by test reporting action
9+
contents: read # github default
10+
packages: read # github default
811

912
jobs:
13+
event-file:
14+
name: "Upload event file"
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Upload
18+
uses: actions/upload-artifact@v4
19+
with:
20+
name: Event File
21+
path: ${{ github.event_path }}
22+
1023
build-pr:
1124
uses: ./.github/workflows/debos.yml
1225

.github/workflows/build-on-push.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,17 @@ on:
55
branches: [main]
66

77
permissions:
8+
checks: write
9+
pull-requests: write
810
contents: read
11+
packages: read
912

1013
jobs:
1114
build-daily:
1215
uses: ./.github/workflows/debos.yml
16+
test:
17+
uses: ./.github/workflows/test.yml
18+
needs: [build]
19+
secrets: inherit
20+
with:
21+
url: ${{ needs.build.outputs.artifacts_url }}

.github/workflows/test-pr.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Test PR build
2+
3+
run-name: "Tests triggered by PR: ${{ github.event.workflow_run.display_title }}"
4+
5+
on:
6+
workflow_run:
7+
workflows: ["Build on PR"]
8+
types:
9+
- completed
10+
11+
permissions:
12+
checks: write # required by test reporting action
13+
pull-requests: write # required by test reporting action
14+
contents: read # github default
15+
packages: read # github default
16+
17+
jobs:
18+
retrieve-build-url:
19+
runs-on: ubuntu-latest
20+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
21+
outputs:
22+
url: ${{ steps.set-build-url.outputs.url }}
23+
steps:
24+
- name: 'Download build URL'
25+
uses: actions/github-script@v6
26+
with:
27+
script: |
28+
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
run_id: context.payload.workflow_run.id,
32+
});
33+
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
34+
return artifact.name == "build_url"
35+
})[0];
36+
let download = await github.rest.actions.downloadArtifact({
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
artifact_id: matchArtifact.id,
40+
archive_format: 'zip',
41+
});
42+
const fs = require('fs');
43+
const path = require('path');
44+
const temp = '${{ runner.temp }}/artifacts';
45+
if (!fs.existsSync(temp)){
46+
fs.mkdirSync(temp);
47+
}
48+
fs.writeFileSync(path.join(temp, 'build_url.zip'), Buffer.from(download.data));
49+
50+
- name: 'Setup build URL'
51+
id: set-build-url
52+
run: |
53+
unzip "${{ runner.temp }}/artifacts/build_url.zip"
54+
BUILD_URL=$(cat build_url)
55+
echo "Build URL: ${BUILD_URL}"
56+
echo "url=${BUILD_URL}" >> $GITHUB_OUTPUT
57+
58+
test:
59+
uses: ./.github/workflows/test.yml
60+
secrets: inherit
61+
needs: retrieve-build-url
62+
with:
63+
url: ${{ needs.retrieve-build-url.outputs.url }}
64+
65+
publish-test-results:
66+
name: "Publish Tests Results"
67+
needs: test
68+
runs-on: ubuntu-latest
69+
steps:
70+
- name: Download Artifacts
71+
uses: actions/download-artifact@v4
72+
with:
73+
path: artifacts
74+
75+
- name: Download event file
76+
uses: actions/download-artifact@v4
77+
with:
78+
run-id: ${{ github.event.workflow_run.id }}
79+
path: artifacts
80+
github-token: ${{ github.token }}
81+
82+
- name: "List files"
83+
run: |
84+
echo $GITHUB_WORKSPACE
85+
ls -R $GITHUB_WORKSPACE
86+
87+
- name: Publish Test Results
88+
uses: EnricoMi/publish-unit-test-result-action@v2
89+
with:
90+
commit: ${{ github.event.workflow_run.head_sha }}
91+
event_file: artifacts/Event File/event.json
92+
event_name: ${{ github.event.workflow_run.event }}
93+
files: "${{ github.workspace }}/artifacts/**/*.xml"
94+
95+
- name: Prepare PR comment
96+
id: pr_comment_prep
97+
run: |
98+
echo "## Test jobs for commit ${{ github.event.workflow_run.head_sha }}" > pr-comment.txt
99+
for json_file in $(find ${{ github.workspace }} -name "test-job-*.json")
100+
do
101+
DEVICE_TYPE=$(cat "$json_file" | jq -r ".requested_device_type")
102+
URL=$(cat "$json_file" | jq -r ".url")
103+
JOB_ID=$(cat "$json_file" | jq -r ".id")
104+
echo " * [Job $JOB_ID on $DEVICE_TYPE]($URL)"
105+
echo " * [Job $JOB_ID on $DEVICE_TYPE]($URL)" >> pr-comment.txt
106+
done
107+
PR_NUMBER=$(cat "artifacts/Event File/event.json" | jq -r ".number")
108+
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
109+
110+
- name: Comment on PR
111+
uses: thollander/actions-comment-pull-request@v3
112+
with:
113+
file-path: pr-comment.txt
114+
pr-number: ${{ steps.pr_comment_prep.outputs.pr_number }}

.github/workflows/test.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
url:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
prepare-job-list:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
jobmatrix: ${{ steps.listjobs.outputs.jobmatrix }}
15+
steps:
16+
- name: Clone repository
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
- name: Print trigger
21+
run: |
22+
echo "Triggered by ${{ github.event_name }}"
23+
echo "Build URL: ${{ inputs.url }}"
24+
- name: "List jobs"
25+
id: listjobs
26+
run: |
27+
JOBFILES=$(find ci/lava/ -name *.yaml)
28+
JOBFILES=$(echo "$JOBFILES" | sed -e "s/^/\"/" | sed -e "s/$/\",/" | tr -d "\n" | sed -e "s/.$//")
29+
JOBFILES="[${JOBFILES}]"
30+
J=$(jq -cn --argjson jobfiles "$JOBFILES" '{target: $jobfiles}')
31+
echo "jobmatrix=$J" >> $GITHUB_OUTPUT
32+
echo "Preparing testjob files"
33+
34+
submit-job:
35+
needs: prepare-job-list
36+
runs-on: ubuntu-latest
37+
strategy:
38+
fail-fast: false
39+
matrix: ${{ fromJson(needs.prepare-job-list.outputs.jobmatrix) }}
40+
steps:
41+
- name: Clone repository
42+
uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
46+
- name: "Update test definition ${{ matrix.target }}"
47+
run: |
48+
TARGET=${{ matrix.target }}
49+
FIND_PATH="${TARGET#*/}"
50+
DEVICE_TYPE_PATH="${FIND_PATH%/*}"
51+
DEVICE_TYPE="${DEVICE_TYPE_PATH#*/}"
52+
BUILD_FILE_NAME="core-image-base-${DEVICE_TYPE}.rootfs.qcomflash.tar.gz"
53+
BUILD_DOWNLOAD_URL="${{inputs.url}}/${DEVICE_TYPE}/${BUILD_FILE_NAME}"
54+
sed -i "s|{{DEVICE_TYPE}}|${DEVICE_TYPE}|g" "${{ matrix.target }}"
55+
sed -i "s|{{GITHUB_SHA}}|${GITHUB_SHA}|g" "${{ matrix.target }}"
56+
sed -i "s|{{BUILD_DOWNLOAD_URL}}|${BUILD_DOWNLOAD_URL}|g" "${{ matrix.target }}"
57+
sed -i "s|{{BUILD_FILE_NAME}}|${BUILD_FILE_NAME}|g" "${{ matrix.target }}"
58+
sed -i "s|{{GITHUB_RUN_ID}}|${GITHUB_RUN_ID}|g" "${{ matrix.target }}"
59+
cat "${{ matrix.target }}"
60+
61+
- name: Submit ${{ matrix.target }}
62+
timeout-minutes: 20
63+
uses: foundriesio/lava-action@v6
64+
with:
65+
lava_token: ${{ secrets.LAVATOKEN }}
66+
lava_url: 'lava.infra.foundries.io'
67+
job_definition: ${{ matrix.target }}
68+
wait_for_job: true
69+
fail_action_on_failure: false
70+
save_result_as_artifact: true
71+
save_job_details: true
72+
73+
publish-test-results:
74+
name: "Publish Tests Results"
75+
needs: submit-job
76+
runs-on: ubuntu-latest
77+
permissions:
78+
checks: write
79+
pull-requests: write
80+
81+
steps:
82+
- name: Download Artifacts
83+
uses: actions/download-artifact@v4
84+
with:
85+
path: artifacts
86+
87+
- name: "List files"
88+
run: |
89+
echo $GITHUB_WORKSPACE
90+
ls -R $GITHUB_WORKSPACE
91+
92+
- name: Publish Test Results
93+
uses: EnricoMi/publish-unit-test-result-action@v2
94+
with:
95+
files: "${{ github.workspace }}/artifacts/**/*.xml"
96+
97+
- name: Publish Test Job Details
98+
run: |
99+
for json_file in $(find ${{ github.workspace }} -name "test-job-*.json")
100+
do
101+
DEVICE_TYPE=$(cat "$json_file" | jq -r ".requested_device_type")
102+
URL=$(cat "$json_file" | jq -r ".url")
103+
JOB_ID=$(cat "$json_file" | jq -r ".id")
104+
echo " * [Job $JOB_ID on $DEVICE_TYPE]($URL)"
105+
echo " * [Job $JOB_ID on $DEVICE_TYPE]($URL)" >> $GITHUB_STEP_SUMMARY
106+
done
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
actions:
2+
- deploy:
3+
images:
4+
image:
5+
headers:
6+
Authentication: Q_GITHUB_TOKEN
7+
url: "{{BUILD_DOWNLOAD_URL}}"
8+
postprocess:
9+
docker:
10+
image: ghcr.io/foundriesio/lava-lmp-sign:main
11+
steps:
12+
- export IMAGE_PATH=$PWD
13+
- cp overlay*.tar.gz overlay.tar.gz
14+
- echo "OVERLAY=overlay.tar.gz" >> $IMAGE_PATH/flash.settings
15+
- echo "OVERLAY_PATH=/home/" >> $IMAGE_PATH/flash.settings
16+
- echo "ROOTFS_IMAGE=disk-ufs.img2" >> $IMAGE_PATH/flash.settings
17+
- echo "DEVICE_TYPE=debian-rb3gen2-vision-kit" >> $IMAGE_PATH/flash.settings
18+
- cat $IMAGE_PATH/flash.settings
19+
timeout:
20+
minutes: 5
21+
to: downloads
22+
- deploy:
23+
images:
24+
image:
25+
url: downloads://{{BUILD_FILE_NAME}}
26+
settings:
27+
url: downloads://flash.settings
28+
overlay:
29+
url: downloads://overlay.tar.gz
30+
timeout:
31+
minutes: 5
32+
to: flasher
33+
- boot:
34+
auto_login:
35+
login_prompt: 'login:'
36+
username: root
37+
method: minimal
38+
prompts:
39+
- root@debian
40+
timeout:
41+
minutes: 3
42+
- test:
43+
definitions:
44+
- from: git
45+
name: "smoke-test"
46+
path: automated/linux/smoke/smoke.yaml
47+
repository: https://github.com/linaro/test-definitions.git
48+
parameters:
49+
SKIP_INSTALL: "True"
50+
TESTS: "pwd, uname -a, ip a"
51+
- command:
52+
name: network_turn_on
53+
context:
54+
lava_test_results_dir: /home/lava-%s
55+
test_character_delay: 10
56+
device_type: qcs6490
57+
job_name: boot test (rb3gen2) {{GITHUB_RUN_ID}}
58+
metadata:
59+
build-commit: '{{GITHUB_SHA}}'
60+
priority: 50
61+
tags:
62+
- cambridge-lab
63+
timeouts:
64+
job:
65+
minutes: 15
66+
visibility: public

0 commit comments

Comments
 (0)