Skip to content

Commit 088353d

Browse files
committed
Move reusable workflows into actions
Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
1 parent 8fc58e3 commit 088353d

File tree

11 files changed

+199
-241
lines changed

11 files changed

+199
-241
lines changed

.github/actions/bench/action.yml

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,42 @@ inputs:
3232
gh_token:
3333
description: GitHub access token
3434
required: true
35+
use-nix:
36+
default: true
37+
env:
38+
SHELL: ${{ inputs.use_nix && "nix develop .#ci -c bash -e {0}" || inputs.custom_shell }}
3539
runs:
3640
using: composite
3741
steps:
38-
- name: Run benchmark
39-
shell: nix develop .#ci -c bash -e {0}
40-
run: |
41-
tests bench -c ${{ inputs.perf }} --cflags "${{ inputs.cflags }}" --arch-flags "${{ inputs.archflags }}" -v --output output.json ${{ inputs.bench_extra_args }}
42-
- name: Dump benchmark
43-
shell: bash
44-
if: ${{ inputs.store_results != 'true' }}
45-
run: |
46-
cat output.json
47-
- name: Store benchmark result
48-
if: ${{ inputs.store_results == 'true' }}
49-
uses: benchmark-action/github-action-benchmark@v1
50-
with:
51-
name: ${{ inputs.name }}
52-
tool: 'customSmallerIsBetter'
53-
output-file-path: output.json
54-
github-token: ${{ inputs.gh_token }}
55-
auto-push: true
42+
- name: Setup nix
43+
if: ${{ inputs.use_nix }}
44+
uses: ./.github/actions/setup-nix
45+
with:
46+
devShell: ci
47+
script: |
48+
ARCH=$(uname -m)
49+
cat >> $GITHUB_STEP_SUMMARY <<-EOF
50+
## Setup
51+
Architecture: $ARCH
52+
- $(uname -a)
53+
- $(nix --version)
54+
- $(astyle --version)
55+
- $(${{ matrix.target.cross_prefix }}gcc --version | grep -m1 "")
56+
- $(bash --version | grep -m1 "")
57+
58+
## CPU Info
59+
$(cat /proc/cpuinfo)
60+
EOF
61+
- name: Run benchmark
62+
shell: ${{ env.SHELL }}
63+
run: |
64+
tests bench -c ${{ inputs.perf }} --cflags "${{ inputs.cflags }}" --arch-flags "${{ inputs.archflags }}" -v --output output.json ${{ inputs.bench_extra_args }}
65+
- name: Store benchmark result
66+
if: ${{ inputs.store_results == 'true' }}
67+
uses: benchmark-action/github-action-benchmark@v1
68+
with:
69+
name: ${{ inputs.name }}
70+
tool: 'customSmallerIsBetter'
71+
output-file-path: output.json
72+
github-token: ${{ inputs.gh_token }}
73+
auto-push: true

.github/workflows/cbmc_core_reusable.yml renamed to .github/actions/cbmc/action.yml

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
name: cbmc-core-reusable
2-
on:
3-
workflow_call:
4-
inputs:
5-
runner:
6-
type: string
7-
description: Name of the runner to use
8-
cross-prefix:
9-
type: string
10-
description: Cross-compilation binary prefix, if any
11-
default: ' '
12-
jobs:
13-
cbmc:
14-
name: CBMC ${{ inputs.runner }}
15-
runs-on: ${{ inputs.runner }}
16-
defaults:
17-
run:
18-
shell: nix develop .#ci-cbmc -c bash -e {0}
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
name: CBMC
4+
description: Run CBMC proofs for MLKEM-C_AArch64
5+
6+
inputs:
7+
use_nix:
8+
description: Whether to run in the default Nix environment
9+
default: true
10+
custom_shell:
11+
description: The shell to use. Only relevant if use_nix is 'false'
12+
default: 'bash'
13+
cross-prefix:
14+
description: Binary prefix for cross compilation
15+
default: ''
16+
runs:
17+
using: composite
18+
env:
19+
SHELL:
1920
steps:
2021
- uses: actions/checkout@v4
2122
- name: Setup nix
23+
if: ${{ inputs.use_nix }}
2224
uses: ./.github/actions/setup-nix
2325
with:
2426
devShell: ci-cbmc
@@ -33,7 +35,11 @@ jobs:
3335
- $(${{ inputs.cross_prefix }}gcc --version | grep -m1 "")
3436
- $(bash --version | grep -m1 "")
3537
EOF
38+
- name: Set shell
39+
shell: bash
40+
run: echo SHELL="${{ inputs.use_nix && 'nix develop .#ci-cbmc -c bash -e {0}' || inputs.custom_shell }}" >> $GITHUB_ENV
3641
- name: Run CBMC proofs
42+
shell: ${{ env.SHELL }}
3743
run: |
3844
cd cbmc/proofs;
3945
KYBER_K=2 ./run-cbmc-proofs.py --summarize;

.github/actions/functest/action.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ name: Functional tests
44
description: Run functional tests for MLKEM-C_AArch64
55

66
inputs:
7+
use_nix:
8+
description: Whether to run in the default Nix environment
9+
default: true
710
cflags:
811
description: CFLAGS to pass to compilation
912
default: ''
@@ -13,17 +16,36 @@ inputs:
1316
runs:
1417
using: composite
1518
steps:
19+
- name: Setup nix
20+
uses: ./.github/actions/setup-nix
21+
if: ${{ inputs.use_nix }}
22+
with:
23+
devShell: ci
24+
script: |
25+
ARCH=$(uname -m)
26+
cat >> $GITHUB_STEP_SUMMARY <<-EOF
27+
## Setup
28+
Architecture: $ARCH
29+
- $(uname -a)
30+
- $(nix --version)
31+
- $(astyle --version)
32+
- $(${{ inputs.cross-prefix }}gcc --version | grep -m1 "")
33+
- $(bash --version | grep -m1 "")
34+
EOF
35+
- name: Set shell
36+
shell: bash
37+
run: echo SHELL="${{ inputs.use_nix && 'nix develop .#ci -c bash -e {0}' || inputs.custom_shell }}" >> $GITHUB_ENV
1638
- name: Run functional tests
1739
id: func_test
18-
shell: nix develop .#ci -c bash -e {0}
40+
shell: ${{ env.SHELL }}
1941
run: |
2042
tests func --cross-prefix=${{ inputs.cross-prefix }} --cflags ${{ inputs.cflags }} -v
2143
- name: Run KAT tests
2244
if: |
2345
success()
2446
|| steps.func_test.conclusion == 'failure'
2547
id: kat_test
26-
shell: nix develop .#ci -c bash -e {0}
48+
shell: ${{ env.SHELL }}
2749
run: |
2850
tests kat --cross-prefix=${{ inputs.cross-prefix }} --cflags ${{ inputs.cflags }} -v
2951
- name: Run Nistkat tests
@@ -32,6 +54,6 @@ runs:
3254
success()
3355
|| steps.func_test.conclusion == 'failure'
3456
|| steps.kat_test.conclusion == 'failure'
35-
shell: nix develop .#ci -c bash -e {0}
57+
shell: ${{ env.SHELL }}
3658
run: |
3759
tests nistkat --cross-prefix=${{ inputs.cross-prefix }} --cflags ${{ inputs.cflags }} -v

.github/actions/lint/action.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
name: Lint
4+
description: Lint MLKEM-C_AArch64
5+
6+
inputs:
7+
use_nix:
8+
description: Whether to run in the default Nix environment
9+
default: true
10+
custom_shell:
11+
description: The shell to use. Only relevant if use_nix is 'false'
12+
default: 'bash'
13+
cross-prefix:
14+
description: Binary prefix for cross compilation
15+
default: ''
16+
runs:
17+
using: composite
18+
steps:
19+
- name: Setup nix
20+
if: ${{ inputs.use_nix }}
21+
uses: ./.github/actions/setup-nix
22+
with:
23+
devShell: ci-linter
24+
script: |
25+
cat >> $GITHUB_STEP_SUMMARY << EOF
26+
## Setup
27+
Architecture: $(uname -m)
28+
- $(uname -a)
29+
- $(nix --version)
30+
- $(astyle --version)
31+
- $(${{ matrix.target.cross-prefix }}gcc --version | grep -m1 "")
32+
- $(bash --version | grep -m1 "")
33+
EOF
34+
- name: Set shell
35+
shell: bash
36+
run: echo SHELL="${{ inputs.use_nix && 'nix develop .#ci-linter -c bash -e {0}' || inputs.custom_shell }}" >> $GITHUB_ENV
37+
- name: Run CBMC proofs
38+
shell: ${{ env.SHELL }}
39+
run: |
40+
echo "## Lint & Checks" >> $GITHUB_STEP_SUMMARY
41+
lint

.github/workflows/bench.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ jobs:
3232
archflags: "-mcpu=cortex-a55 -march=armv8.2-a"
3333
cflags: "-static -DFORCE_AARCH64"
3434
bench_extra_args: -w exec-on-a55
35-
uses: ./.github/workflows/bench_core_reusable.yml
3635
if: github.repository_owner == 'pq-code-package' && (github.event.label.name == 'benchmark' || github.ref == 'refs/heads/main')
37-
with:
38-
runner: self-hosted-${{ matrix.target.system }}
39-
name: ${{ matrix.target.name }}
40-
cflags: ${{ matrix.target.cflags }}
41-
archflags: ${{ matrix.target.archflags }}
42-
perf: ${{ matrix.target.bench_pmu }}
43-
store_results: ${{ github.repository_owner == 'pq-code-package' && github.ref == 'refs/heads/main' }}
44-
bench_extra_args: ${{ matrix.target.bench_extra_args }}
45-
secrets:
46-
inherit
36+
steps:
37+
- uses: actions/checkout@v4
38+
- uses: ./.github/actions/bench
39+
with:
40+
runner: self-hosted-${{ matrix.target.system }}
41+
name: ${{ matrix.target.name }}
42+
cflags: ${{ matrix.target.cflags }}
43+
archflags: ${{ matrix.target.archflags }}
44+
perf: ${{ matrix.target.bench_pmu }}
45+
store_results: ${{ github.repository_owner == 'pq-code-package' && github.ref == 'refs/heads/main' }}
46+
bench_extra_args: ${{ matrix.target.bench_extra_args }}
47+
gh_token: ${{ secrets.AWS_GITHUB_TOKEN }}

.github/workflows/bench_core_reusable.yml

Lines changed: 0 additions & 69 deletions
This file was deleted.

.github/workflows/bench_ec2_reusable.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,19 @@ jobs:
7373
bench:
7474
name: Bench ${{ inputs.name }}
7575
needs: start-ec2-runner # required to start the main job when the runner is ready
76-
uses: ./.github/workflows/bench_core_reusable.yml
77-
with:
78-
runner: ${{ needs.start-ec2-runner.outputs.label }}
79-
name: ${{ inputs.name }}
80-
cflags: ${{ inputs.cflags }}
81-
archflags: ${{ inputs.archflags }}
82-
perf: PERF
83-
store_results: ${{ inputs.store_results }}
84-
bench_extra_args: ${{ inputs.bench_extra_args }}
85-
secrets: inherit
76+
steps:
77+
- uses: actions/checkout@v4
78+
- uses: ./.github/actions/bench
79+
with:
80+
use-nix: true
81+
runner: ${{ needs.start-ec2-runner.outputs.label }}
82+
name: ${{ inputs.name }}
83+
cflags: ${{ inputs.cflags }}
84+
archflags: ${{ inputs.archflags }}
85+
perf: PERF
86+
store_results: ${{ inputs.store_results }}
87+
bench_extra_args: ${{ inputs.bench_extra_args }}
88+
gh_token: ${{ secrets.AWS_GITHUB_TOKEN }}
8689
stop-ec2-runner:
8790
name: Stop ${{ github.event.inputs.name }} (${{ github.event.inputs.ec2_instance_type }})
8891
permissions:

.github/workflows/ci.yml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,34 @@ jobs:
3535
- runner: 'pqcp-arm64'
3636
name: 'ubuntu-latest (aarch64)'
3737
name: Functional tests (${{ matrix.target.name }})
38-
uses: ./.github/workflows/functest_core_reusable.yml
39-
with:
40-
runner: ${{ matrix.target.runner }}
41-
cflags: ${{ matrix.target.cflags }}
42-
cross-prefix: ${{ matrix.target.cross-prefix }}
38+
runs-on: ${{ matrix.target.runner }}
39+
steps:
40+
- uses: actions/checkout@v4
41+
- uses: ./.github/actions/functest
42+
with:
43+
use-nix: true
44+
cflags: ${{ matrix.target.cflags }}
45+
cross-prefix: ${{ matrix.target.cross-prefix }}
4346
lint:
4447
strategy:
4548
matrix:
4649
system: [ubuntu-latest]
47-
uses: ./.github/workflows/lint_core_reusable.yml
48-
with:
49-
runner: ${{ matrix.system }}
50-
cross-prefix: "aarch64-unknown-linux-gnu-"
50+
name: Linting
51+
runs-on: ${{ matrix.target.runner }}
52+
steps:
53+
- uses: actions/checkout@v4
54+
- uses: ./.github/actions/lint
55+
with:
56+
use-nix: true
57+
cross-prefix: "aarch64-unknown-linux-gnu-"
5158
cbmc:
5259
strategy:
5360
matrix:
5461
system: [macos-latest]
55-
uses: ./.github/workflows/cbmc_core_reusable.yml
56-
with:
57-
runner: ${{ matrix.system }}
58-
cross-prefix: "aarch64-unknown-linux-gnu-"
62+
name: CBMC
63+
runs-on: ${{ matrix.target.runner }}
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: ./.github/actions/cbmc
67+
with:
68+
use-nix: true

0 commit comments

Comments
 (0)