Skip to content

Commit 21e721d

Browse files
committed
test: Run unit test *once* not once for each build platform
1 parent 6dc7f6e commit 21e721d

4 files changed

Lines changed: 127 additions & 9 deletions

File tree

.github/workflows/build.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,6 @@ jobs:
133133
podman rm -af || true
134134
pkill -9 -f rootlessport || true
135135
136-
- name: Unit Test ${{ env.TARGET }}
137-
run: |
138-
make test-unit
139-
140136
- name: Prepare parallel build
141137
id: parallel
142138
run: |

.github/workflows/trigger.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,29 @@ jobs:
5050
echo "aarch64_target=aarch64" >> $GITHUB_OUTPUT
5151
echo "arm_target=arm" >> $GITHUB_OUTPUT
5252
fi
53+
unit-test:
54+
needs: check-trigger
55+
uses: ./.github/workflows/unit-test.yml
56+
with:
57+
name: "infix"
58+
target: ${{ needs.check-trigger.outputs.x86_64_target }}
5359

5460
build-x86_64:
55-
needs: check-trigger
61+
needs: [check-trigger, unit-test]
5662
uses: ./.github/workflows/build.yml
5763
with:
5864
name: "infix"
5965
target: ${{ needs.check-trigger.outputs.x86_64_target }}
6066

6167
build-aarch64:
62-
needs: check-trigger
68+
needs: [check-trigger, unit-test]
6369
uses: ./.github/workflows/build.yml
6470
with:
6571
name: "infix"
6672
target: ${{ needs.check-trigger.outputs.aarch64_target }}
6773

6874
build-arm:
69-
needs: check-trigger
75+
needs: [check-trigger, unit-test]
7076
uses: ./.github/workflows/build.yml
7177
with:
7278
name: "infix"

.github/workflows/unit-test.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: unit-test
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
target:
7+
description: "Build target (e.g. aarch64 or aarch64_minimal)"
8+
default: "x86_64"
9+
type: string
10+
parallel:
11+
description: 'Massive parallel build of each image'
12+
default: true
13+
type: boolean
14+
name:
15+
description: "Name (for spin overrides)"
16+
default: "infix"
17+
type: string
18+
infix_repo:
19+
description: 'Repo to checkout (for spin overrides)'
20+
default: kernelkit/infix
21+
type: string
22+
infix_branch:
23+
description: 'Branch/tag/commit to checkout (for spin overrides)'
24+
default: ''
25+
type: string
26+
27+
workflow_call:
28+
inputs:
29+
target:
30+
required: true
31+
type: string
32+
name:
33+
required: true
34+
type: string
35+
infix_repo:
36+
required: false
37+
type: string
38+
default: kernelkit/infix
39+
infix_branch:
40+
required: false
41+
type: string
42+
default: ''
43+
description: 'Branch/tag/commit to checkout (for spin overrides). Defaults to github.ref if not specified'
44+
parallel:
45+
required: false
46+
type: boolean
47+
default: true
48+
pre_build_script:
49+
required: false
50+
type: string
51+
default: ''
52+
description: 'Optional script to run after checkout (for spin customization)'
53+
secrets:
54+
CHECKOUT_TOKEN:
55+
required: false
56+
description: 'Token for cross-repository access'
57+
58+
env:
59+
NAME: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.name || inputs.name }}
60+
TARGET: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target || inputs.target }}
61+
INFIX_REPO: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.infix_repo || inputs.infix_repo }}
62+
INFIX_BRANCH: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.infix_branch || inputs.infix_branch }}
63+
64+
jobs:
65+
unit-tests:
66+
name: Build ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.name || inputs.name }} ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target || inputs.target }}
67+
runs-on: [ self-hosted, latest ]
68+
env:
69+
PARALLEL: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.parallel == 'true' || github.event_name != 'workflow_dispatch' && inputs.parallel == true }}
70+
strategy:
71+
fail-fast: false
72+
steps:
73+
- name: Cleanup Build Folder
74+
run: |
75+
ls -la ./
76+
rm -rf ./* || true
77+
rm -rf ./.??* || true
78+
ls -la ./
79+
80+
- name: Checkout infix repo
81+
uses: actions/checkout@v4
82+
with:
83+
repository: ${{ env.INFIX_REPO }}
84+
ref: ${{ env.INFIX_BRANCH != '' && env.INFIX_BRANCH || github.ref }}
85+
clean: true
86+
fetch-depth: 0
87+
submodules: recursive
88+
token: ${{ secrets.CHECKOUT_TOKEN || github.token }}
89+
90+
- uses: ./.github/actions/podman-cleanup
91+
92+
- name: Run pre-build script
93+
if: ${{ inputs.pre_build_script != '' }}
94+
run: |
95+
cat > ./pre-build.sh << 'EOF'
96+
${{ inputs.pre_build_script }}
97+
EOF
98+
chmod +x ./pre-build.sh
99+
bash ./pre-build.sh
100+
101+
- uses: ./.github/actions/cache-restore
102+
with:
103+
target: ${{ env.TARGET }}
104+
105+
- name: Configure ${{ env.TARGET }}
106+
run: |
107+
make ${{ env.TARGET }}_defconfig
108+
109+
- name: Cleanup stale containers and ports
110+
run: |
111+
podman rm -af || true
112+
pkill -9 -f rootlessport || true
113+
114+
- name: Unit Test ${{ env.TARGET }}
115+
run: |
116+
make test-unit

test/case/hardware/gps_simple/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ def verify_position(target):
6666

6767

6868
with test.step("Configure GPS hardware component"):
69-
target.put_config_dict("ietf-hardware", {
69+
target.put_config_dicts({"ietf-hardware": {
7070
"hardware": {
7171
"component": [{
7272
"name": "gps0",
7373
"class": "infix-hardware:gps",
7474
"infix-hardware:gps-receiver": {}
7575
}]
7676
}
77-
})
77+
}})
7878

7979
with test.step("Verify GPS is activated"):
8080
until(lambda: gps.is_activated(target), attempts=500)

0 commit comments

Comments
 (0)