Skip to content

Commit 350f2dd

Browse files
committed
.github: use workflow calls to build and test
Redesign how GH actions are triggered. This new design uses a self-trigger to start jobs which are only started via workflow_calls. The main benefit of this is to be able to start workflows from various Infix Spins without needing to duplicate the workflow files in them. Upcoming patches are intended to parameterize to allow Spins to pass different architectures, brand names and such. Signed-off-by: Richard Alpe <[email protected]>
1 parent 6d53d92 commit 350f2dd

File tree

4 files changed

+171
-126
lines changed

4 files changed

+171
-126
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
name: Bob the Builder
1+
name: Build Infix
22

33
on:
4-
pull_request:
5-
types: [opened, synchronize, reopened, labeled]
6-
push:
7-
branches:
8-
- main
94
workflow_dispatch:
105
inputs:
116
minimal:
@@ -18,13 +13,17 @@ on:
1813
required: false
1914
default: true
2015
type: boolean
16+
17+
workflow_call:
18+
inputs:
19+
target:
20+
required: true
21+
type: string
2122
jobs:
2223
build:
23-
name: Build Infix ${{ matrix.target }}
24+
name: Build Infix ${{ inputs.target }}
2425
runs-on: [ self-hosted, latest ]
2526
strategy:
26-
matrix:
27-
target: [aarch64, x86_64]
2827
fail-fast: false
2928
outputs:
3029
build_id: ${{ steps.vars.outputs.INFIX_BUILD_ID }}
@@ -70,7 +69,7 @@ jobs:
7069
flavor=""
7170
fi
7271
fi
73-
target=${{ matrix.target }}
72+
target=${{ inputs.target }}
7473
echo "dir=infix-$target" >> $GITHUB_OUTPUT
7574
echo "tgz=infix-$target.tar.gz" >> $GITHUB_OUTPUT
7675
echo "flv=$flavor" >> $GITHUB_OUTPUT
@@ -88,16 +87,16 @@ jobs:
8887
uses: actions/cache@v4
8988
with:
9089
path: .ccache/
91-
key: ccache-${{ matrix.target }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }}
90+
key: ccache-${{ inputs.target }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }}
9291
restore-keys: |
93-
ccache-${{ matrix.target }}-
92+
ccache-${{ inputs.target }}-
9493
ccache-
9594
96-
- name: Configure ${{ matrix.target }}${{ steps.vars.outputs.flv }}
95+
- name: Configure ${{ inputs.target }}${{ steps.vars.outputs.flv }}
9796
run: |
98-
make ${{ matrix.target }}${{ steps.vars.outputs.flv }}_defconfig
97+
make ${{ inputs.target }}${{ steps.vars.outputs.flv }}_defconfig
9998
100-
- name: Unit Test ${{ matrix.target }}
99+
- name: Unit Test ${{ inputs.target }}
101100
run: |
102101
make test-unit
103102
@@ -115,9 +114,9 @@ jobs:
115114
fi
116115
echo "MAKE=$MAKE" >> $GITHUB_OUTPUT
117116
118-
- name: Build ${{ matrix.target }}${{ steps.vars.outputs.flv }}
117+
- name: Build ${{ inputs.target }}${{ steps.vars.outputs.flv }}
119118
run: |
120-
echo "Building ${{ matrix.target }}${{ steps.vars.outputs.flv }}_defconfig ..."
119+
echo "Building ${{ inputs.target }}${{ steps.vars.outputs.flv }}_defconfig ..."
121120
eval "${{ steps.parallel.outputs.MAKE }}"
122121
123122
- name: Check SBOM from Build
@@ -139,7 +138,7 @@ jobs:
139138
printf "Size of output/images/: "
140139
ls -l output/images/
141140
142-
- name: Prepare ${{ matrix.target }} Artifact
141+
- name: Prepare ${{ inputs.target }} Artifact
143142
run: |
144143
cd output/
145144
mv images ${{ steps.vars.outputs.dir }}
@@ -149,111 +148,4 @@ jobs:
149148
- uses: actions/upload-artifact@v4
150149
with:
151150
path: output/${{ steps.vars.outputs.tgz }}
152-
name: artifact-${{ matrix.target }}
153-
154-
test:
155-
name: Regression Test of Infix x86_64
156-
needs: build
157-
runs-on: [ self-hosted, regression ]
158-
steps:
159-
- uses: actions/checkout@v4
160-
with:
161-
clean: true
162-
submodules: recursive
163-
164-
- name: Set Build Variables
165-
id: vars
166-
run: |
167-
if [ -n "${{ needs.build.outputs.build_id }}" ]; then
168-
echo "INFIX_BUILD_ID=${{ needs.build.outputs.build_id }}" \
169-
>>$GITHUB_ENV
170-
fi
171-
172-
if [ "$GITHUB_REF_NAME" != "main" ]; then
173-
flavor="_minimal"
174-
else
175-
flavor=""
176-
fi
177-
echo "flv=$flavor" >> $GITHUB_OUTPUT
178-
179-
- name: Configure x86_64${{ steps.vars.outputs.flv }}
180-
run: |
181-
make x86_64${{ steps.vars.outputs.flv }}_defconfig
182-
183-
- uses: actions/download-artifact@v4
184-
with:
185-
pattern: "artifact-*"
186-
merge-multiple: true
187-
188-
- name: Restore x86-64${{ steps.vars.outputs.flv }} output/
189-
run: |
190-
ls -l
191-
mkdir -p output
192-
mv infix-x86_64.tar.gz output/
193-
cd output/
194-
tar xf infix-x86_64.tar.gz
195-
ln -s infix-x86_64 images
196-
197-
- name: Regression Test x86_64${{ steps.vars.outputs.flv }}
198-
run: |
199-
make test
200-
201-
- name: Publish Test Result for x86_64${{ steps.vars.outputs.flv }}
202-
# Ensure this runs even if Regression Test fails
203-
if: always()
204-
run: cat test/.log/last/result-gh.md >> $GITHUB_STEP_SUMMARY
205-
206-
- name: Generate Test Report for x86_64${{ steps.vars.outputs.flv }}
207-
# Ensure this runs even if Regression Test fails
208-
if: always()
209-
run: |
210-
asciidoctor-pdf \
211-
--theme test/9pm/report/theme.yml \
212-
-a pdf-fontsdir=test/9pm/report/fonts \
213-
test/.log/last/report.adoc \
214-
-o test/.log/last/report.pdf
215-
216-
- name: Upload Test Report as Artifact
217-
uses: actions/upload-artifact@v4
218-
with:
219-
name: test-report
220-
path: test/.log/last/report.pdf
221-
222-
release:
223-
if: ${{github.repository_owner == 'kernelkit' && github.ref_name == 'main'}}
224-
name: Upload Latest Build
225-
needs: test
226-
runs-on: ubuntu-latest
227-
permissions:
228-
contents: write
229-
steps:
230-
- uses: actions/download-artifact@v4
231-
with:
232-
pattern: "artifact-*"
233-
merge-multiple: true
234-
235-
- name: Create checksums ...
236-
run: |
237-
for file in *.tar.gz; do
238-
sha256sum $file > $file.sha256
239-
done
240-
241-
- uses: ncipollo/release-action@v1
242-
with:
243-
allowUpdates: true
244-
omitName: true
245-
omitBody: true
246-
omitBodyDuringUpdate: true
247-
prerelease: true
248-
tag: "latest"
249-
token: ${{ secrets.GITHUB_TOKEN }}
250-
artifacts: "*.tar.gz*"
251-
252-
- name: Summary
253-
run: |
254-
cat <<EOF >> $GITHUB_STEP_SUMMARY
255-
# Latest Build Complete! :rocket:
256-
257-
For the public download links of these build artifacts, please see:
258-
<https://github.com/kernelkit/infix/releases/tag/latest>
259-
EOF
151+
name: artifact-${{ inputs.target }}

.github/workflows/publish.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Publish latest Infix
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
7+
jobs:
8+
publish:
9+
name: Upload Latest Build
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- uses: actions/download-artifact@v4
15+
with:
16+
pattern: "artifact-*"
17+
merge-multiple: true
18+
19+
- name: Create checksums ...
20+
run: |
21+
for file in *.tar.gz; do
22+
sha256sum $file > $file.sha256
23+
done
24+
25+
- uses: ncipollo/release-action@v1
26+
with:
27+
allowUpdates: true
28+
omitName: true
29+
omitBody: true
30+
omitBodyDuringUpdate: true
31+
prerelease: true
32+
tag: "latest"
33+
token: ${{ secrets.GITHUB_TOKEN }}
34+
artifacts: "*.tar.gz*"
35+
36+
- name: Summary
37+
run: |
38+
cat <<EOF >> $GITHUB_STEP_SUMMARY
39+
# Latest Build Complete! :rocket:
40+
41+
For the public download links of these build artifacts, please see:
42+
<https://github.com/kernelkit/infix/releases/tag/latest>
43+
EOF

.github/workflows/test.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Test Infix
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
inputs:
7+
target:
8+
required: true
9+
type: string
10+
11+
jobs:
12+
test:
13+
name: Regression Test of Infix x86_64
14+
runs-on: [ self-hosted, regression ]
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
clean: true
19+
submodules: recursive
20+
21+
- name: Set Build Variables
22+
id: vars
23+
run: |
24+
if [ -n "${{ needs.build.outputs.build_id }}" ]; then
25+
echo "INFIX_BUILD_ID=${{ needs.build.outputs.build_id }}" \
26+
>>$GITHUB_ENV
27+
fi
28+
29+
if [ "$GITHUB_REF_NAME" != "main" ]; then
30+
flavor="_minimal"
31+
else
32+
flavor=""
33+
fi
34+
echo "flv=$flavor" >> $GITHUB_OUTPUT
35+
36+
- name: Configure x86_64${{ steps.vars.outputs.flv }}
37+
run: |
38+
make x86_64${{ steps.vars.outputs.flv }}_defconfig
39+
40+
- uses: actions/download-artifact@v4
41+
with:
42+
pattern: "artifact-*"
43+
merge-multiple: true
44+
45+
- name: Restore x86-64${{ steps.vars.outputs.flv }} output/
46+
run: |
47+
ls -l
48+
mkdir -p output
49+
mv infix-x86_64.tar.gz output/
50+
cd output/
51+
tar xf infix-x86_64.tar.gz
52+
ln -s infix-x86_64 images
53+
54+
- name: Regression Test x86_64${{ steps.vars.outputs.flv }}
55+
run: |
56+
make test
57+
58+
- name: Publish Test Result for x86_64${{ steps.vars.outputs.flv }}
59+
# Ensure this runs even if Regression Test fails
60+
if: always()
61+
run: cat test/.log/last/result-gh.md >> $GITHUB_STEP_SUMMARY
62+
63+
- name: Generate Test Report for x86_64${{ steps.vars.outputs.flv }}
64+
# Ensure this runs even if Regression Test fails
65+
if: always()
66+
run: |
67+
asciidoctor-pdf \
68+
--theme test/9pm/report/theme.yml \
69+
-a pdf-fontsdir=test/9pm/report/fonts \
70+
test/.log/last/report.adoc \
71+
-o test/.log/last/report.pdf
72+
73+
- name: Upload Test Report as Artifact
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: test-report
77+
path: test/.log/last/report.pdf
78+

.github/workflows/trigger.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Self Trigger
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, labeled]
6+
push:
7+
branches:
8+
- main
9+
- ci-workflow-redesign
10+
workflow_dispatch:
11+
12+
jobs:
13+
build-x86_64:
14+
uses: ./.github/workflows/build.yml
15+
with:
16+
target: x86_64
17+
18+
build-aarch64:
19+
uses: ./.github/workflows/build.yml
20+
with:
21+
target: aarch64
22+
23+
test-run-x86_64:
24+
needs: build-x86_64
25+
uses: ./.github/workflows/test.yml
26+
with:
27+
target: x86_64
28+
29+
test-publish-x86_64:
30+
needs: test-run-x86_64
31+
uses: ./.github/workflows/publish.yml
32+

0 commit comments

Comments
 (0)