Skip to content

Commit 3ca4aae

Browse files
committed
add github actions ci
1 parent 9d54e06 commit 3ca4aae

File tree

3 files changed

+361
-11
lines changed

3 files changed

+361
-11
lines changed

.github/workflows/build.yml

Lines changed: 358 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,358 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches: ["scarthgap"]
6+
pull_request:
7+
branches: ["scarthgap"]
8+
schedule:
9+
- cron: "0 0 * * 5"
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
jobs:
14+
prepare_container:
15+
name: Prepare Build Container
16+
runs-on: self-hosted
17+
timeout-minutes: 30
18+
outputs:
19+
uid: ${{ steps.uid_step.outputs.userid }}
20+
gid: ${{ steps.uid_step.outputs.groupid }}
21+
steps:
22+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
23+
- uses: actions/checkout@v4
24+
25+
- name: Get user id/group
26+
id: uid_step
27+
run: |
28+
echo "userid=$(id -u)" >> "$GITHUB_OUTPUT"
29+
echo "groupid=$(id -g)" >> "$GITHUB_OUTPUT"
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
with:
34+
buildkitd-config: /etc/docker/cibuilder.toml
35+
36+
- name: Login to Docker Registry
37+
uses: docker/login-action@v3
38+
with:
39+
registry: ciserver.ci:5000
40+
username: ${{ secrets.CI_CACHE_REGISTRY_LOGIN }}
41+
password: ${{ secrets.CI_CACHE_REGISTRY_PASSWORD }}
42+
43+
- name: Build and push
44+
uses: docker/build-push-action@v5
45+
with:
46+
context: .
47+
push: true
48+
tags: ciserver.ci:5000/${{ github.repository_id }}/scarthgap:latest
49+
cache-from: type=registry,ref=ciserver.ci:5000/${{ github.repository_id }}:cache-scarthgap
50+
cache-to: type=registry,ref=ciserver.ci:5000/${{ github.repository_id }}:cache-scarthgap,mode=max
51+
file: conf/docker/Dockerfile
52+
build-args: |
53+
USER_ID=${{ steps.uid_step.outputs.userid }}
54+
GROUP_ID=${{ steps.uid_step.outputs.groupid }}
55+
56+
info:
57+
name: Collect Build Info
58+
runs-on: self-hosted
59+
timeout-minutes: 10
60+
outputs:
61+
build_date: ${{ steps.tag_step.outputs.build_date }}
62+
build_rev: ${{ steps.tag_step.outputs.build_rev }}
63+
build_ref: ${{ steps.tag_step.outputs.build_ref }}
64+
build_tag: ${{ steps.tag_step.outputs.build_date }}_${{ steps.tag_step.outputs.build_rev }}
65+
local_artifacts_path: ${{ github.repository_id }}/${{ steps.tag_step.outputs.build_date }}_${{ steps.tag_step.outputs.build_rev }}
66+
steps:
67+
- name: Generate build tags
68+
shell: bash {0}
69+
id: tag_step
70+
run: |
71+
build_date="$(date +%Y-%m-%d)"
72+
build_rev="$(echo ${GITHUB_SHA} | head -zc 7)"
73+
build_ref="${GITHUB_REF}"
74+
echo "build_date=$build_date" >> "$GITHUB_OUTPUT"
75+
echo "build_rev=$build_rev" >> "$GITHUB_OUTPUT"
76+
echo "build_ref=$build_ref" >> "$GITHUB_OUTPUT"
77+
78+
build:
79+
name: Build
80+
needs:
81+
- prepare_container
82+
- info
83+
runs-on: self-hosted
84+
timeout-minutes: 300
85+
container:
86+
image: ciserver.ci:5000/${{ github.repository_id }}/scarthgap:latest
87+
credentials:
88+
username: ${{ secrets.CI_CACHE_REGISTRY_LOGIN }}
89+
password: ${{ secrets.CI_CACHE_REGISTRY_PASSWORD }}
90+
options: --user developer
91+
env:
92+
TARGETS: |
93+
[
94+
{
95+
"machine": "lx2160a-rev2-cex6-evb",
96+
"targets": ["fsl-image-networking"],
97+
"artifacts": [
98+
"fsl-image-networking-lx2160a-rev2-cex6-evb.rootfs.manifest",
99+
"fsl-image-networking-lx2160a-rev2-cex6-evb.rootfs.wic.bmap",
100+
"fsl-image-networking-lx2160a-rev2-cex6-evb.rootfs.wic.gz",
101+
"fsl-lx2160a-cex6-evb.dtb",
102+
"Image.gz",
103+
"modules-lx2160a-rev2-cex6-evb.tgz"
104+
]
105+
},{
106+
"machine": "lx2160a-rev2-clearfog-cx",
107+
"targets": ["fsl-image-networking", "fsl-image-networking-full"],
108+
"artifacts": [
109+
"fsl-image-networking-lx2160a-rev2-clearfog-cx.rootfs.manifest",
110+
"fsl-image-networking-lx2160a-rev2-clearfog-cx.rootfs.wic.bmap",
111+
"fsl-image-networking-lx2160a-rev2-clearfog-cx.rootfs.wic.gz",
112+
"fsl-image-networking-full-lx2160a-rev2-clearfog-cx.rootfs.manifest",
113+
"fsl-image-networking-full-lx2160a-rev2-clearfog-cx.rootfs.wic.bmap",
114+
"fsl-image-networking-full-lx2160a-rev2-clearfog-cx.rootfs.wic.gz",
115+
"fsl-lx2160a-clearfog-cx.dtb",
116+
"Image.gz",
117+
"modules-lx2160a-rev2-clearfog-cx.tgz"
118+
]
119+
},{
120+
"machine": "lx2160a-rev2-half-twins",
121+
"targets": ["fsl-image-networking"],
122+
"artifacts": [
123+
"fsl-image-networking-lx2160a-rev2-half-twins.rootfs.manifest",
124+
"fsl-image-networking-lx2160a-rev2-half-twins.rootfs.wic.bmap",
125+
"fsl-image-networking-lx2160a-rev2-half-twins.rootfs.wic.gz",
126+
"fsl-lx2160a-half-twins.dtb",
127+
"Image.gz",
128+
"modules-lx2160a-rev2-half-twins.tgz"
129+
]
130+
},{
131+
"machine": "lx2160a-rev2-honeycomb",
132+
"targets": ["fsl-image-networking", "fsl-image-networking-full"],
133+
"artifacts": [
134+
"fsl-image-networking-lx2160a-rev2-honeycomb.rootfs.manifest",
135+
"fsl-image-networking-lx2160a-rev2-honeycomb.rootfs.wic.bmap",
136+
"fsl-image-networking-lx2160a-rev2-honeycomb.rootfs.wic.gz",
137+
"fsl-image-networking-full-lx2160a-rev2-honeycomb.rootfs.manifest",
138+
"fsl-image-networking-full-lx2160a-rev2-honeycomb.rootfs.wic.bmap",
139+
"fsl-image-networking-full-lx2160a-rev2-honeycomb.rootfs.wic.gz",
140+
"fsl-lx2160a-honeycomb.dtb",
141+
"Image.gz",
142+
"modules-lx2160a-rev2-honeycomb.tgz"
143+
]
144+
},{
145+
"machine": "lx2162a-rev2-clearfog",
146+
"targets": ["fsl-image-networking", "fsl-image-networking-full"],
147+
"artifacts": [
148+
"fsl-image-networking-lx2162a-rev2-clearfog.rootfs.manifest",
149+
"fsl-image-networking-lx2162a-rev2-clearfog.rootfs.wic.bmap",
150+
"fsl-image-networking-lx2162a-rev2-clearfog.rootfs.wic.gz",
151+
"fsl-image-networking-full-lx2162a-rev2-clearfog.rootfs.manifest",
152+
"fsl-image-networking-full-lx2162a-rev2-clearfog.rootfs.wic.bmap",
153+
"fsl-image-networking-full-lx2162a-rev2-clearfog.rootfs.wic.gz",
154+
"fsl-lx2162a-clearfog.dtb",
155+
"Image.gz",
156+
"modules-lx2162a-rev2-clearfog.tgz"
157+
]
158+
},{
159+
"machine": "lx216xa-solidrun",
160+
"targets": ["fsl-image-networking", "fsl-image-networking-full"],
161+
"artifacts": [
162+
"fsl-image-networking-lx216xa-solidrun.rootfs.manifest",
163+
"fsl-image-networking-lx216xa-solidrun.rootfs.wic.bmap",
164+
"fsl-image-networking-lx216xa-solidrun.rootfs.wic.gz",
165+
"fsl-image-networking-full-lx216xa-solidrun.rootfs.manifest",
166+
"fsl-image-networking-full-lx216xa-solidrun.rootfs.wic.bmap",
167+
"fsl-image-networking-full-lx216xa-solidrun.rootfs.wic.gz",
168+
"fsl-lx2160a-cex6-evb.dtb",
169+
"fsl-lx2160a-clearfog-cx.dtb",
170+
"fsl-lx2160a-half-twins.dtb",
171+
"fsl-lx2160a-honeycomb.dtb",
172+
"fsl-lx2162a-clearfog.dtb",
173+
"Image.gz",
174+
"modules-lx216xa-solidrun.tgz"
175+
]
176+
}
177+
]
178+
steps:
179+
- name: Checkout pull-request version of meta-solidrun-arm-lx2xx
180+
uses: actions/checkout@v4
181+
with:
182+
path: sources/meta-solidrun-arm-lx2xxx
183+
184+
- name: Checkout dependency layers
185+
shell: bash {0}
186+
run: |
187+
# initialise repo tool from base branch
188+
repo init -u https://github.com/SolidRun/meta-solidrun-arm-lx2xxx.git -b scarthgap -m ls-6.6.52-2.2.0-sr.xml
189+
190+
# overwrite manifest.xml with pull-request version
191+
cp sources/meta-solidrun-arm-lx2xxx/ls-6.6.52-2.2.0-sr.xml .repo/manifests/ls-6.6.52-2.2.0-sr.xml
192+
193+
# prevent repo tool from changing already downloaded pull-request version of this repository
194+
mkdir .repo/local_manifests
195+
echo "<manifest><remove-project name=\"meta-solidrun-arm-lx2xxx\"/></manifest>" > .repo/local_manifests/ignore_self.xml
196+
197+
# fetch all other layers from manifest
198+
repo sync
199+
200+
- name: Create cache dir
201+
run: mkdir -p buildcache
202+
203+
- name: Fetch cache from server
204+
uses: tespkg/actions-cache/restore@v1
205+
with:
206+
endpoint: ciserver.ci
207+
port: 9000
208+
insecure: true
209+
accessKey: ${{ secrets.CI_CACHE_MINIO_ACCESS }}
210+
secretKey: ${{ secrets.CI_CACHE_MINIO_SECRET }}
211+
bucket: cicache
212+
use-fallback: false
213+
key: ${{ github.repository }}/scarthgap
214+
path: |
215+
buildcache
216+
217+
- name: Configure
218+
shell: bash {0}
219+
run: |
220+
export EULA="1"
221+
BASEDIR=$PWD
222+
source ./setup-env -m lx2160ardb-rev2 -b build
223+
bitbake-layers add-layer $BASEDIR/sources/meta-solidrun-arm-lx2xxx
224+
echo "IMAGE_FSTYPES:append = \" wic.gz wic.bmap \""
225+
echo "# break dependency cycle with core-image-minimal used as initramfs"
226+
echo "IMAGE_FSTYPES:remove:pn-core-image-minimal = \"wic.gz wic.bmap\"" >> conf/local.conf
227+
echo "require conf/includes/ci.conf" >> conf/local.conf
228+
229+
- name: Download Sources
230+
shell: bash {0}
231+
run: |
232+
source build/SOURCE_THIS
233+
export CACHE_DIR="$GITHUB_WORKSPACE/buildcache"
234+
export BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS CACHE_DIR"
235+
236+
echo "$TARGETS" | jq -c '.[]' | while read -r item; do
237+
machine=$(echo "$item" | jq -r '.machine')
238+
targets=($(echo "$item" | jq -r '.targets[]'))
239+
240+
env MACHINE="$machine" WKS_FILE="lx2160a-$type.wks.in" bitbake -k ${targets[@]} --runall=fetch
241+
done
242+
continue-on-error: true
243+
244+
- name: Build
245+
if: ${{ !cancelled() }}
246+
id: build_step
247+
shell: bash {0}
248+
run: |
249+
source build/SOURCE_THIS
250+
export CACHE_DIR="$GITHUB_WORKSPACE/buildcache"
251+
export BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS CACHE_DIR"
252+
253+
echo "$TARGETS" | jq -c '.[]' | while read -r item; do
254+
machine=$(echo "$item" | jq -r '.machine')
255+
targets=($(echo "$item" | jq -r '.targets[]'))
256+
257+
env MACHINE="$machine" WKS_FILE="lx2160a-$type.wks.in" bitbake -k ${targets[@]}
258+
done
259+
continue-on-error: true
260+
261+
- name: Update cache on the server (build may have failed)
262+
if: ${{ !cancelled() }}
263+
uses: tespkg/actions-cache/save@v1
264+
with:
265+
endpoint: ciserver.ci
266+
port: 9000
267+
insecure: true
268+
accessKey: ${{ secrets.CI_CACHE_MINIO_ACCESS }}
269+
secretKey: ${{ secrets.CI_CACHE_MINIO_SECRET }}
270+
bucket: cicache
271+
use-fallback: false
272+
key: ${{ github.repository }}/scarthgap
273+
path: |
274+
buildcache
275+
276+
- name: Select artifacts for publishing
277+
if: ${{ (!cancelled()) && (steps.build_step.outcome == 'success') }}
278+
shell: bash -e {0}
279+
env:
280+
MACHINE: ${{ matrix.machine }}
281+
ARTIFACTS: ${{ join(matrix.publish_artifacts, ' ') }}
282+
run: |
283+
echo "$TARGETS" | jq -c '.[]' | while read -r item; do
284+
machine=$(echo "$item" | jq -r '.machine')
285+
artifacts=($(echo "$item" | jq -r '.artifacts[]'))
286+
287+
ls -lh build/tmp/deploy/images/$machine/
288+
mkdir -p deploy/$MACHINE
289+
cp -v -L ${artifacts[@]} deploy/$MACHINE/
290+
ls -lh deploy/$MACHINE/
291+
done
292+
293+
- name: Deploy to the local minio storage
294+
if: ${{ (!cancelled()) && (steps.build_step.outcome == 'success') }}
295+
uses: yakubique/minio-upload@v1.1.3
296+
with:
297+
endpoint: http://ciserver.ci:9000
298+
insecure: true
299+
access_key: ${{ secrets.CI_CACHE_MINIO_ACCESS }}
300+
secret_key: ${{ secrets.CI_CACHE_MINIO_SECRET }}
301+
bucket: cipublish
302+
source: ./deploy/
303+
"target": "/${{ needs.info.outputs.local_artifacts_path }}/"
304+
recursive: true
305+
306+
- name: Fail Late
307+
if: ${{ steps.build_step.outcome == 'failure' }}
308+
shell: bash {0}
309+
run: exit 1
310+
311+
test_images:
312+
name: Test on Hardware
313+
needs:
314+
- info
315+
- build
316+
runs-on: self-hosted
317+
timeout-minutes: 90
318+
319+
steps:
320+
- name: Generate Temporary Image Download URLs
321+
id: dl_url
322+
shell: bash {0}
323+
run: |
324+
echo "lx2162a_rev2_clearfog_fsl_image_networking_url=http://ciserver.ci:8000/cipublish/${{ needs.build.outputs.local_artifacts_path }}/lx2162a-rev2-clearfog/fsl-image-networking-lx2162a-rev2-clearfog.rootfs.wic.gz" >> "$GITHUB_OUTPUT"
325+
echo "lx2162a_rev2_clearfog_fsl_image_networking_full_url=http://ciserver.ci:8000/cipublish/${{ needs.build.outputs.local_artifacts_path }}/lx2162a-rev2-clearfog/fsl-image-networking-full-lx2162a-rev2-clearfog.rootfs.wic.gz" >> "$GITHUB_OUTPUT"
326+
327+
- name: Checkout LAVA action
328+
uses: actions/checkout@v4
329+
with:
330+
repository: SolidRun/lava-test-definitions
331+
path: .lava-action
332+
ssh-key: ${{ secrets.LAVA_ACTION_SECRET }}
333+
334+
- name: Test Images on LAVA
335+
id: submit
336+
uses: ./.lava-action/.github/actions/lava-submit
337+
with:
338+
server: 192.168.15.184
339+
port: 8001
340+
timeout: 36000
341+
jobs: |
342+
[
343+
{
344+
"device_type": "lx2162a-solidrun",
345+
"tags": [],
346+
"image_url": "${{ steps.dl_url.outputs.lx2162a_rev2_clearfog_fsl_image_networking_url }}",
347+
"description": "LX2162A Clearfog Yocto - FSL Network - meta-solidrun-armlx2xxx/${{ needs.info.outputs.build_ref }} (${{ needs.info.outputs.build_rev }})",
348+
"compression": "xz",
349+
"all_devices": false
350+
},{
351+
"device_type": "lx2162a-solidrun",
352+
"tags": [],
353+
"image_url": "${{ steps.dl_url.outputs.lx2162a_rev2_clearfog_fsl_image_networking_full_url }}",
354+
"description": "LX2162A Clearfog Yocto - FSL Network Full - meta-solidrun-armlx2xxx/${{ needs.info.outputs.build_ref }} (${{ needs.info.outputs.build_rev }})",
355+
"compression": "xz",
356+
"all_devices": false
357+
}
358+
]

conf/docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ RUN apt-get update && apt-get install -y apt-transport-https \
2222
python3-subunit mesa-common-dev patchelf \
2323
zstd liblz4-tool file locales libacl1 \
2424
tree sudo locales ca-certificates \
25-
bash icecc
25+
bash icecc zstd
2626

2727
# Install extra non-yocto build tools
28-
RUN apt-get update && apt-get install -y repo
28+
RUN apt-get update && apt-get install -y repo s3cmd jq
2929

3030
RUN locale-gen en_US.UTF-8
3131

conf/includes/ci.conf

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,4 @@ SSTATE_DIR = "${CACHE_DIR}/sstate-cache"
99
CCACHE_TOP_DIR = "${CACHE_DIR}/ccache"
1010

1111
INHERIT += "ccache"
12-
13-
# dont inherit work to prevent wic error below:
14-
# INFO: Build artifacts not found, exiting.
15-
# INFO: (Please check that the build artifacts for the machine
16-
# INFO: selected in local.conf actually exist and that they
17-
# INFO: are the correct artifacts for the image (.wks file)).
18-
# ERROR: The artifact that couldn't be found was rootfs-dir:
19-
# /__w/meta-solidrun-arm-lx2xxx/meta-solidrun-arm-lx2xxx/build_lx2160acex7-rev2/tmp/work/lx2160acex7_rev2-fsl-linux/fsl-image-networking/1.0-r0/rootfs
20-
# INHERIT += "rm_work"
12+
INHERIT += "rm_work"

0 commit comments

Comments
 (0)