Skip to content

Commit afe9350

Browse files
authored
Merge pull request #15 from mwasilew/lava-testing
workflows: Submit LAVA test jobs
2 parents 0a4d161 + 7f21524 commit afe9350

File tree

9 files changed

+394
-3
lines changed

9 files changed

+394
-3
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: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,23 @@ 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
12-
25+
schema-check:
26+
uses: ./.github/workflows/lava-schema-check.yml

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,19 @@ 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+
schema-check:
17+
uses: ./.github/workflows/lava-schema-check.yml
18+
test:
19+
uses: ./.github/workflows/test.yml
20+
needs: [build, schema-check]
21+
secrets: inherit
22+
with:
23+
url: ${{ needs.build.outputs.artifacts_url }}

.github/workflows/debos.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,17 @@ jobs:
166166
id: upload_sbom_artifacts
167167
with:
168168
path: sboms
169-
169+
- name: "Print output"
170+
env:
171+
build_url: ${{ steps.upload_artifacts.outputs.url }}
172+
run: |
173+
echo "Downloads URL: ${build_url}"
174+
echo "url=\"${build_url}\"" >> $GITHUB_OUTPUT
175+
echo "${build_url}" > build_url
176+
echo "## Download URL" >> $GITHUB_STEP_SUMMARY
177+
echo "[${build_url}](${build_url})" >> $GITHUB_STEP_SUMMARY
178+
- name: Upload build URL
179+
uses: actions/upload-artifact@v4
180+
with:
181+
name: build_url
182+
path: build_url
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Chech LAVA templates
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
schema-check:
8+
runs-on: ubuntu-latest
9+
container: lavasoftware/lava-server:2025.04
10+
steps:
11+
- name: Clone repository
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
- name: Schema check
16+
run: |
17+
DEVICE_TYPE="my-device"
18+
BUILD_FILE_NAME="build.tar.gz"
19+
BUILD_DOWNLOAD_URL="https://example.com/downloads/1"
20+
GITHUB_SHA="7e6f96ccf3e911a8a1a18accdbb91991aa0db66e"
21+
22+
find ci/lava/ -name "*.yaml" -exec sed -i "s|{{DEVICE_TYPE}}|${DEVICE_TYPE}|g" '{}' \;
23+
find ci/lava/ -name "*.yaml" -exec sed -i "s|{{GITHUB_SHA}}|${GITHUB_SHA}|g" '{}' \;
24+
find ci/lava/ -name "*.yaml" -exec sed -i "s|{{BUILD_DOWNLOAD_URL}}|${BUILD_DOWNLOAD_URL}|g" '{}' \;
25+
find ci/lava/ -name "*.yaml" -exec sed -i "s|{{BUILD_FILE_NAME}}|${BUILD_FILE_NAME}|g" '{}' \;
26+
find ci/lava/ -name "*.yaml" -exec sed -i "s|{{GITHUB_RUN_ID}}|${GITHUB_RUN_ID}|g" '{}' \;
27+
28+
python3 ci/schemacheck.py ./ci/lava/

.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)