Skip to content

Commit 6a1c73d

Browse files
committed
Test new workflows
1 parent 94865a7 commit 6a1c73d

File tree

4 files changed

+190
-45
lines changed

4 files changed

+190
-45
lines changed

.github/workflows/build.yml

Lines changed: 168 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
11
name: Bob the Builder
22

33
on:
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

1017
jobs:
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 infix/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 infix/test/9pm/report/theme.yml \
192+
-a pdf-fontsdir=infix/test/9pm/report/fonts \
193+
infix/test/.log/last/report.adoc \
194+
-o infix/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: infix/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

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ jobs:
3939
echo "pre=false" >> $GITHUB_OUTPUT
4040
fi
4141
target=${{ matrix.target }}-${ver}
42-
echo "dir=dcp-sc-28p-$target" >> $GITHUB_OUTPUT
43-
echo "tgz=dcp-sc-28p-$target.tar.gz" >> $GITHUB_OUTPUT
42+
echo "dir=vendor-example-$target" >> $GITHUB_OUTPUT
43+
echo "tgz=vendor-example-$target.tar.gz" >> $GITHUB_OUTPUT
4444
4545
- name: Restore Cache of dl/
4646
uses: actions/cache@v4

.github/workflows/sync-infix.yml

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
11
name: Automatically sync Infix
2-
32
on:
43
workflow_dispatch:
54
schedule:
65
- cron: '0 2 * * *'
76
permissions:
87
contents: write
9-
108
jobs:
11-
commit:
9+
check_changes:
1210
runs-on: [ self-hosted, latest ]
13-
if: ${{ env.SYNC_INFIX }}
11+
if: ${{ vars.SYNC_INFIX }}
1412
steps:
1513
- uses: actions/checkout@v4
1614
with:
1715
token: ${{ secrets.COMMIT_TOKEN }}
1816
fetch-depth: 0
19-
submodules: true
20-
21-
- name: Check for updates on infix and commit them
17+
clean: true
18+
submodules: recursive
19+
- name: Check for updates and commit if needed
20+
id: check_changes
2221
run: |
2322
git config --global user.name 'Wires bot'
2423
git config --global user.email '[email protected]'
25-
2624
CHANGES=0
27-
28-
if git ls-remote --heads origin latest | grep -q latest; then
29-
echo "Latest exists, checking out"
30-
git checkout latest
31-
git submodule update --init --recursive
32-
else
33-
echo "Latest does not exist, create it"
34-
git checkout -b latest
25+
if [ -z "$(git branch | grep latest)" ]; then
26+
if [ -n "$(git branch -r | grep latest)" ]; then
27+
git checkout latest
28+
else
29+
git checkout -b latest
30+
fi
31+
fi
32+
git checkout latest
33+
if [[ -n "$(git diff --exit-code origin/main)" ]]; then
34+
echo "New commits exist on main"
35+
git merge origin/main
36+
CHANGES=1
3537
fi
3638
3739
cd infix
40+
git clean -ffdx
3841
git checkout main
3942
git pull origin main
4043
cd ..

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Vendor example for infix
22

3-
This repo is an example of how to extend standard Infix
3+
This repo is an example of how to extend standard Infix.

0 commit comments

Comments
 (0)