Skip to content

Commit 4fa5da0

Browse files
committed
Add nix setup and compiler tests in CI
Tests the following compilers: - GCC: 4.8, 4.9, 7, 11, 13, 14 - Clang: 18, 19, 20 - Zig: 0.12, 0.13, 0.14 Signed-off-by: Matthias J. Kannwischer <[email protected]>
1 parent 64ee44c commit 4fa5da0

File tree

5 files changed

+229
-2
lines changed

5 files changed

+229
-2
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
2+
3+
name: Functional tests
4+
description: Run functional tests
5+
6+
inputs:
7+
nix-shell:
8+
description: Run in the specified Nix environment if exists
9+
default: "ci"
10+
custom_shell:
11+
description: The shell to use. Only relevant if no nix-shell specified
12+
default: "bash"
13+
nix-cache:
14+
description: Determine whether to enable nix cache
15+
default: 'false'
16+
nix-verbose:
17+
description: Determine wether to suppress nix log or not
18+
default: 'false'
19+
gh_token:
20+
description: Github access token to use
21+
required: true
22+
cflags:
23+
description: CFLAGS to pass to compilation
24+
default: ""
25+
26+
runs:
27+
using: composite
28+
steps:
29+
- uses: ./.github/actions/setup-nix
30+
with:
31+
devShell: ${{ inputs.nix-shell }}
32+
cache: ${{ inputs.nix-cache }}
33+
verbose: ${{ inputs.nix-verbose }}
34+
gh_token: ${{ inputs.gh_token }}
35+
- name: Functional tests
36+
shell: ${{ env.SHELL }}
37+
run: |
38+
export CFLAGS="${{ inputs.cflags }}"
39+
make clean
40+
make
41+
make test
42+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
2+
3+
name: Multiple Functional tests
4+
description: Run functional tests
5+
6+
inputs:
7+
nix-shell:
8+
description: Run in the specified Nix environment if exists
9+
default: "ci"
10+
custom_shell:
11+
description: The shell to use. Only relevant if no nix-shell specified
12+
default: "bash"
13+
nix-cache:
14+
description: Determine whether to enable nix cache
15+
default: 'false'
16+
nix-verbose:
17+
description: Determine wether to suppress nix log or not
18+
default: 'false'
19+
gh_token:
20+
description: Github access token to use
21+
required: true
22+
cflags:
23+
description: CFLAGS to pass to compilation
24+
default: ""
25+
26+
runs:
27+
using: composite
28+
steps:
29+
- name: Native Tests
30+
uses: ./.github/actions/functest
31+
with:
32+
nix-shell: ${{ inputs.nix-shell }}
33+
nix-cache: ${{ inputs.nix-cache }}
34+
nix-verbose: ${{ inputs.nix-verbose }}
35+
gh_token: ${{ inputs.gh_token }}
36+
custom_shell: ${{ inputs.custom_shell }}
37+
cflags: ${{ inputs.cflags }}

.github/workflows/all.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ jobs:
2828
id-token: 'write'
2929
uses: ./.github/workflows/nix.yml
3030
secrets: inherit
31+
ci:
32+
name: Extended
33+
permissions:
34+
contents: 'read'
35+
id-token: 'write'
36+
needs: [ base, nix ]
37+
uses: ./.github/workflows/ci.yml
38+
secrets: inherit
3139
cbmc:
3240
name: CBMC
3341
permissions:

.github/workflows/ci.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
2+
3+
name: Extended
4+
permissions:
5+
contents: read
6+
on:
7+
workflow_call:
8+
workflow_dispatch:
9+
10+
jobs:
11+
compiler_tests:
12+
name: Compiler tests (${{ matrix.compiler.name }}, ${{ matrix.target.name }}, ${{ matrix.cflags }})
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
cflags: [ "-O0", "-Os", "-O3" ]
17+
target:
18+
- runner: pqcp-arm64
19+
name: 'aarch64'
20+
archflags: ''
21+
- runner: ubuntu-latest
22+
name: 'x86_64'
23+
archflags: '-mavx2 -mbmi2 -mpopcnt -maes'
24+
- runner: macos-latest
25+
name: 'macos'
26+
archflags: ''
27+
compiler:
28+
- name: gcc-4.8
29+
shell: ci_gcc48
30+
darwin: False
31+
c17: False
32+
c23: False
33+
- name: gcc-4.9
34+
shell: ci_gcc49
35+
darwin: False
36+
c17: False
37+
c23: False
38+
- name: gcc-7
39+
shell: ci_gcc7
40+
darwin: False
41+
c17: False
42+
c23: False
43+
- name: gcc-11
44+
shell: ci_gcc11
45+
darwin: True
46+
c17: True
47+
c23: False
48+
- name: gcc-13
49+
shell: ci_gcc13
50+
darwin: True
51+
c17: True
52+
c23: False
53+
- name: gcc-14
54+
shell: ci_gcc14
55+
darwin: True
56+
c17: True
57+
c23: True
58+
- name: clang-18
59+
shell: ci_clang18
60+
darwin: True
61+
c17: True
62+
c23: True
63+
- name: clang-19
64+
shell: ci_clang19
65+
darwin: True
66+
c17: True
67+
c23: True
68+
- name: clang-20
69+
shell: ci_clang20
70+
darwin: True
71+
c17: True
72+
c23: True
73+
# CPU flags are not correctly passed to the zig assembler
74+
# https://github.com/ziglang/zig/issues/23576
75+
# We therefore only test the C backend
76+
#
77+
# We omit all examples since there is currently no way to run
78+
# only those examples not involving native code.
79+
- name: zig-0.12
80+
shell: ci_zig0_12
81+
darwin: True
82+
c17: True
83+
c23: False
84+
- name: zig-0.13
85+
shell: ci_zig0_13
86+
darwin: True
87+
c17: True
88+
c23: False
89+
- name: zig-0.14
90+
shell: ci_zig0_14
91+
darwin: True
92+
c17: True
93+
c23: True
94+
exclude:
95+
# Exclude old GCC versions from macOS and aarch64 runners
96+
- target: { name: 'macos' }
97+
compiler: { darwin: False }
98+
- target: { name: 'aarch64' }
99+
compiler: { darwin: False }
100+
runs-on: ${{ matrix.target.runner }}
101+
steps:
102+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
103+
- name: build+functest (default)
104+
uses: ./.github/actions/multi-functest
105+
with:
106+
gh_token: ${{ secrets.GITHUB_TOKEN }}
107+
nix-shell: ${{ matrix.compiler.shell }}
108+
cflags: "${{ matrix.cflags }} ${{ matrix.target.archflags }}"
109+
- name: native build+functest (C90)
110+
uses: ./.github/actions/multi-functest
111+
with:
112+
gh_token: ${{ secrets.GITHUB_TOKEN }}
113+
nix-shell: ${{ matrix.compiler.shell }}
114+
cflags: "-std=c90 ${{ matrix.cflags }} ${{ matrix.target.archflags }}"
115+
- name: native build+functest (C99)
116+
uses: ./.github/actions/multi-functest
117+
with:
118+
gh_token: ${{ secrets.GITHUB_TOKEN }}
119+
nix-shell: ${{ matrix.compiler.shell }}
120+
cflags: "-std=c99 ${{ matrix.cflags }} ${{ matrix.target.archflags }}"
121+
- name: native build+functest (C11)
122+
uses: ./.github/actions/multi-functest
123+
with:
124+
gh_token: ${{ secrets.GITHUB_TOKEN }}
125+
nix-shell: ${{ matrix.compiler.shell }}
126+
cflags: "-std=c11 ${{ matrix.cflags }} ${{ matrix.target.archflags }}"
127+
- name: native build+functest (C17)
128+
if: ${{ matrix.compiler.c17 }}
129+
uses: ./.github/actions/multi-functest
130+
with:
131+
gh_token: ${{ secrets.GITHUB_TOKEN }}
132+
nix-shell: ${{ matrix.compiler.shell }}
133+
cflags: "-std=c17 ${{ matrix.cflags }} ${{ matrix.target.archflags }}"
134+
- name: native build+functest (C23)
135+
if: ${{ matrix.compiler.c23 }}
136+
uses: ./.github/actions/multi-functest
137+
with:
138+
gh_token: ${{ secrets.GITHUB_TOKEN }}
139+
nix-shell: ${{ matrix.compiler.shell }}
140+
cflags: "-std=c23 ${{ matrix.cflags }} ${{ matrix.target.archflags }}"

flake.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
44

55
{
6-
description = "mlkem-native";
6+
description = "slhdsa-c";
77

88
inputs = {
99
nixpkgs-2405.url = "github:NixOS/nixpkgs/nixos-24.05";
@@ -58,7 +58,7 @@
5858

5959
packages.linters = util.linters;
6060
packages.cbmc = util.cbmc_pkgs;
61-
61+
6262
packages.toolchains = util.toolchains;
6363
packages.toolchains_native = util.toolchains_native;
6464
packages.toolchain_x86_64 = util.toolchain_x86_64;

0 commit comments

Comments
 (0)