Skip to content

Commit ed3156e

Browse files
committed
Port ec2_compatibilitytests from mlkem
- This commit port ec2_compatibilitytests from mlkem to mldsa - Also, due to the requement for ci_ec2_container.yml, this commit add the ci_ec2_container.yml based on ci_ec2_reuseable.yml, referencing from mlkem-native Signed-off-by: willieyz <willie.zhao@chelpis.com>
1 parent c6d7c93 commit ed3156e

File tree

2 files changed

+255
-0
lines changed

2 files changed

+255
-0
lines changed

.github/workflows/ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,52 @@ jobs:
613613
nix-shell: ""
614614
custom_shell: ${{ matrix.container.nix_shell && format('{0} --run \"bash -e {{0}}\"', matrix.container.nix_shell) || 'bash' }}
615615
gh_token: ${{ secrets.GITHUB_TOKEN }}
616+
ec2_compatibilitytests:
617+
strategy:
618+
max-parallel: 8
619+
fail-fast: false
620+
matrix:
621+
container:
622+
- id: amazonlinux-2-aarch:base
623+
- id: amazonlinux-2-aarch:gcc-7x
624+
- id: amazonlinux-2-aarch:clang-7x
625+
- id: amazonlinux-2023-aarch:base
626+
- id: amazonlinux-2023-aarch:gcc-11x
627+
- id: amazonlinux-2023-aarch:clang-15x
628+
- id: amazonlinux-2023-aarch:clang-15x-sanitizer
629+
# - id: amazonlinux-2023-aarch:cryptofuzz Not yet supported
630+
- id: ubuntu-22.04-aarch:gcc-12x
631+
- id: ubuntu-22.04-aarch:gcc-11x
632+
- id: ubuntu-20.04-aarch:gcc-8x
633+
- id: ubuntu-20.04-aarch:gcc-7x
634+
- id: ubuntu-20.04-aarch:clang-9x
635+
- id: ubuntu-20.04-aarch:clang-8x
636+
- id: ubuntu-20.04-aarch:clang-7x-bm-framework
637+
- id: ubuntu-20.04-aarch:clang-7x
638+
- id: ubuntu-20.04-aarch:clang-10x
639+
- id: ubuntu-22.04-aarch:base
640+
- id: ubuntu-20.04-aarch:base
641+
name: Compatibility tests (${{ matrix.container.id }})
642+
permissions:
643+
contents: 'read'
644+
id-token: 'write'
645+
uses: ./.github/workflows/ci_ec2_container.yml
646+
if: github.repository_owner == 'pq-code-package' && !github.event.pull_request.head.repo.fork
647+
with:
648+
container: ${{ matrix.container.id }}
649+
name: ${{ matrix.container.id }}
650+
ec2_instance_type: t4g.small
651+
ec2_ami: ubuntu-latest (custom AMI)
652+
ec2_ami_id: ami-0c9bc1901ef0d1066 # Has docker images preinstalled
653+
compile_mode: native
654+
opt: all
655+
functest: true
656+
kattest: true
657+
acvptest: true
658+
lint: false
659+
verbose: true
660+
cflags: "-O0"
661+
secrets: inherit
616662
check_autogenerated_files:
617663
strategy:
618664
fail-fast: false
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
# Copyright (c) The mlkem-native project authors
2+
# Copyright (c) The mldsa-native project authors
3+
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4+
5+
name: ci-ec2-reusable
6+
permissions:
7+
contents: read
8+
on:
9+
workflow_call:
10+
inputs:
11+
name:
12+
type: string
13+
description: Alternative name of instance
14+
default: Graviton2
15+
ec2_instance_type:
16+
type: string
17+
description: Type if EC2 instance to benchmark on
18+
default: t4g.small
19+
ec2_ami:
20+
type: string
21+
description: Textual description of AMI
22+
default: ubuntu-latest (aarch64)
23+
ec2_ami_id:
24+
type: string
25+
description: AMI ID
26+
default: ami-0e8c824f386e1de06
27+
cflags:
28+
type: string
29+
description: Custom CFLAGS for compilation
30+
default: ""
31+
verbose:
32+
description: Determine for the log verbosity
33+
type: boolean
34+
default: false
35+
compile_mode:
36+
type: string
37+
description: either all, native, cross or none
38+
default: all
39+
opt:
40+
type: string
41+
description: either all, opt or no_opt
42+
default: all
43+
functest:
44+
type: boolean
45+
default: true
46+
kattest:
47+
type: boolean
48+
default: true
49+
acvptest:
50+
type: boolean
51+
default: true
52+
lint:
53+
type: boolean
54+
default: true
55+
cbmc:
56+
type: boolean
57+
default: false
58+
cbmc_mldsa_parameter_set:
59+
type: string
60+
default: 44
61+
container:
62+
type: string
63+
default: ''
64+
env:
65+
AWS_ROLE: arn:aws:iam::904233116199:role/mldsa-native-ci
66+
AWS_REGION: us-east-1
67+
AMI_UBUNTU_LATEST_X86_64: ami-084568db4383264d4
68+
AMI_UBUNTU_LATEST_AARCH64: ami-0c4e709339fa8521a
69+
jobs:
70+
start-ec2-runner:
71+
name: Start instance (${{ inputs.ec2_instance_type }})
72+
permissions:
73+
contents: 'read'
74+
id-token: 'write'
75+
runs-on: ubuntu-latest
76+
if: ${{ always() }} # The point is to make this step non-cancellable,
77+
# avoiding race conditions where an instance is started,
78+
# but isn't yet done registering as a runner and reporting back.
79+
outputs:
80+
label: ${{ steps.remember-runner.outputs.label }}
81+
ec2-instance-id: ${{ steps.remember-runner.outputs.ec2-instance-id }}
82+
steps:
83+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
84+
- name: Determine AMI ID
85+
id: det_ami_id
86+
run: |
87+
if [[ "${{ inputs.ec2_ami }}" == "ubuntu-latest (x86_64)" ]]; then
88+
AMI_ID=${{ env.AMI_UBUNTU_LATEST_X86_64 }}
89+
elif [[ "${{ inputs.ec2_ami }}" == "ubuntu-latest (aarch64)" ]]; then
90+
AMI_ID=${{ env.AMI_UBUNTU_LATEST_AARCH64 }}
91+
elif [[ "${{ inputs.ec2_ami }}" == "ubuntu-latest (custom AMI)" ]]; then
92+
AMI_ID=${{ inputs.ec2_ami_id }}
93+
fi
94+
echo "Using AMI ID: $AMI_ID"
95+
echo "AMI_ID=$AMI_ID" >> $GITHUB_OUTPUT
96+
- name: Configure AWS credentials
97+
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 # v5.1.0
98+
with:
99+
role-to-assume: ${{ env.AWS_ROLE }}
100+
aws-region: ${{ env.AWS_REGION }}
101+
- name: Start EC2 runner
102+
id: start-ec2-runner-first
103+
continue-on-error: true
104+
uses: machulav/ec2-github-runner@a6dbcefcf8a31a861f5e078bb153ed332130c512 # v2.4.3
105+
with:
106+
mode: start
107+
github-token: ${{ secrets.AWS_GITHUB_TOKEN }}
108+
ec2-image-id: ${{ steps.det_ami_id.outputs.AMI_ID }}
109+
ec2-instance-type: ${{ inputs.ec2_instance_type }}
110+
subnet-id: subnet-094d73eb42eb6bf5b
111+
security-group-id: sg-0282706dbc92a1579
112+
- name: Start EC2 runner (wait before retry)
113+
if: steps.start-ec2-runner-first.outcome == 'failure'
114+
shell: bash
115+
run: |
116+
sleep 30 # Wait 30s before retrying
117+
sleep $((1 + RANDOM % 30))
118+
- name: Start EC2 runner (retry)
119+
id: start-ec2-runner-second
120+
if: steps.start-ec2-runner-first.outcome == 'failure'
121+
uses: machulav/ec2-github-runner@a6dbcefcf8a31a861f5e078bb153ed332130c512 # v2.4.3
122+
with:
123+
mode: start
124+
github-token: ${{ secrets.AWS_GITHUB_TOKEN }}
125+
ec2-image-id: ${{ steps.det_ami_id.outputs.AMI_ID }}
126+
ec2-instance-type: ${{ inputs.ec2_instance_type }}
127+
subnet-id: subnet-094d73eb42eb6bf5b
128+
security-group-id: sg-0282706dbc92a1579
129+
- name: Remember runner
130+
id: remember-runner
131+
shell: bash
132+
run: |
133+
if [[ "${{ steps.start-ec2-runner-first.outcome }}" == "failure" ]]; then
134+
echo "label=${{ steps.start-ec2-runner-second.outputs.label }}" >> "$GITHUB_OUTPUT"
135+
echo "ec2-instance-id=${{ steps.start-ec2-runner-second.outputs.ec2-instance-id }}" >> "$GITHUB_OUTPUT"
136+
else
137+
echo "label=${{ steps.start-ec2-runner-first.outputs.label }}" >> "$GITHUB_OUTPUT"
138+
echo "ec2-instance-id=${{ steps.start-ec2-runner-first.outputs.ec2-instance-id }}" >> "$GITHUB_OUTPUT"
139+
fi
140+
141+
tests:
142+
name: Run tests
143+
needs: start-ec2-runner
144+
if: ${{ inputs.container != '' }}
145+
runs-on: ${{ needs.start-ec2-runner.outputs.label }}
146+
container:
147+
localhost:5000/${{ inputs.container }}
148+
steps:
149+
# We're not using the checkout action here because on it's not supported
150+
# on all containers we want to test. Resort to a manual checkout.
151+
#
152+
# We can't hoist this into an action since calling an action can only
153+
# be done after checkout.
154+
- name: Manual checkout
155+
shell: bash
156+
run: |
157+
if /usr/bin/which yum; then
158+
yum install git -y
159+
elif /usr/bin/which apt; then
160+
apt update
161+
apt install git -y
162+
fi
163+
164+
git init
165+
git remote add origin $GITHUB_SERVER_URL/$GITHUB_REPOSITORY
166+
git fetch origin --depth 1 $GITHUB_SHA
167+
git checkout FETCH_HEAD
168+
- uses: ./.github/actions/setup-os
169+
with:
170+
sudo: ""
171+
- name: make quickcheck
172+
run: |
173+
OPT=0 make quickcheck
174+
make clean >/dev/null
175+
OPT=1 make quickcheck
176+
- name: Functional Tests
177+
uses: ./.github/actions/multi-functest
178+
with:
179+
nix-shell: ""
180+
gh_token: ${{ secrets.AWS_GITHUB_TOKEN }}
181+
cflags: ${{ inputs.cflags }}
182+
compile_mode: ${{ inputs.compile_mode }}
183+
opt: ${{ inputs.opt }}
184+
func: ${{ inputs.functest }}
185+
kat: ${{ inputs.kattest }}
186+
acvp: ${{ inputs.acvptest }}
187+
stop-ec2-runner:
188+
name: Stop instance (${{ inputs.ec2_instance_type }})
189+
permissions:
190+
contents: 'read'
191+
id-token: 'write'
192+
needs:
193+
- start-ec2-runner
194+
- tests
195+
runs-on: ubuntu-latest
196+
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
197+
steps:
198+
- name: Configure AWS credentials
199+
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 # v5.1.0
200+
with:
201+
role-to-assume: ${{ env.AWS_ROLE }}
202+
aws-region: ${{ env.AWS_REGION }}
203+
- name: Stop EC2 runner
204+
uses: machulav/ec2-github-runner@a6dbcefcf8a31a861f5e078bb153ed332130c512 # v2.4.3
205+
with:
206+
mode: stop
207+
github-token: ${{ secrets.AWS_GITHUB_TOKEN }}
208+
label: ${{ needs.start-ec2-runner.outputs.label }}
209+
ec2-instance-id: ${{ needs.start-ec2-runner.outputs.ec2-instance-id }}

0 commit comments

Comments
 (0)