| 1 |
|
| 2 |
|
| 3 |
|
| 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 |
ec2_volume_size: |
| 28 |
type: string |
| 29 |
default: "" |
| 30 |
cflags: |
| 31 |
type: string |
| 32 |
description: Custom CFLAGS for compilation |
| 33 |
default: "" |
| 34 |
verbose: |
| 35 |
description: Determine for the log verbosity |
| 36 |
type: boolean |
| 37 |
default: false |
| 38 |
compile_mode: |
| 39 |
type: string |
| 40 |
description: either all, native, cross or none |
| 41 |
default: all |
| 42 |
opt: |
| 43 |
type: string |
| 44 |
description: either all, opt or no_opt |
| 45 |
default: all |
| 46 |
functest: |
| 47 |
type: boolean |
| 48 |
default: true |
| 49 |
kattest: |
| 50 |
type: boolean |
| 51 |
default: true |
| 52 |
acvptest: |
| 53 |
type: boolean |
| 54 |
default: true |
| 55 |
lint: |
| 56 |
type: boolean |
| 57 |
default: true |
| 58 |
test: |
| 59 |
type: boolean |
| 60 |
default: true |
| 61 |
config_variations: |
| 62 |
type: string |
| 63 |
description: List of configuration variation tests to run (space-separated IDs) or empty for no tests |
| 64 |
default: '' |
| 65 |
cbmc: |
| 66 |
type: boolean |
| 67 |
default: false |
| 68 |
slothy: |
| 69 |
type: boolean |
| 70 |
default: false |
| 71 |
cbmc_mldsa_parameter_set: |
| 72 |
type: string |
| 73 |
default: 44 |
| 74 |
env: |
| 75 |
AWS_ROLE: arn:aws:iam::904233116199:role/mldsa-native-ci |
| 76 |
AWS_REGION: us-east-1 |
| 77 |
AMI_UBUNTU_LATEST_X86_64: ami-084568db4383264d4 |
| 78 |
AMI_UBUNTU_LATEST_AARCH64: ami-0c4e709339fa8521a |
| 79 |
jobs: |
| 80 |
start-ec2-runner: |
| 81 |
name: Start instance (${{ inputs.ec2_instance_type }}) |
| 82 |
permissions: |
| 83 |
contents: 'read' |
| 84 |
id-token: 'write' |
| 85 |
runs-on: ubuntu-latest |
| 86 |
if: ${{ always() }} |
| 87 |
|
| 88 |
|
| 89 |
outputs: |
| 90 |
label: ${{ steps.remember-runner.outputs.label }} |
| 91 |
ec2-instance-id: ${{ steps.remember-runner.outputs.ec2-instance-id }} |
| 92 |
steps: |
| 93 |
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 |
| 94 |
- name: Determine AMI ID |
| 95 |
id: det_ami_id |
| 96 |
run: | |
| 97 |
if [[ "${{ inputs.ec2_ami }}" == "ubuntu-latest (x86_64)" ]]; then |
| 98 |
AMI_ID=${{ env.AMI_UBUNTU_LATEST_X86_64 }} |
| 99 |
elif [[ "${{ inputs.ec2_ami }}" == "ubuntu-latest (aarch64)" ]]; then |
| 100 |
AMI_ID=${{ env.AMI_UBUNTU_LATEST_AARCH64 }} |
| 101 |
elif [[ "${{ inputs.ec2_ami }}" == "ubuntu-latest (custom AMI)" ]]; then |
| 102 |
AMI_ID=${{ inputs.ec2_ami_id }} |
| 103 |
fi |
| 104 |
echo "Using AMI ID: $AMI_ID" |
| 105 |
echo "AMI_ID=$AMI_ID" >> $GITHUB_OUTPUT |
| 106 |
- name: Configure AWS credentials |
| 107 |
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 |
| 108 |
with: |
| 109 |
role-to-assume: ${{ env.AWS_ROLE }} |
| 110 |
aws-region: ${{ env.AWS_REGION }} |
| 111 |
- name: Start EC2 runner |
| 112 |
id: start-ec2-runner-first |
| 113 |
continue-on-error: true |
| 114 |
uses: machulav/ec2-github-runner@a6dbcefcf8a31a861f5e078bb153ed332130c512 |
| 115 |
with: |
| 116 |
mode: start |
| 117 |
github-token: ${{ secrets.AWS_GITHUB_TOKEN }} |
| 118 |
ec2-image-id: ${{ steps.det_ami_id.outputs.AMI_ID }} |
| 119 |
ec2-volume-size: ${{ inputs.ec2_volume_size }} |
| 120 |
ec2-instance-type: ${{ inputs.ec2_instance_type }} |
| 121 |
subnet-id: subnet-094d73eb42eb6bf5b |
| 122 |
security-group-id: sg-0282706dbc92a1579 |
| 123 |
- name: Start EC2c runner (wait before retry) |
| 124 |
if: steps.start-ec2-runner-first.outcome == 'failure' |
| 125 |
shell: bash |
| 126 |
run: | |
| 127 |
sleep 30 # Wait 30s before retrying |
| 128 |
sleep $((1 + RANDOM % 30)) |
| 129 |
- name: Start EC2 runner (retry) |
| 130 |
id: start-ec2-runner-second |
| 131 |
if: steps.start-ec2-runner-first.outcome == 'failure' |
| 132 |
uses: machulav/ec2-github-runner@a6dbcefcf8a31a861f5e078bb153ed332130c512 |
| 133 |
with: |
| 134 |
mode: start |
| 135 |
github-token: ${{ secrets.AWS_GITHUB_TOKEN }} |
| 136 |
ec2-image-id: ${{ steps.det_ami_id.outputs.AMI_ID }} |
| 137 |
ec2-volume-size: ${{ inputs.ec2_volume_size }} |
| 138 |
ec2-instance-type: ${{ inputs.ec2_instance_type }} |
| 139 |
subnet-id: subnet-094d73eb42eb6bf5b |
| 140 |
security-group-id: sg-0282706dbc92a1579 |
| 141 |
- name: Remember runner |
| 142 |
id: remember-runner |
| 143 |
shell: bash |
| 144 |
run: | |
| 145 |
if [[ "${{ steps.start-ec2-runner-first.outcome }}" == "failure" ]]; then |
| 146 |
echo "label=${{ steps.start-ec2-runner-second.outputs.label }}" >> "$GITHUB_OUTPUT" |
| 147 |
echo "ec2-instance-id=${{ steps.start-ec2-runner-second.outputs.ec2-instance-id }}" >> "$GITHUB_OUTPUT" |
| 148 |
else |
| 149 |
echo "label=${{ steps.start-ec2-runner-first.outputs.label }}" >> "$GITHUB_OUTPUT" |
| 150 |
echo "ec2-instance-id=${{ steps.start-ec2-runner-first.outputs.ec2-instance-id }}" >> "$GITHUB_OUTPUT" |
| 151 |
fi |
| 152 |
|
| 153 |
tests: |
| 154 |
name: Run tests |
| 155 |
needs: start-ec2-runner |
| 156 |
runs-on: ${{ needs.start-ec2-runner.outputs.label }} |
| 157 |
steps: |
| 158 |
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 |
| 159 |
- name: Linting |
| 160 |
if: ${{ inputs.lint }} |
| 161 |
uses: ./.github/actions/lint |
| 162 |
with: |
| 163 |
nix-shell: ci-linter |
| 164 |
gh_token: ${{ secrets.AWS_GITHUB_TOKEN }} |
| 165 |
nix-verbose: ${{ inputs.verbose }} |
| 166 |
- name: Functional Tests |
| 167 |
if: ${{ inputs.test }} |
| 168 |
uses: ./.github/actions/multi-functest |
| 169 |
with: |
| 170 |
nix-shell: ${{ (inputs.compile_mode == 'cross' || inputs.compile_mode == 'all') && 'ci-cross' || 'ci' }} |
| 171 |
nix-cache: ${{ inputs.cbmc || inputs.compile_mode == 'cross' || inputs.compile_mode == 'all' }} |
| 172 |
nix-verbose: ${{ inputs.verbose }} |
| 173 |
gh_token: ${{ secrets.AWS_GITHUB_TOKEN }} |
| 174 |
cflags: ${{ inputs.cflags }} |
| 175 |
compile_mode: ${{ inputs.compile_mode }} |
| 176 |
opt: ${{ inputs.opt }} |
| 177 |
func: ${{ inputs.functest }} |
| 178 |
kat: ${{ inputs.kattest }} |
| 179 |
acvp: ${{ inputs.acvptest }} |
| 180 |
- name: Config Variations |
| 181 |
if: ${{ inputs.config_variations != '' && (success() || failure()) }} |
| 182 |
uses: ./.github/actions/config-variations |
| 183 |
with: |
| 184 |
gh_token: ${{ secrets.AWS_GITHUB_TOKEN }} |
| 185 |
tests: ${{ inputs.config_variations }} |
| 186 |
opt: opt |
| 187 |
- name: CBMC |
| 188 |
if: ${{ inputs.cbmc && (success() || failure()) }} |
| 189 |
uses: ./.github/actions/cbmc |
| 190 |
with: |
| 191 |
nix-shell: ci-cbmc |
| 192 |
nix-verbose: ${{ inputs.verbose }} |
| 193 |
mldsa_parameter_set: ${{ inputs.cbmc_mldsa_parameter_set }} |
| 194 |
gh_token: ${{ secrets.AWS_GITHUB_TOKEN }} |
| 195 |
- name: SLOTHY |
| 196 |
if: ${{ inputs.slothy }} |
| 197 |
uses: ./.github/actions/setup-shell |
| 198 |
with: |
| 199 |
gh_token: ${{ secrets.AWS_GITHUB_TOKEN }} |
| 200 |
nix-cache: true |
| 201 |
nix-shell: ci-slothy |
| 202 |
script: | |
| 203 |
autogen --slothy |
| 204 |
tests all --opt opt |
| 205 |
# Force testing of SLOTHY-optimized Keccak variants |
| 206 |
# We can't run the examples here because some of them also specify the backend |
| 207 |
make clean |
| 208 |
tests all --no-examples --opt opt --cflags="-DMLD_CONFIG_FIPS202_BACKEND_FILE=\\\"fips202/native/aarch64/x1_scalar.h\\\"" |
| 209 |
make clean |
| 210 |
tests all --no-examples --opt opt --cflags="-DMLD_CONFIG_FIPS202_BACKEND_FILE=\\\"fips202/native/aarch64/x4_v8a_scalar.h\\\"" |
| 211 |
make clean |
| 212 |
tests all --no-examples --opt opt --cflags="-march=armv8.4-a+sha3 -DMLD_CONFIG_FIPS202_BACKEND_FILE=\\\"fips202/native/aarch64/x4_v8a_v84a_scalar.h\\\"" |
| 213 |
stop-ec2-runner: |
| 214 |
name: Stop instance (${{ inputs.ec2_instance_type }}) |
| 215 |
permissions: |
| 216 |
contents: 'read' |
| 217 |
id-token: 'write' |
| 218 |
needs: |
| 219 |
- start-ec2-runner |
| 220 |
- tests |
| 221 |
runs-on: ubuntu-latest |
| 222 |
if: ${{ always() }} |
| 223 |
steps: |
| 224 |
- name: Configure AWS credentials |
| 225 |
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 |
| 226 |
with: |
| 227 |
role-to-assume: ${{ env.AWS_ROLE }} |
| 228 |
aws-region: ${{ env.AWS_REGION }} |
| 229 |
- name: Stop EC2 runner |
| 230 |
uses: machulav/ec2-github-runner@a6dbcefcf8a31a861f5e078bb153ed332130c512 |
| 231 |
with: |
| 232 |
mode: stop |
| 233 |
github-token: ${{ secrets.AWS_GITHUB_TOKEN }} |
| 234 |
label: ${{ needs.start-ec2-runner.outputs.label }} |
| 235 |
ec2-instance-id: ${{ needs.start-ec2-runner.outputs.ec2-instance-id }} |