1+ name : Test Action
2+ inputs :
3+ docker_image :
4+ description : Docker image
5+ required : true
6+ default : kmake-image:latest
7+
8+ runs :
9+ using : " composite"
10+ steps :
11+ - name : Process presigned_urls.json
12+ id : process_urls
13+ uses : actions/github-script@v7
14+ with :
15+ script : |
16+ const fs = require('fs');
17+ const p = require('path');
18+ // Helper function to find URL by filename
19+ function findUrlByFilename(filename) {
20+ for (const [path, url] of Object.entries(data)) {
21+ if (path.endsWith(filename)) {
22+ return url;
23+ }
24+ }
25+ return null;
26+ }
27+ const filePath = p.join(process.env.GITHUB_WORKSPACE, 'presigned_urls.json');
28+ if (fs.existsSync(filePath)) {
29+ console.log("File exists");
30+ } else {
31+ console.log("File does not exist");
32+ core.setFailed(`File not found: ${filePath}`);
33+ }
34+ // Read the JSON file
35+ const data = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
36+ // Extract URLs into variables
37+ const modulesTarUrl = findUrlByFilename('modules.tar.xz');
38+ const imageUrl = findUrlByFilename('Image');
39+ const vmlinuxUrl = findUrlByFilename('vmlinux');
40+ const dtbUrl = findUrlByFilename('qcs6490-rb3gen2.dtb');
41+ // Set outputs
42+ core.setOutput('modules_url', modulesTarUrl);
43+ core.setOutput('image_url', imageUrl);
44+ core.setOutput('vmlinux_url', vmlinuxUrl);
45+ core.setOutput('dtb_url', dtbUrl);
46+ console.log(`Modules URL: ${modulesTarUrl}`);
47+ console.log(`Image URL: ${imageUrl}`);
48+ console.log(`Vmlinux URL: ${vmlinuxUrl}`);
49+ console.log(`Dtb URL: ${dtbUrl}`);
50+
51+ - name : Create metadata.json
52+ id : create_metadata
53+ shell : bash
54+ run : |
55+ echo "Creating job definition"
56+ # Create the job definition using the processed URLs
57+ cd ../job_render
58+ docker run -i --rm \
59+ --user "$(id -u):$(id -g)" \
60+ --workdir="$PWD" \
61+ -v "$(dirname "$PWD")":"$(dirname "$PWD")" \
62+ -e dtb_url="${{ steps.process_urls.outputs.dtb_url }}" \
63+ ${{ inputs.docker_image }} \
64+ jq '.artifacts["dtbs/qcom/qcs6490-rb3gen2.dtb"] = env.dtb_url' data/metadata.json > temp.json && mv temp.json data/metadata.json
65+
66+ - name : Upload metadata.json
67+ id : upload_metadata
68+ uses : ./.github/actions/aws_s3_helper
69+ with :
70+ local_file : ../job_render/data/metadata.json
71+ s3_bucket : qli-prd-kernel-gh-artifacts
72+ mode : single-upload
73+
74+ - name : Create template json
75+ shell : bash
76+ run : |
77+ echo "Creating job definition"
78+ metadata_url="${{ steps.upload_metadata.outputs.presigned_url }}"
79+ vmlinux_url="${{ steps.process_urls.outputs.vmlinux_url }}"
80+ image_url="${{ steps.process_urls.outputs.image_url }}"
81+ modules_url="${{ steps.process_urls.outputs.modules_url }}"
82+ # Create the job definition using the processed URLs
83+ cd ../job_render
84+ # using metadata_url
85+ docker run -i --rm \
86+ --user "$(id -u):$(id -g)" \
87+ --workdir="$PWD" \
88+ -v "$(dirname "$PWD")":"$(dirname "$PWD")" \
89+ -e metadata_url="$metadata_url" \
90+ ${{ inputs.docker_image }} \
91+ jq '.artifacts.metadata = env.metadata_url' data/cloudData.json > temp.json && mv temp.json data/cloudData.json
92+ # using image_url
93+ docker run -i --rm \
94+ --user "$(id -u):$(id -g)" \
95+ --workdir="$PWD" \
96+ -v "$(dirname "$PWD")":"$(dirname "$PWD")" \
97+ -e image_url="$image_url" \
98+ ${{ inputs.docker_image }} \
99+ jq '.artifacts.kernel = env.image_url' data/cloudData.json > temp.json && mv temp.json data/cloudData.json
100+ # using vmlinux_url
101+ docker run -i --rm \
102+ --user "$(id -u):$(id -g)" \
103+ --workdir="$PWD" \
104+ -v "$(dirname "$PWD")":"$(dirname "$PWD")" \
105+ -e vmlinux_url="$vmlinux_url" \
106+ ${{ inputs.docker_image }} \
107+ jq '.artifacts.vmlinux = env.vmlinux_url' data/cloudData.json > temp.json && mv temp.json data/cloudData.json
108+ # using modules_url
109+ docker run -i --rm \
110+ --user "$(id -u):$(id -g)" \
111+ --workdir="$PWD" \
112+ -v "$(dirname "$PWD")":"$(dirname "$PWD")" \
113+ -e modules_url="$modules_url" \
114+ ${{ inputs.docker_image }} \
115+ jq '.artifacts.modules = env.modules_url' data/cloudData.json > temp.json && mv temp.json data/cloudData.json
116+
117+ - name : Update firmware and ramdisk
118+ shell : bash
119+ run : |
120+ cd ../job_render
121+ ramdisk_url="$(aws s3 presign s3://qli-prd-kernel-gh-artifacts/meta-qcom/initramfs-kerneltest-full-image-qcom-armv8a.cpio.gz --expires 7600)"
122+ firmware_url="$(aws s3 presign s3://qli-prd-kernel-gh-artifacts/meta-qcom/initramfs-firmware-rb3gen2-image-qcom-armv8a.cpio.gz --expires 7600)"
123+ # using ramdisk_url
124+ docker run -i --rm \
125+ --user "$(id -u):$(id -g)" \
126+ --workdir="$PWD" \
127+ -v "$(dirname "$PWD")":"$(dirname "$PWD")" \
128+ -e ramdisk_url="$ramdisk_url" \
129+ ${{ inputs.docker_image }} \
130+ jq '.artifacts.ramdisk = env.ramdisk_url' data/cloudData.json > temp.json && mv temp.json data/cloudData.json
131+
132+ # using firmware_url
133+ docker run -i --rm \
134+ --user "$(id -u):$(id -g)" \
135+ --workdir="$PWD" \
136+ -v "$(dirname "$PWD")":"$(dirname "$PWD")" \
137+ -e firmware_url="$firmware_url" \
138+ ${{ inputs.docker_image }} \
139+ jq '.artifacts.firmware = env.firmware_url' data/cloudData.json > temp.json && mv temp.json data/cloudData.json
140+
141+ - name : Create lava_job_definition
142+ shell : bash
143+ run : |
144+ cd ../job_render
145+ mkdir renders
146+ docker run -i --rm \
147+ --user "$(id -u):$(id -g)" \
148+ --workdir="$PWD" \
149+ -v "$(dirname "$PWD")":"$(dirname "$PWD")" \
150+ ${{ inputs.docker_image }} \
151+ sh -c 'export BOOT_METHOD=fastboot && \
152+ export TARGET=qcs6490-rb3gen2 && \
153+ export TARGET_DTB=qcs6490-rb3gen2 && \
154+ python3 lava_Job_definition_generator.py --localjson ./data/cloudData.json'
0 commit comments