-
Notifications
You must be signed in to change notification settings - Fork 86
154 lines (153 loc) · 7.64 KB
/
build-test-recipe.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: build-test-recipe
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
pull_request:
jobs:
changed:
name: Get changed recipes
runs-on: ubuntu-latest
outputs:
recipes: ${{ steps.diff.outputs.recipes }}
diff: ${{ steps.diff.outputs.diff }}
release: ${{ steps.get-yocto-release-name.outputs.release }}
steps:
- uses: actions/checkout@v4
- name: Diff files and set variables
id: diff
run: |
# See https://github.community/t/check-pushed-file-changes-with-git-diff-tree-in-github-actions/17220/10
if [ $GITHUB_BASE_REF ]; then
# Pull Request
# 'github.event.before/after' and 'github.event.pull_request.base.sha' are inconsistent for PRs
# Find the commit where the PR branch was forked from the base branch
git fetch origin ${{ github.base_ref }} ${{ github.event.pull_request.head.ref }}
FORK_POINT=$( git show-branch --merge-base "origin/${{ github.base_ref }}" "origin/${{ github.event.pull_request.head.ref }}" )
LATEST_COMMIT_IN_PR=${{ github.event.pull_request.head.sha }}
export DIFF=$( git diff --name-only $FORK_POINT $LATEST_COMMIT_IN_PR )
echo "Diff between $FORK_POINT and $LATEST_COMMIT_IN_PR"
fi
echo "$DIFF"
echo "diff=$( echo "$DIFF" | tr '\n' ' ' )" >> $GITHUB_OUTPUT
- name: get yocto release name
id: get-yocto-release-name
run: |
export RELEASE=$(echo ${{github.event.pull_request.base.ref}} | cut -d- -f1)
echo "$RELEASE"
echo "release=${RELEASE:-master}" >> $GITHUB_OUTPUT
build-test:
name: Build, Test ${{ matrix.machine }} ${{ needs.changed.outputs.release }}
needs: changed
strategy:
fail-fast: false
matrix:
machine:
- qemuarm
- qemuarm64
- qemux86-64
runs-on: codebuild-${{ vars.CODEBUILD_RUNNER_NAME }}-${{ github.run_id }}-${{ github.run_attempt }}
steps:
- name: Checkout meta-aws
uses: actions/checkout@v4
with:
path: ${{ github.workspace }}/meta-aws
- name: Checkout meta-oe
uses: actions/checkout@v4
with:
repository: openembedded/meta-openembedded
path: ${{ github.workspace }}/meta-openembedded
ref: ${{ needs.changed.outputs.release }}
- name: Checkout poky
run: |
git clone git://git.yoctoproject.org/poky --single-branch ${{ github.workspace }}/poky -b ${{ needs.changed.outputs.release }}
- name: Get changed Recipes or defaults
id: recipes_to_build_test
shell: bash
run: |
echo diff:
echo ${{ needs.changed.outputs.diff }}
export RECIPES=$( echo "${{ needs.changed.outputs.diff }}" | tr ' ' '\n' | grep '\.bb.*$' | sed 's!.*/!!' | sed 's!.bb!!' | sed 's!_.*!!' | sort | uniq | sed -z $'s/\\\n/ /g')
if [ "" == "$RECIPES" ]; then
echo "No changed recipes, adding everything with a ptest to test, build"
THINGS_TO_EXCLUDE="! -name aws-lc* ! -name neo-ai-tv* ! -name corretto-17-bin* ! -name corretto-21-bin* ! -name corretto-8-bin* ! -name firecracker-bin* ! -name jailer-bin* ! -name amazon-kvs-producer-sdk-c* ! -name aws-cli-v2* "
if [ ${{ matrix.machine }} == "qemuarm" ]; then
THINGS_TO_EXCLUDE+="! -name amazon-kvs-webrtc-sdk* ! -name amazon-kvs-producer-pic*"
fi
export RECIPES=$(find meta-aws/ -name *.bb -type f \( ${THINGS_TO_EXCLUDE} \) -print | xargs grep -l 'inherit.*ptest.*'| sed 's!.*/!!' | sed 's!.bb!!' | sed 's!_.*!!' | sort | uniq | sed -z $'s/\\\n/ /g')
echo THINGS_TO_EXCLUDE: $THINGS_TO_EXCLUDE
fi
echo RECIPES to build, test: "$RECIPES"
echo "recipes=$RECIPES" >> $GITHUB_OUTPUT
- name: Run build
env:
RECIPES: ${{ steps.recipes_to_build_test.outputs.recipes }}
run: |
echo RECIPES to build: $RECIPES
chown yoctouser /sstate-cache
chown yoctouser /downloads
chown -R yoctouser .
sysctl vm.mmap_min_addr=65536
sudo RECIPES="$RECIPES" -u yoctouser bash -c '
cd ${{ github.workspace }}
source poky/oe-init-build-env build
echo QEMU_USE_KVM = \"\" >> conf/local.conf
# set to the same as core-image-ptest
echo QB_MEM = \"-m 1024\" >> conf/local.conf
# use slirp networking instead of TAP interface (require root rights)
echo QEMU_USE_SLIRP = \"1\" >> conf/local.conf
echo TEST_RUNQEMUPARAMS += \"slirp\" >> conf/local.conf
echo TEST_SERVER_IP = \"127.0.0.1\" >> conf/local.conf
echo DISTRO_FEATURES += \"ptest\" >> conf/local.conf
# this will specify what test should run when running testimage cmd - oeqa layer tests + ptests:
# Ping and SSH are not required, but do help in debugging. ptest will discover all ptest packages.
echo TEST_SUITES = \" ping ssh ptest\" >> conf/local.conf
# this will allow - running testimage cmd: bitbake core-image-minimal -c testimage
echo IMAGE_CLASSES += \"testimage\" >> conf/local.conf
cat conf/local.conf
bitbake-layers add-layer ../meta-openembedded/meta-oe
bitbake-layers add-layer ../meta-openembedded/meta-python
bitbake-layers add-layer ../meta-openembedded/meta-networking
bitbake-layers add-layer ../meta-openembedded/meta-multimedia
bitbake-layers add-layer ../meta-aws
export SSTATE_DIR=/sstate-cache
export DL_DIR=/downloads
export MACHINE=${{ matrix.machine }}
export BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS SSTATE_DIR DL_DIR"
bitbake $RECIPES -f -k | tee -a $MACHINE-build.log'
set -e
echo RECIPES to build: $RECIPES
test -e build/${{ matrix.machine }}-build.log && ! grep -A3 " failed" build/${{ matrix.machine }}-build.log
test -e build/${{ matrix.machine }}-build.log && ! grep -A3 " ERROR:" build/${{ matrix.machine }}-build.log
- name: Save ${{ matrix.machine }}-build.log
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.machine }}-build.log
path: build/${{ matrix.machine }}-build.log
- name: Run test
env:
RECIPES: ${{ steps.recipes_to_build_test.outputs.recipes }}
run: |
sudo RECIPES="$RECIPES" -u yoctouser bash -c '
cd ${{ github.workspace }}
source poky/oe-init-build-env build
# PUT = package under test
for recipe in $RECIPES; do PUT+="${recipe}-ptest "; done
echo IMAGE_INSTALL:append = \" ptest-runner ssh ${PUT}\" >> conf/local.conf
export SSTATE_DIR=/sstate-cache
export DL_DIR=/downloads
export MACHINE=${{ matrix.machine }}
export BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS SSTATE_DIR DL_DIR"
bitbake core-image-minimal
bitbake core-image-minimal -c testimage
resulttool report tmp/log/oeqa/testresults.json | tee -a ${{ matrix.machine }}-resulttool_report.txt'
set -e
echo RECIPES to test: $RECIPES
test -e build/tmp/log/oeqa/testresults.json && ! grep -B3 "\"FAILED\"" build/tmp/log/oeqa/testresults.json
- name: Save resulttool_report.txt
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.machine }}-resulttool_report.txt
path: build/${{ matrix.machine }}-resulttool_report.txt