Skip to content

Commit c3baf8d

Browse files
committed
ci: CI for build/test/publish container
Signed-off-by: Josh Morman <jmorman@gnuradio.org>
1 parent 5fc5f54 commit c3baf8d

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed

.github/workflows/ci.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
env:
15+
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/gr4-incubator-ci
16+
17+
jobs:
18+
qa-tests:
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 90
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Login to GHCR
30+
uses: docker/login-action@v3
31+
continue-on-error: true
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Build CI image (load for test run)
38+
uses: docker/build-push-action@v6
39+
with:
40+
context: .
41+
file: docker/Dockerfile
42+
target: ci
43+
tags: gr4-incubator-ci:local
44+
load: true
45+
push: false
46+
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
47+
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max
48+
49+
- name: Configure and build
50+
run: |
51+
docker run --rm \
52+
-v "${{ github.workspace }}:/workspaces/gr4-incubator" \
53+
-w /workspaces/gr4-incubator \
54+
gr4-incubator-ci:local bash -lc '
55+
set -euo pipefail
56+
cmake -S . -B build -G Ninja \
57+
-DENABLE_TESTING=ON \
58+
-DENABLE_EXAMPLES=ON \
59+
-DENABLE_GUI_EXAMPLES=OFF
60+
cmake --build build -j"$(nproc)"
61+
'
62+
63+
- name: Run QA tests
64+
run: |
65+
docker run --rm \
66+
-v "${{ github.workspace }}:/workspaces/gr4-incubator" \
67+
-w /workspaces/gr4-incubator \
68+
gr4-incubator-ci:local bash -lc '
69+
set -euo pipefail
70+
ctest --test-dir build --output-on-failure -R "^qa_"
71+
'
72+
73+
publish-image:
74+
runs-on: ubuntu-latest
75+
timeout-minutes: 90
76+
needs: qa-tests
77+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
78+
79+
steps:
80+
- name: Checkout
81+
uses: actions/checkout@v4
82+
83+
- name: Set up Docker Buildx
84+
uses: docker/setup-buildx-action@v3
85+
86+
- name: Login to GHCR
87+
uses: docker/login-action@v3
88+
with:
89+
registry: ghcr.io
90+
username: ${{ github.actor }}
91+
password: ${{ secrets.GITHUB_TOKEN }}
92+
93+
- name: Build and push CI image
94+
uses: docker/build-push-action@v6
95+
with:
96+
context: .
97+
file: docker/Dockerfile
98+
target: ci
99+
push: true
100+
tags: |
101+
${{ env.IMAGE_NAME }}:latest
102+
${{ env.IMAGE_NAME }}:${{ github.sha }}
103+
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
104+
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max

0 commit comments

Comments
 (0)