Skip to content

Commit f0f637a

Browse files
committed
ci test
1 parent ca0cfca commit f0f637a

2 files changed

Lines changed: 77 additions & 90 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Prepare zenv native container
2+
description: Prepare a GitHub native job container to run zenv project commands.
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Configure zenv environment
7+
shell: bash
8+
run: |
9+
set -euo pipefail
10+
11+
project_root="${GITHUB_WORKSPACE:-${PWD}}"
12+
git config --global --add safe.directory "${project_root}"
13+
14+
while IFS= read -r -d '' git_dir
15+
do
16+
git config --global --add safe.directory "$(dirname "${git_dir}")"
17+
done < <(find "${ZEPHYR_WS}" -name .git -prune -print0)
18+
19+
source "${ZEPHYR_WS}/.venv/bin/activate"
20+
21+
echo "ZENV_PROJECT_ROOT=${project_root}" >> "${GITHUB_ENV}"
22+
echo "CCACHE_DIR=${project_root}/ccache" >> "${GITHUB_ENV}"
23+
echo "${VIRTUAL_ENV}/bin" >> "${GITHUB_PATH}"

.github/workflows/ci.yml

Lines changed: 54 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ jobs:
7070
needs:
7171
- app-targets
7272
- devcontainer
73+
container: &native-container
74+
image: ${{ needs.devcontainer.outputs.image_name }}:${{ needs.devcontainer.outputs.image_tag }}
75+
credentials:
76+
username: ${{ github.repository_owner }}
77+
password: ${{ secrets.GITHUB_TOKEN }}
78+
options: --user root
79+
env: &native-env
80+
HOME: /home/ubuntu
81+
defaults: &native-defaults
82+
run:
83+
shell: bash
7384
strategy:
7485
fail-fast: false
7586
matrix:
@@ -86,37 +97,25 @@ jobs:
8697
uses: actions/checkout@v6
8798
with:
8899
fetch-depth: 0
89-
- name: Login to GitHub Container Registry
90-
uses: docker/login-action@v4
91-
with:
92-
registry: ghcr.io
93-
username: ${{ github.repository_owner }}
94-
password: ${{ secrets.GITHUB_TOKEN }}
100+
- name: Prepare zenv
101+
uses: ./.github/actions/prepare-zenv-native
95102
- name: Setup ccache
96103
uses: hendrikmuhs/ccache-action@v1.2
97104
with:
98105
key: app-${{ matrix.target }}
99106
restore-keys: app-${{ matrix.target }}
100107
max-size: 1G
101-
env:
102-
CCACHE_DIR: ${{ github.workspace }}/ccache
103108
- name: Build target
104-
uses: devcontainers/ci@v0.3
105-
with:
106-
configFile: .devcontainer/ci/devcontainer.json
107-
push: never
108-
runCmd: |
109-
set -euo pipefail
110-
git fetch --tags
111-
git rev-parse HEAD
112-
git status --short
113-
make TARGET=${{ matrix.target }}
114-
./scripts/copy_release_binaries.sh --build-dir=build --copy-dir=release/${{ matrix.target }}
115-
test -n "$(find release/${{ matrix.target }} -type f -print -quit)"
116-
cd release/${{ matrix.target }}
117-
python3 -m zipfile -c ../../release-${{ matrix.target }}.zip *
118-
env:
119-
OPENDECK_DEVCONTAINER_IMAGE: ${{ needs.devcontainer.outputs.image_name }}:${{ needs.devcontainer.outputs.image_tag }}
109+
run: |
110+
set -euo pipefail
111+
git fetch --tags
112+
git rev-parse HEAD
113+
git status --short
114+
make TARGET=${{ matrix.target }}
115+
./scripts/copy_release_binaries.sh --build-dir=build --copy-dir=release/${{ matrix.target }}
116+
test -n "$(find release/${{ matrix.target }} -type f -print -quit)"
117+
cd release/${{ matrix.target }}
118+
python3 -m zipfile -c ../../release-${{ matrix.target }}.zip *
120119
- name: Upload release binaries
121120
uses: actions/upload-artifact@v7
122121
with:
@@ -145,6 +144,9 @@ jobs:
145144
needs:
146145
- host-test-targets
147146
- devcontainer
147+
container: *native-container
148+
env: *native-env
149+
defaults: *native-defaults
148150
steps:
149151
- name: Free Disk Space
150152
uses: jlumbroso/free-disk-space@main
@@ -157,36 +159,27 @@ jobs:
157159
uses: actions/checkout@v6
158160
with:
159161
fetch-depth: 0
160-
- name: Login to GitHub Container Registry
161-
uses: docker/login-action@v4
162-
with:
163-
registry: ghcr.io
164-
username: ${{ github.repository_owner }}
165-
password: ${{ secrets.GITHUB_TOKEN }}
162+
- name: Prepare zenv
163+
uses: ./.github/actions/prepare-zenv-native
166164
- name: Setup ccache
167165
uses: hendrikmuhs/ccache-action@v1.2
168166
with:
169167
key: host-test-shared
170168
restore-keys: host-test-shared
171169
max-size: 1G
172-
env:
173-
CCACHE_DIR: ${{ github.workspace }}/ccache
174170
- name: Run shared host tests
175-
uses: devcontainers/ci@v0.3
176-
with:
177-
configFile: .devcontainer/ci/devcontainer.json
178-
push: never
179-
runCmd: |
180-
set -euo pipefail
181-
./scripts/bulk_build.sh --type=host-test --test-scope=shared
182-
env:
183-
OPENDECK_DEVCONTAINER_IMAGE: ${{ needs.devcontainer.outputs.image_name }}:${{ needs.devcontainer.outputs.image_tag }}
171+
run: |
172+
set -euo pipefail
173+
./scripts/bulk_build.sh --type=host-test --test-scope=shared
184174
host-test-target:
185175
name: Tests (${{ matrix.target }})
186176
runs-on: ubuntu-latest
187177
needs:
188178
- host-test-targets
189179
- devcontainer
180+
container: *native-container
181+
env: *native-env
182+
defaults: *native-defaults
190183
strategy:
191184
fail-fast: false
192185
matrix:
@@ -203,55 +196,35 @@ jobs:
203196
uses: actions/checkout@v6
204197
with:
205198
fetch-depth: 0
206-
- name: Login to GitHub Container Registry
207-
uses: docker/login-action@v4
208-
with:
209-
registry: ghcr.io
210-
username: ${{ github.repository_owner }}
211-
password: ${{ secrets.GITHUB_TOKEN }}
199+
- name: Prepare zenv
200+
uses: ./.github/actions/prepare-zenv-native
212201
- name: Setup ccache
213202
uses: hendrikmuhs/ccache-action@v1.2
214203
with:
215204
key: host-test-${{ matrix.target }}
216205
restore-keys: host-test-${{ matrix.target }}
217206
max-size: 1G
218-
env:
219-
CCACHE_DIR: ${{ github.workspace }}/ccache
220207
- name: Run host test
221-
uses: devcontainers/ci@v0.3
222-
with:
223-
configFile: .devcontainer/ci/devcontainer.json
224-
push: never
225-
runCmd: |
226-
set -euo pipefail
227-
make configure-app TARGET=${{ matrix.target }}
228-
./scripts/bulk_build.sh --type=host-test --test-scope=preset --test-target=${{ matrix.target }}
229-
env:
230-
OPENDECK_DEVCONTAINER_IMAGE: ${{ needs.devcontainer.outputs.image_name }}:${{ needs.devcontainer.outputs.image_tag }}
208+
run: |
209+
set -euo pipefail
210+
make configure-app TARGET=${{ matrix.target }}
211+
./scripts/bulk_build.sh --type=host-test --test-scope=preset --test-target=${{ matrix.target }}
231212
format:
232213
name: Code formatting
233214
runs-on: ubuntu-latest
234215
needs: devcontainer
216+
container: *native-container
217+
env: *native-env
218+
defaults: *native-defaults
235219
steps:
236220
- name: Pull the repository
237221
uses: actions/checkout@v6
238222
with:
239223
fetch-depth: 0
240-
- name: Login to GitHub Container Registry
241-
uses: docker/login-action@v4
242-
with:
243-
registry: ghcr.io
244-
username: ${{ github.repository_owner }}
245-
password: ${{ secrets.GITHUB_TOKEN }}
224+
- name: Prepare zenv
225+
uses: ./.github/actions/prepare-zenv-native
246226
- name: Check formatting
247-
uses: devcontainers/ci@v0.3
248-
with:
249-
configFile: .devcontainer/ci/devcontainer.json
250-
push: never
251-
runCmd: |
252-
make format
253-
env:
254-
OPENDECK_DEVCONTAINER_IMAGE: ${{ needs.devcontainer.outputs.image_name }}:${{ needs.devcontainer.outputs.image_tag }}
227+
run: make format
255228
lint-targets:
256229
name: Lint targets
257230
runs-on: ubuntu-latest
@@ -274,6 +247,9 @@ jobs:
274247
needs:
275248
- lint-targets
276249
- devcontainer
250+
container: *native-container
251+
env: *native-env
252+
defaults: *native-defaults
277253
strategy:
278254
fail-fast: false
279255
matrix:
@@ -290,27 +266,15 @@ jobs:
290266
uses: actions/checkout@v6
291267
with:
292268
fetch-depth: 0
293-
- name: Login to GitHub Container Registry
294-
uses: docker/login-action@v4
295-
with:
296-
registry: ghcr.io
297-
username: ${{ github.repository_owner }}
298-
password: ${{ secrets.GITHUB_TOKEN }}
269+
- name: Prepare zenv
270+
uses: ./.github/actions/prepare-zenv-native
299271
- name: Setup ccache
300272
uses: hendrikmuhs/ccache-action@v1.2
301273
with:
302274
key: lint-${{ matrix.target }}
303275
restore-keys: lint-${{ matrix.target }}
304276
max-size: 1G
305-
env:
306-
CCACHE_DIR: ${{ github.workspace }}/ccache
307277
- name: Run lint
308-
uses: devcontainers/ci@v0.3
309-
with:
310-
configFile: .devcontainer/ci/devcontainer.json
311-
push: never
312-
runCmd: |
313-
set -euo pipefail
314-
make CHECK=1 TARGET=${{ matrix.target }}
315-
env:
316-
OPENDECK_DEVCONTAINER_IMAGE: ${{ needs.devcontainer.outputs.image_name }}:${{ needs.devcontainer.outputs.image_tag }}
278+
run: |
279+
set -euo pipefail
280+
make CHECK=1 TARGET=${{ matrix.target }}

0 commit comments

Comments
 (0)