Skip to content

Commit

Permalink
Move reusable workflows into actions
Browse files Browse the repository at this point in the history
Signed-off-by: Hanno Becker <[email protected]>
  • Loading branch information
hanno-becker committed Sep 11, 2024
1 parent 8fc58e3 commit e6ef886
Show file tree
Hide file tree
Showing 13 changed files with 271 additions and 240 deletions.
54 changes: 36 additions & 18 deletions .github/actions/bench/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,42 @@ inputs:
gh_token:
description: GitHub access token
required: true
use-nix:
default: true
env:
SHELL: ${{ inputs.use_nix && "nix develop .#ci -c bash -e {0}" || inputs.custom_shell }}
runs:
using: composite
steps:
- name: Run benchmark
shell: nix develop .#ci -c bash -e {0}
run: |
tests bench -c ${{ inputs.perf }} --cflags "${{ inputs.cflags }}" --arch-flags "${{ inputs.archflags }}" -v --output output.json ${{ inputs.bench_extra_args }}
- name: Dump benchmark
shell: bash
if: ${{ inputs.store_results != 'true' }}
run: |
cat output.json
- name: Store benchmark result
if: ${{ inputs.store_results == 'true' }}
uses: benchmark-action/github-action-benchmark@v1
with:
name: ${{ inputs.name }}
tool: 'customSmallerIsBetter'
output-file-path: output.json
github-token: ${{ inputs.gh_token }}
auto-push: true
- name: Setup nix
if: ${{ inputs.use_nix }}
uses: ./.github/actions/setup-nix
with:
devShell: ci
script: |
ARCH=$(uname -m)
cat >> $GITHUB_STEP_SUMMARY <<-EOF
## Setup
Architecture: $ARCH
- $(uname -a)
- $(nix --version)
- $(astyle --version)
- $(${{ matrix.target.cross_prefix }}gcc --version | grep -m1 "")
- $(bash --version | grep -m1 "")
## CPU Info
$(cat /proc/cpuinfo)
EOF
- name: Run benchmark
shell: ${{ env.SHELL }}
run: |
tests bench -c ${{ inputs.perf }} --cflags "${{ inputs.cflags }}" --arch-flags "${{ inputs.archflags }}" -v --output output.json ${{ inputs.bench_extra_args }}
- name: Store benchmark result
if: ${{ inputs.store_results == 'true' }}
uses: benchmark-action/github-action-benchmark@v1
with:
name: ${{ inputs.name }}
tool: 'customSmallerIsBetter'
output-file-path: output.json
github-token: ${{ inputs.gh_token }}
auto-push: true
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
name: cbmc-core-reusable
on:
workflow_call:
inputs:
runner:
type: string
description: Name of the runner to use
cross-prefix:
type: string
description: Cross-compilation binary prefix, if any
default: ' '
jobs:
cbmc:
name: CBMC ${{ inputs.runner }}
runs-on: ${{ inputs.runner }}
defaults:
run:
shell: nix develop .#ci-cbmc -c bash -e {0}
# SPDX-License-Identifier: Apache-2.0

name: CBMC
description: Run CBMC proofs for MLKEM-C_AArch64

inputs:
use_nix:
description: Whether to run in the default Nix environment
default: true
custom_shell:
description: The shell to use. Only relevant if use_nix is 'false'
default: 'bash'
cross-prefix:
description: Binary prefix for cross compilation
default: ''
runs:
using: composite
env:
SHELL:
steps:
- uses: actions/checkout@v4
- name: Setup nix
if: ${{ inputs.use_nix }}
uses: ./.github/actions/setup-nix
with:
devShell: ci-cbmc
Expand All @@ -33,7 +35,11 @@ jobs:
- $(${{ inputs.cross_prefix }}gcc --version | grep -m1 "")
- $(bash --version | grep -m1 "")
EOF
- name: Set shell
shell: bash
run: "echo SHELL=${{ inputs.use_nix && "nix develop .#ci-cbmc -c bash -e {0}" || inputs.custom_shell }}" >> $GITHUB_ENV
- name: Run CBMC proofs
shell: ${{ env.SHELL }}
run: |
cd cbmc/proofs;
KYBER_K=2 ./run-cbmc-proofs.py --summarize;
Expand Down
37 changes: 37 additions & 0 deletions .github/actions/cbmc/action.yml~
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-License-Identifier: Apache-2.0

name: Functional tests
description: Run functional tests for MLKEM-C_AArch64

inputs:
cflags:
description: CFLAGS to pass to compilation
default: ''
cross-prefix:
description: Binary prefix for cross compilation
default: ''
runs:
using: composite
steps:
- name: Run functional tests
id: func_test
shell: nix develop .#ci -c bash -e {0}
run: |
tests func --cross-prefix=${{ inputs.cross-prefix }} --cflags ${{ inputs.cflags }} -v
- name: Run KAT tests
if: |
success()
|| steps.func_test.conclusion == 'failure'
id: kat_test
shell: nix develop .#ci -c bash -e {0}
run: |
tests kat --cross-prefix=${{ inputs.cross-prefix }} --cflags ${{ inputs.cflags }} -v
- name: Run Nistkat tests
id: nistkat_test
if: |
success()
|| steps.func_test.conclusion == 'failure'
|| steps.kat_test.conclusion == 'failure'
shell: nix develop .#ci -c bash -e {0}
run: |
tests nistkat --cross-prefix=${{ inputs.cross-prefix }} --cflags ${{ inputs.cflags }} -v
27 changes: 24 additions & 3 deletions .github/actions/functest/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,47 @@ name: Functional tests
description: Run functional tests for MLKEM-C_AArch64

inputs:
use_nix:
description: Whether to run in the default Nix environment
default: true
cflags:
description: CFLAGS to pass to compilation
default: ''
cross-prefix:
description: Binary prefix for cross compilation
default: ''
env:
SHELL: ${{ inputs.use_nix && "nix develop .#ci -c bash -e {0}" || inputs.custom_shell }}
runs:
using: composite
steps:
- name: Setup nix
uses: ./.github/actions/setup-nix
if: ${{ inputs.use_nix }}
with:
devShell: ci
script: |
ARCH=$(uname -m)
cat >> $GITHUB_STEP_SUMMARY <<-EOF
## Setup
Architecture: $ARCH
- $(uname -a)
- $(nix --version)
- $(astyle --version)
- $(${{ inputs.cross-prefix }}gcc --version | grep -m1 "")
- $(bash --version | grep -m1 "")
EOF
- name: Run functional tests
id: func_test
shell: nix develop .#ci -c bash -e {0}
shell: ${{ env.SHELL }}
run: |
tests func --cross-prefix=${{ inputs.cross-prefix }} --cflags ${{ inputs.cflags }} -v
- name: Run KAT tests
if: |
success()
|| steps.func_test.conclusion == 'failure'
id: kat_test
shell: nix develop .#ci -c bash -e {0}
shell: ${{ env.SHELL }}
run: |
tests kat --cross-prefix=${{ inputs.cross-prefix }} --cflags ${{ inputs.cflags }} -v
- name: Run Nistkat tests
Expand All @@ -32,6 +53,6 @@ runs:
success()
|| steps.func_test.conclusion == 'failure'
|| steps.kat_test.conclusion == 'failure'
shell: nix develop .#ci -c bash -e {0}
shell: ${{ env.SHELL }}
run: |
tests nistkat --cross-prefix=${{ inputs.cross-prefix }} --cflags ${{ inputs.cflags }} -v
40 changes: 40 additions & 0 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# SPDX-License-Identifier: Apache-2.0

name: Lint
description: Lint MLKEM-C_AArch64

inputs:
use_nix:
description: Whether to run in the default Nix environment
default: true
custom_shell:
description: The shell to use. Only relevant if use_nix is 'false'
default: 'bash'
cross-prefix:
description: Binary prefix for cross compilation
default: ''
env:
SHELL: ${{ inputs.use_nix && "nix develop .#ci-linter -c bash -e {0}" || inputs.custom_shell }}
runs:
using: composite
steps:
- name: Setup nix
if: ${{ inputs.use_nix }}
uses: ./.github/actions/setup-nix
with:
devShell: ci-linter
script: |
cat >> $GITHUB_STEP_SUMMARY << EOF
## Setup
Architecture: $(uname -m)
- $(uname -a)
- $(nix --version)
- $(astyle --version)
- $(${{ matrix.target.cross-prefix }}gcc --version | grep -m1 "")
- $(bash --version | grep -m1 "")
EOF
- name: Run CBMC proofs
shell: ${{ env.SHELL }}
run: |
echo "## Lint & Checks" >> $GITHUB_STEP_SUMMARY
lint
37 changes: 37 additions & 0 deletions .github/actions/lint/action.yml~
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-License-Identifier: Apache-2.0

name: Functional tests
description: Run functional tests for MLKEM-C_AArch64

inputs:
cflags:
description: CFLAGS to pass to compilation
default: ''
cross-prefix:
description: Binary prefix for cross compilation
default: ''
runs:
using: composite
steps:
- name: Run functional tests
id: func_test
shell: nix develop .#ci -c bash -e {0}
run: |
tests func --cross-prefix=${{ inputs.cross-prefix }} --cflags ${{ inputs.cflags }} -v
- name: Run KAT tests
if: |
success()
|| steps.func_test.conclusion == 'failure'
id: kat_test
shell: nix develop .#ci -c bash -e {0}
run: |
tests kat --cross-prefix=${{ inputs.cross-prefix }} --cflags ${{ inputs.cflags }} -v
- name: Run Nistkat tests
id: nistkat_test
if: |
success()
|| steps.func_test.conclusion == 'failure'
|| steps.kat_test.conclusion == 'failure'
shell: nix develop .#ci -c bash -e {0}
run: |
tests nistkat --cross-prefix=${{ inputs.cross-prefix }} --cflags ${{ inputs.cflags }} -v
22 changes: 12 additions & 10 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ jobs:
bench_extra_args: -w exec-on-a55
uses: ./.github/workflows/bench_core_reusable.yml
if: github.repository_owner == 'pq-code-package' && (github.event.label.name == 'benchmark' || github.ref == 'refs/heads/main')
with:
runner: self-hosted-${{ matrix.target.system }}
name: ${{ matrix.target.name }}
cflags: ${{ matrix.target.cflags }}
archflags: ${{ matrix.target.archflags }}
perf: ${{ matrix.target.bench_pmu }}
store_results: ${{ github.repository_owner == 'pq-code-package' && github.ref == 'refs/heads/main' }}
bench_extra_args: ${{ matrix.target.bench_extra_args }}
secrets:
inherit
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/bench
with:
runner: self-hosted-${{ matrix.target.system }}
name: ${{ matrix.target.name }}
cflags: ${{ matrix.target.cflags }}
archflags: ${{ matrix.target.archflags }}
perf: ${{ matrix.target.bench_pmu }}
store_results: ${{ github.repository_owner == 'pq-code-package' && github.ref == 'refs/heads/main' }}
bench_extra_args: ${{ matrix.target.bench_extra_args }}
gh_token: ${{ secrets.AWS_GITHUB_TOKEN }}
69 changes: 0 additions & 69 deletions .github/workflows/bench_core_reusable.yml

This file was deleted.

Loading

0 comments on commit e6ef886

Please sign in to comment.