Skip to content

Commit 29424dc

Browse files
committed
CI: Add Docker-based compiler tests workflow
Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
1 parent 6d579fa commit 29424dc

3 files changed

Lines changed: 302 additions & 85 deletions

File tree

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Copyright (c) The mlkem-native project authors
2+
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
3+
4+
name: Compiler functional tests
5+
description: Run functional tests across C standard versions
6+
7+
inputs:
8+
cflags:
9+
description: Base CFLAGS (e.g. -O0, -Os, -O3)
10+
required: true
11+
opt:
12+
description: Whether to build opt/non-opt binaries or all (all | opt | no_opt)
13+
default: "all"
14+
examples:
15+
description: Determine whether to run examples or not
16+
default: "true"
17+
c17:
18+
description: Whether compiler supports C17
19+
default: "true"
20+
c23:
21+
description: Whether compiler supports C23
22+
default: "false"
23+
gh_token:
24+
description: Github access token to use
25+
required: true
26+
27+
runs:
28+
using: composite
29+
steps:
30+
- name: functest (${{ inputs.cflags }})
31+
uses: ./.github/actions/multi-functest
32+
with:
33+
nix-shell: ""
34+
gh_token: ${{ inputs.gh_token }}
35+
compile_mode: native
36+
func: true
37+
kat: false
38+
acvp: false
39+
examples: ${{ inputs.examples }}
40+
opt: ${{ inputs.opt }}
41+
cflags: "${{ inputs.cflags }} -DNTESTS_FUNC=10 -DNUM_RANDOM_TESTS=10 -DNUM_RANDOM_TESTS_REJ_UNIFORM=10"
42+
- name: functest (${{ inputs.cflags }}, C90)
43+
uses: ./.github/actions/multi-functest
44+
with:
45+
nix-shell: ""
46+
gh_token: ${{ inputs.gh_token }}
47+
compile_mode: native
48+
func: true
49+
kat: false
50+
acvp: false
51+
examples: ${{ inputs.examples }}
52+
opt: ${{ inputs.opt }}
53+
cflags: "-std=c90 ${{ inputs.cflags }} -DNTESTS_FUNC=10 -DNUM_RANDOM_TESTS=10 -DNUM_RANDOM_TESTS_REJ_UNIFORM=10"
54+
- name: functest (${{ inputs.cflags }}, C99)
55+
uses: ./.github/actions/multi-functest
56+
with:
57+
nix-shell: ""
58+
gh_token: ${{ inputs.gh_token }}
59+
compile_mode: native
60+
func: true
61+
kat: false
62+
acvp: false
63+
examples: ${{ inputs.examples }}
64+
opt: ${{ inputs.opt }}
65+
cflags: "-std=c99 ${{ inputs.cflags }} -DNTESTS_FUNC=10 -DNUM_RANDOM_TESTS=10 -DNUM_RANDOM_TESTS_REJ_UNIFORM=10"
66+
- name: functest (${{ inputs.cflags }}, C11)
67+
uses: ./.github/actions/multi-functest
68+
with:
69+
nix-shell: ""
70+
gh_token: ${{ inputs.gh_token }}
71+
compile_mode: native
72+
func: true
73+
kat: false
74+
acvp: false
75+
examples: ${{ inputs.examples }}
76+
opt: ${{ inputs.opt }}
77+
cflags: "-std=c11 ${{ inputs.cflags }} -DNTESTS_FUNC=10 -DNUM_RANDOM_TESTS=10 -DNUM_RANDOM_TESTS_REJ_UNIFORM=10"
78+
- name: functest (${{ inputs.cflags }}, C17)
79+
if: ${{ inputs.c17 == 'true' }}
80+
uses: ./.github/actions/multi-functest
81+
with:
82+
nix-shell: ""
83+
gh_token: ${{ inputs.gh_token }}
84+
compile_mode: native
85+
func: true
86+
kat: false
87+
acvp: false
88+
examples: ${{ inputs.examples }}
89+
opt: ${{ inputs.opt }}
90+
cflags: "-std=c17 ${{ inputs.cflags }} -DNTESTS_FUNC=10 -DNUM_RANDOM_TESTS=10 -DNUM_RANDOM_TESTS_REJ_UNIFORM=10"
91+
- name: functest (${{ inputs.cflags }}, C23)
92+
if: ${{ inputs.c23 == 'true' }}
93+
uses: ./.github/actions/multi-functest
94+
with:
95+
nix-shell: ""
96+
gh_token: ${{ inputs.gh_token }}
97+
compile_mode: native
98+
func: true
99+
kat: false
100+
acvp: false
101+
examples: ${{ inputs.examples }}
102+
opt: ${{ inputs.opt }}
103+
cflags: "-std=c23 ${{ inputs.cflags }} -DNTESTS_FUNC=10 -DNUM_RANDOM_TESTS=10 -DNUM_RANDOM_TESTS_REJ_UNIFORM=10"

.github/workflows/all.yml

Lines changed: 3 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -13,91 +13,9 @@ on:
1313
types: [ "opened", "synchronize" ]
1414

1515
jobs:
16-
base:
17-
name: Base
16+
compiler-tests:
17+
name: Compiler tests (Docker)
1818
permissions:
1919
contents: 'read'
20-
id-token: 'write'
21-
uses: ./.github/workflows/base.yml
22-
secrets: inherit
23-
lint-markdown:
24-
name: Lint Markdown
25-
permissions:
26-
contents: 'read'
27-
id-token: 'write'
28-
uses: ./.github/workflows/lint_markdown.yml
29-
nix:
30-
name: Nix
31-
permissions:
32-
actions: 'write'
33-
contents: 'read'
34-
id-token: 'write'
35-
uses: ./.github/workflows/nix.yml
36-
secrets: inherit
37-
ci:
38-
name: Extended
39-
permissions:
40-
contents: 'read'
41-
id-token: 'write'
42-
needs: [ base, nix ]
43-
uses: ./.github/workflows/ci.yml
44-
secrets: inherit
45-
cbmc:
46-
name: CBMC
47-
permissions:
48-
contents: 'read'
49-
id-token: 'write'
50-
pull-requests: 'write'
51-
needs: [ base, nix ]
52-
uses: ./.github/workflows/cbmc.yml
53-
secrets: inherit
54-
oqs_integration:
55-
name: libOQS
56-
permissions:
57-
contents: 'read'
58-
id-token: 'write'
59-
needs: [ base ]
60-
uses: ./.github/workflows/integration-liboqs.yml
61-
secrets: inherit
62-
opentitan_integration:
63-
name: OpenTitan
64-
permissions:
65-
contents: 'read'
66-
id-token: 'write'
67-
needs: [ base ]
68-
uses: ./.github/workflows/integration-opentitan.yml
69-
secrets: inherit
70-
awslc_integration:
71-
name: AWS-LC
72-
permissions:
73-
contents: 'read'
74-
id-token: 'write'
75-
needs: [ base ]
76-
uses: ./.github/workflows/integration-awslc.yml
77-
with:
78-
commit: v1.67.0
79-
secrets: inherit
80-
ct-test:
81-
name: Constant-time
82-
permissions:
83-
contents: 'read'
84-
id-token: 'write'
85-
needs: [ base, nix ]
86-
uses: ./.github/workflows/ct-tests.yml
87-
secrets: inherit
88-
slothy:
89-
name: SLOTHY
90-
permissions:
91-
contents: 'read'
92-
id-token: 'write'
93-
needs: [ base, nix ]
94-
uses: ./.github/workflows/slothy.yml
95-
secrets: inherit
96-
baremetal:
97-
name: Baremetal
98-
permissions:
99-
contents: 'read'
100-
id-token: 'write'
101-
needs: [ base ]
102-
uses: ./.github/workflows/baremetal.yml
20+
uses: ./.github/workflows/compiler-tests.yml
10321
secrets: inherit
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
# Copyright (c) The mlkem-native project authors
2+
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
3+
4+
name: Compiler tests
5+
permissions:
6+
contents: read
7+
on:
8+
workflow_call:
9+
workflow_dispatch:
10+
11+
jobs:
12+
compiler_tests:
13+
name: Compiler tests (${{ matrix.compiler.name }}, ${{ matrix.target.name }})
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
target:
18+
- runner: ubuntu-24.04-arm
19+
name: 'aarch64'
20+
- runner: ubuntu-latest
21+
name: 'x86_64'
22+
- runner: macos-latest
23+
name: 'macos'
24+
compiler:
25+
# GCC compilers
26+
# Linux: installed via ubuntu-toolchain-r PPA
27+
# macOS: installed via Homebrew
28+
- name: gcc-9
29+
type: gcc
30+
version: '9'
31+
c17: true
32+
c23: false
33+
opt: all
34+
examples: true
35+
macos: false
36+
- name: gcc-10
37+
type: gcc
38+
version: '10'
39+
c17: true
40+
c23: false
41+
opt: all
42+
examples: true
43+
macos: false
44+
- name: gcc-11
45+
type: gcc
46+
version: '11'
47+
c17: true
48+
c23: false
49+
opt: all
50+
examples: true
51+
macos: true
52+
- name: gcc-12
53+
type: gcc
54+
version: '12'
55+
c17: true
56+
c23: false
57+
opt: all
58+
examples: true
59+
macos: true
60+
- name: gcc-13
61+
type: gcc
62+
version: '13'
63+
c17: true
64+
c23: false
65+
opt: all
66+
examples: true
67+
macos: true
68+
- name: gcc-14
69+
type: gcc
70+
version: '14'
71+
c17: true
72+
c23: true
73+
opt: all
74+
examples: true
75+
macos: true
76+
# Clang compilers (installed via install-llvm-action)
77+
- name: clang-14
78+
type: clang
79+
version: '14'
80+
c17: true
81+
c23: false
82+
opt: all
83+
examples: true
84+
macos: true
85+
- name: clang-15
86+
type: clang
87+
version: '15'
88+
c17: true
89+
c23: false
90+
opt: all
91+
examples: true
92+
macos: true
93+
- name: clang-16
94+
type: clang
95+
version: '16'
96+
c17: true
97+
c23: false
98+
opt: all
99+
examples: true
100+
macos: true
101+
- name: clang-17
102+
type: clang
103+
version: '17'
104+
c17: true
105+
c23: false
106+
opt: all
107+
examples: true
108+
macos: true
109+
- name: clang-18
110+
type: clang
111+
version: '18'
112+
c17: true
113+
c23: true
114+
opt: all
115+
examples: true
116+
macos: true
117+
- name: clang-19
118+
type: clang
119+
version: '19'
120+
c17: true
121+
c23: true
122+
opt: all
123+
examples: true
124+
macos: true
125+
- name: clang-20
126+
type: clang
127+
version: '20'
128+
c17: true
129+
c23: true
130+
opt: all
131+
examples: true
132+
macos: true
133+
- name: clang-21
134+
type: clang
135+
version: '21'
136+
c17: true
137+
c23: true
138+
opt: all
139+
examples: true
140+
macos: true
141+
exclude:
142+
- target: { name: 'macos' }
143+
compiler: { macos: false }
144+
runs-on: ${{ matrix.target.runner }}
145+
steps:
146+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
147+
- name: Setup GCC (Linux)
148+
if: ${{ matrix.compiler.type == 'gcc' && runner.os == 'Linux' }}
149+
run: |
150+
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
151+
sudo apt-get update
152+
sudo apt-get install -y gcc-${{ matrix.compiler.version }}
153+
echo "CC=gcc-${{ matrix.compiler.version }}" >> $GITHUB_ENV
154+
- name: Setup GCC (macOS)
155+
if: ${{ matrix.compiler.type == 'gcc' && runner.os == 'macOS' }}
156+
run: |
157+
brew install gcc@${{ matrix.compiler.version }}
158+
echo "CC=gcc-${{ matrix.compiler.version }}" >> $GITHUB_ENV
159+
- name: Setup Clang dependencies
160+
if: ${{ matrix.compiler.type == 'clang' && runner.os == 'Linux' }}
161+
run: sudo apt-get install -y libtinfo5
162+
- name: Install Clang
163+
if: ${{ matrix.compiler.type == 'clang' }}
164+
uses: KyleMayes/install-llvm-action@v2
165+
with:
166+
version: ${{ matrix.compiler.version }}
167+
env: true
168+
- name: Compiler info
169+
run: ${{ env.CC }} --version
170+
- name: Tests (-O0)
171+
uses: ./.github/actions/compiler-functest
172+
with:
173+
cflags: "-O0"
174+
opt: ${{ matrix.compiler.opt }}
175+
examples: ${{ matrix.compiler.examples }}
176+
c17: ${{ matrix.compiler.c17 }}
177+
c23: ${{ matrix.compiler.c23 }}
178+
gh_token: ${{ secrets.GITHUB_TOKEN }}
179+
- name: Tests (-Os)
180+
uses: ./.github/actions/compiler-functest
181+
with:
182+
cflags: "-Os"
183+
opt: ${{ matrix.compiler.opt }}
184+
examples: ${{ matrix.compiler.examples }}
185+
c17: ${{ matrix.compiler.c17 }}
186+
c23: ${{ matrix.compiler.c23 }}
187+
gh_token: ${{ secrets.GITHUB_TOKEN }}
188+
- name: Tests (-O3)
189+
uses: ./.github/actions/compiler-functest
190+
with:
191+
cflags: "-O3"
192+
opt: ${{ matrix.compiler.opt }}
193+
examples: ${{ matrix.compiler.examples }}
194+
c17: ${{ matrix.compiler.c17 }}
195+
c23: ${{ matrix.compiler.c23 }}
196+
gh_token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)