Skip to content

Commit c5d9a7c

Browse files
authored
Merge pull request #1078 from kernelkit/ci-workflow-redesign
Redesign CI to use workflow calls Signed-off-by: Joachim Wiberg <[email protected]>
2 parents d6c0d4b + 45c5885 commit c5d9a7c

File tree

4 files changed

+251
-151
lines changed

4 files changed

+251
-151
lines changed

.github/workflows/build.yml

Lines changed: 55 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,51 @@
1-
name: Bob the Builder
1+
name: Build
22

33
on:
4-
pull_request:
5-
types: [opened, synchronize, reopened, labeled]
6-
push:
7-
branches:
8-
- main
94
workflow_dispatch:
105
inputs:
11-
minimal:
12-
description: 'Build minimal defconfigs'
6+
flavor:
7+
description: 'Optional build flavor (e.g. _minimal)'
138
required: false
14-
default: true
15-
type: boolean
16-
parallell:
9+
default: ''
10+
type: string
11+
parallel:
1712
description: 'Massive parallel build of each image'
1813
required: false
1914
default: true
2015
type: boolean
16+
infix_repo:
17+
description: 'Repo to checkout (for spin overrides)'
18+
required: false
19+
default: kernelkit/infix
20+
type: string
21+
22+
23+
workflow_call:
24+
inputs:
25+
target:
26+
required: true
27+
type: string
28+
name:
29+
required: true
30+
type: string
31+
flavor:
32+
required: false
33+
type: string
34+
default: ''
35+
infix_repo:
36+
required: false
37+
type: string
38+
default: kernelkit/infix
39+
40+
env:
41+
FLV: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.flavor || inputs.flavor }}
42+
INFIX_REPO: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.infix_repo || inputs.infix_repo }}
43+
2144
jobs:
2245
build:
23-
name: Build Infix ${{ matrix.target }}
46+
name: Build ${{ inputs.name }} ${{ inputs.target }}
2447
runs-on: [ self-hosted, latest ]
2548
strategy:
26-
matrix:
27-
target: [aarch64, x86_64]
2849
fail-fast: false
2950
outputs:
3051
build_id: ${{ steps.vars.outputs.INFIX_BUILD_ID }}
@@ -36,8 +57,11 @@ jobs:
3657
rm -rf ./.??* || true
3758
ls -la ./
3859
39-
- uses: actions/checkout@v4
60+
- name: Checkout infix repo
61+
uses: actions/checkout@v4
4062
with:
63+
repository: ${{ env.INFIX_REPO }}
64+
ref: ${{ github.ref }}
4165
clean: true
4266
fetch-depth: 0
4367
submodules: recursive
@@ -55,26 +79,13 @@ jobs:
5579
"${{ github.event.number }}" "${{ github.event.pull_request.head.sha }}" \
5680
| tee -a $GITHUB_OUTPUT $GITHUB_ENV
5781
fi
58-
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
59-
if [ "${{ github.event.inputs.minimal }}" == "true" ]; then
60-
flavor="_minimal"
61-
fi
62-
else
63-
# Ensure 'release' job get the proper image when building main
64-
if [ "$GITHUB_REF_NAME" != "main" ]; then
65-
flavor="_minimal"
66-
else
67-
flavor=""
68-
fi
69-
if ${{ contains(github.event.pull_request.labels.*.name, 'ci:main') }}; then
70-
flavor=""
71-
fi
72-
fi
73-
target=${{ matrix.target }}
74-
echo "dir=infix-$target" >> $GITHUB_OUTPUT
75-
echo "tgz=infix-$target.tar.gz" >> $GITHUB_OUTPUT
76-
echo "flv=$flavor" >> $GITHUB_OUTPUT
77-
echo "Building target ${target}${flavor}_defconfig"
82+
83+
target=${{ inputs.target }}
84+
name=${{ inputs.name }}
85+
echo "dir=${name}-${target}" >> $GITHUB_OUTPUT
86+
echo "tgz=${name}-${target}.tar.gz" >> $GITHUB_OUTPUT
87+
echo "flv=$FLV" >> $GITHUB_OUTPUT
88+
echo "Building target ${target}${FLV}_defconfig"
7889
7990
- name: Restore Cache of dl/
8091
uses: actions/cache@v4
@@ -88,16 +99,16 @@ jobs:
8899
uses: actions/cache@v4
89100
with:
90101
path: .ccache/
91-
key: ccache-${{ matrix.target }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }}
102+
key: ccache-${{ inputs.target }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }}
92103
restore-keys: |
93-
ccache-${{ matrix.target }}-
104+
ccache-${{ inputs.target }}-
94105
ccache-
95106
96-
- name: Configure ${{ matrix.target }}${{ steps.vars.outputs.flv }}
107+
- name: Configure ${{ inputs.target }}${{ steps.vars.outputs.flv }}
97108
run: |
98-
make ${{ matrix.target }}${{ steps.vars.outputs.flv }}_defconfig
109+
make ${{ inputs.target }}${{ steps.vars.outputs.flv }}_defconfig
99110
100-
- name: Unit Test ${{ matrix.target }}
111+
- name: Unit Test ${{ inputs.target }}
101112
run: |
102113
make test-unit
103114
@@ -115,9 +126,9 @@ jobs:
115126
fi
116127
echo "MAKE=$MAKE" >> $GITHUB_OUTPUT
117128
118-
- name: Build ${{ matrix.target }}${{ steps.vars.outputs.flv }}
129+
- name: Build ${{ inputs.target }}${{ steps.vars.outputs.flv }}
119130
run: |
120-
echo "Building ${{ matrix.target }}${{ steps.vars.outputs.flv }}_defconfig ..."
131+
echo "Building ${{ inputs.target }}${{ steps.vars.outputs.flv }}_defconfig ..."
121132
eval "${{ steps.parallel.outputs.MAKE }}"
122133
123134
- name: Check SBOM from Build
@@ -139,7 +150,7 @@ jobs:
139150
printf "Size of output/images/: "
140151
ls -l output/images/
141152
142-
- name: Prepare ${{ matrix.target }} Artifact
153+
- name: Prepare ${{ inputs.target }} Artifact
143154
run: |
144155
cd output/
145156
mv images ${{ steps.vars.outputs.dir }}
@@ -149,111 +160,4 @@ jobs:
149160
- uses: actions/upload-artifact@v4
150161
with:
151162
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
163+
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

0 commit comments

Comments
 (0)