11name : Bob the Builder
22
33on :
4- # pull_request:
5- # push:
6- # branches:
7- # - main
4+ pull_request :
5+ types : [opened, synchronize, reopened, labeled]
6+ push :
7+ branches :
8+ - main
89 workflow_dispatch :
10+ inputs :
11+ minimal :
12+ description : ' Build minimal defconfigs'
13+ required : false
14+ default : true
15+ type : boolean
916
1017jobs :
1118 build :
12- if : ${{github.ref_name == 'main' && github.event_name == 'push'}} || github.event_name == 'workflow_dispatch'
13- name : Vendor example build [${{ matrix.platform }}]
14- runs-on : [self-hosted, latest]
19+ name : Build Vendor example Infix ${{ matrix.target }}
20+ runs-on : [ self-hosted, latest ]
1521 strategy :
1622 matrix :
17- platform : [aarch64, x86_64]
23+ target : [aarch64, x86_64]
1824 fail-fast : false
25+ outputs :
26+ build_id : ${{ steps.vars.outputs.INFIX_BUILD_ID }}
1927 steps :
28+ - name : Cleanup Build Folder
29+ run : |
30+ ls -la ./
31+ rm -rf ./* || true
32+ rm -rf ./.??* || true
33+ ls -la ./
34+
2035 - uses : actions/checkout@v4
2136 with :
2237 clean : true
@@ -25,58 +40,184 @@ jobs:
2540 - name : Set Build Variables
2641 id : vars
2742 run : |
28- target=${{ matrix.platform }}
43+ if [ -n "${{ github.event.pull_request.head.sha }}" ]; then
44+ # Since PRs are built from an internally generated merge
45+ # commit, reverse lookups of PRs and/or commits from
46+ # image version information are cumbersome. Therefore:
47+ # explicitly set a build id that references both the PR
48+ # and the commit.
49+ printf "INFIX_BUILD_ID=pr%d.%.7s\n" \
50+ "${{ github.event.number }}" "${{ github.event.pull_request.head.sha }}" \
51+ | tee -a $GITHUB_OUTPUT $GITHUB_ENV
52+ fi
53+ if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
54+ if [ "${{ github.event.inputs.minimal }}" == "true" ]; then
55+ flavor="_minimal"
56+ fi
57+ else
58+ # Ensure 'release' job get the proper image when building main
59+ if [ "$GITHUB_REF_NAME" != "main" ]; then
60+ flavor="_minimal"
61+ else
62+ flavor=""
63+ fi
64+ if ${{ contains(github.event.pull_request.labels.*.name, 'ci:main') }}; then
65+ flavor=""
66+ fi
67+ fi
68+ target=${{ matrix.target }}
2969 echo "dir=vendor-example-$target" >> $GITHUB_OUTPUT
3070 echo "tgz=vendor-example-$target.tar.gz" >> $GITHUB_OUTPUT
31-
71+ echo "flv=$flavor" >> $GITHUB_OUTPUT
72+ echo "Building target ${target}${flavor}_defconfig"
3273 - name : Restore Cache of dl/
3374 uses : actions/cache@v4
3475 with :
3576 path : dl/
36- key : dl-${{ matrix.platform }}-${{ hashFiles('.git/modules/infix/refs/heads/main ', 'configs/*') }}
77+ key : dl-${{ hashFiles('.git/modules/buildroot/HEAD ', 'configs/*', 'package/*/*.hash ') }}
3778 restore-keys : |
38- dl-${{ matrix.platform }}-
3979 dl-
4080
4181 - name : Restore Cache of .ccache/
4282 uses : actions/cache@v4
4383 with :
4484 path : .ccache/
45- key : ccache-${{ matrix.platform }}-${{ hashFiles('.git/modules/infix/refs/heads/main ', 'configs/* ') }}
85+ key : ccache-${{ matrix.target }}-${{ hashFiles('.git/modules/buildroot/HEAD ', 'package/*/*.hash ') }}
4686 restore-keys : |
47- ccache-${{ matrix.platform }}-
87+ ccache-${{ matrix.target }}-
4888 ccache-
4989
50- - name : Configure & Build
90+ - name : Configure ${{ matrix.target }}${{ steps.vars.outputs.flv }}
91+ run : |
92+ make ${{ matrix.target }}${{ steps.vars.outputs.flv }}_defconfig
93+
94+ - name : Unit Test ${{ matrix.target }}
95+ run : |
96+ make test-unit
97+
98+ - name : Build ${{ matrix.target }}${{ steps.vars.outputs.flv }}
5199 run : |
52- target=${{ matrix.platform }}_vendor_example_defconfig
53- echo "Buildring $target ..."
54- make $target
100+ echo "Building ${{ matrix.target }}${{ steps.vars.outputs.flv }}_defconfig ..."
55101 make
56102
57- - name : Prepare Artifact
103+ - name : Check SBOM from Build
104+ run : |
105+ make legal-info
106+
107+ - name : Build test specification
108+ run : |
109+ make test-spec
110+
111+ - name : Resulting size of build
112+ run : |
113+ printf "Size of complete tree : "
114+ du -sh .
115+ printf "Size of output/ : "
116+ du -sh output
117+ printf "Size of dl/ : "
118+ du -sh dl
119+ printf "Size of output/images/: "
120+ ls -l output/images/
121+
122+ - name : Prepare ${{ matrix.target }} Artifact
58123 run : |
59- cd output
124+ cd output/
60125 mv images ${{ steps.vars.outputs.dir }}
61126 ln -s ${{ steps.vars.outputs.dir }} images
62127 tar chfz ${{ steps.vars.outputs.tgz }} ${{ steps.vars.outputs.dir }}
63128
64129 - uses : actions/upload-artifact@v4
65130 with :
66131 path : output/${{ steps.vars.outputs.tgz }}
67- name : artifact-${{ matrix.platform }}
132+ name : artifact-${{ matrix.target }}
133+
134+ test :
135+ name : Regression Test of Vendor example Infix x86_64
136+ needs : build
137+ runs-on : [ self-hosted, regression ]
138+ steps :
139+ - uses : actions/checkout@v4
140+ with :
141+ clean : true
142+ submodules : recursive
143+
144+ - name : Set Build Variables
145+ id : vars
146+ run : |
147+ if [ -n "${{ needs.build.outputs.build_id }}" ]; then
148+ echo "INFIX_BUILD_ID=${{ needs.build.outputs.build_id }}" \
149+ >>$GITHUB_ENV
150+ fi
151+
152+ if [ "$GITHUB_REF_NAME" != "main" ]; then
153+ flavor="_minimal"
154+ else
155+ flavor=""
156+ fi
157+ echo "flv=$flavor" >> $GITHUB_OUTPUT
158+
159+ - name : Configure x86_64${{ steps.vars.outputs.flv }}
160+ run : |
161+ make x86_64${{ steps.vars.outputs.flv }}_defconfig
162+
163+ - uses : actions/download-artifact@v4
164+ with :
165+ pattern : " artifact-*"
166+ merge-multiple : true
167+
168+ - name : Restore x86-64${{ steps.vars.outputs.flv }} output/
169+ run : |
170+ ls -l
171+ mkdir -p output
172+ mv vendor-example-x86_64.tar.gz output/
173+ cd output/
174+ tar xf vendor-example-x86_64.tar.gz
175+ ln -s vendor-example-x86_64 images
176+
177+ - name : Regression Test x86_64${{ steps.vars.outputs.flv }}
178+ run : |
179+ make test
180+
181+ - name : Publish Test Result for x86_64${{ steps.vars.outputs.flv }}
182+ # Ensure this runs even if Regression Test fails
183+ if : always()
184+ run : cat test/.log/last/result-gh.md >> $GITHUB_STEP_SUMMARY
185+
186+ - name : Generate Test Report for x86_64${{ steps.vars.outputs.flv }}
187+ # Ensure this runs even if Regression Test fails
188+ if : always()
189+ run : |
190+ asciidoctor-pdf \
191+ --theme test/9pm/report/theme.yml \
192+ -a pdf-fontsdir=test/9pm/report/fonts \
193+ test/.log/last/report.adoc \
194+ -o test/.log/last/report.pdf
195+
196+ - name : Upload Test Report as Artifact
197+ uses : actions/upload-artifact@v4
198+ with :
199+ name : test-report
200+ path : test/.log/last/report.pdf
68201
69202 release :
70- if : github.repository == 'kernelkit/vendor-example' && github.ref == 'refs/heads/main'
71- permissions : write-all
203+ if : ${{github.repository_owner == 'kernelkit' && github.ref_name == 'main'}}
72204 name : Upload Latest Build
73- needs : build
205+ needs : test
74206 runs-on : ubuntu-latest
207+ permissions :
208+ contents : write
75209 steps :
76210 - uses : actions/download-artifact@v4
77211 with :
78212 pattern : " artifact-*"
79213 merge-multiple : true
214+
215+ - name : Create checksums ...
216+ run : |
217+ for file in *.tar.gz; do
218+ sha256sum $file > $file.sha256
219+ done
220+
80221 - uses : ncipollo/release-action@v1
81222 with :
82223 allowUpdates : true
@@ -86,12 +227,13 @@ jobs:
86227 prerelease : true
87228 tag : " latest"
88229 token : ${{ secrets.GITHUB_TOKEN }}
89- artifacts : " *.tar.gz"
230+ artifacts : " *.tar.gz*"
231+
90232 - name : Summary
91233 run : |
92234 cat <<EOF >> $GITHUB_STEP_SUMMARY
93235 # Latest Build Complete! :rocket:
94-
236+
95237 For the public download links of these build artifacts, please see:
96238 <https://github.com/kernelkit/vendor-example/releases/tag/latest>
97239 EOF
0 commit comments