| 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 |
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 |
quickcheck: |
| 53 |
type: boolean |
| 54 |
default: true |
| 55 |
lint: |
| 56 |
type: boolean |
| 57 |
default: true |
| 58 |
cbmc: |
| 59 |
type: boolean |
| 60 |
default: false |
| 61 |
cbmc_mldsa_parameter_set: |
| 62 |
type: string |
| 63 |
default: 44 |
| 64 |
container: |
| 65 |
type: string |
| 66 |
default: '' |
| 67 |
env: |
| 68 |
AWS_ROLE: arn:aws:iam::904233116199:role/mldsa-native-ci |
| 69 |
AWS_REGION: us-east-1 |
| 70 |
AMI_UBUNTU_LATEST_X86_64: ami-0e86e20dae9224db8 |
| 71 |
AMI_UBUNTU_LATEST_AARCH64: ami-096ea6a12ea24a797 |
| 72 |
jobs: |
| 73 |
start-ec2-runner: |
| 74 |
name: Start instance (${{ inputs.ec2_instance_type }}) |
| 75 |
permissions: |
| 76 |
contents: 'read' |
| 77 |
id-token: 'write' |
| 78 |
runs-on: ubuntu-latest |
| 79 |
if: ${{ always() }} |
| 80 |
|
| 81 |
|
| 82 |
outputs: |
| 83 |
label: ${{ steps.remember-runner.outputs.label }} |
| 84 |
ec2-instance-id: ${{ steps.remember-runner.outputs.ec2-instance-id }} |
| 85 |
steps: |
| 86 |
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 |
| 87 |
- name: Determine AMI ID |
| 88 |
id: det_ami_id |
| 89 |
run: | |
| 90 |
if [[ "${{ inputs.ec2_ami }}" == "ubuntu-latest (x86_64)" ]]; then |
| 91 |
AMI_ID=${{ env.AMI_UBUNTU_LATEST_X86_64 }} |
| 92 |
elif [[ "${{ inputs.ec2_ami }}" == "ubuntu-latest (aarch64)" ]]; then |
| 93 |
AMI_ID=${{ env.AMI_UBUNTU_LATEST_AARCH64 }} |
| 94 |
elif [[ "${{ inputs.ec2_ami }}" == "ubuntu-latest (custom AMI)" ]]; then |
| 95 |
AMI_ID=${{ inputs.ec2_ami_id }} |
| 96 |
fi |
| 97 |
echo "Using AMI ID: $AMI_ID" |
| 98 |
echo "AMI_ID=$AMI_ID" >> $GITHUB_OUTPUT |
| 99 |
- name: Configure AWS credentials |
| 100 |
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 |
| 101 |
with: |
| 102 |
role-to-assume: ${{ env.AWS_ROLE }} |
| 103 |
aws-region: ${{ env.AWS_REGION }} |
| 104 |
- name: Start EC2 runner |
| 105 |
id: start-ec2-runner-first |
| 106 |
continue-on-error: true |
| 107 |
uses: machulav/ec2-github-runner@a6dbcefcf8a31a861f5e078bb153ed332130c512 |
| 108 |
with: |
| 109 |
mode: start |
| 110 |
github-token: ${{ secrets.AWS_GITHUB_TOKEN }} |
| 111 |
ec2-image-id: ${{ steps.det_ami_id.outputs.AMI_ID }} |
| 112 |
ec2-instance-type: ${{ inputs.ec2_instance_type }} |
| 113 |
subnet-id: subnet-094d73eb42eb6bf5b |
| 114 |
security-group-id: sg-0282706dbc92a1579 |
| 115 |
- name: Start EC2 runner (wait before retry) |
| 116 |
if: steps.start-ec2-runner-first.outcome == 'failure' |
| 117 |
shell: bash |
| 118 |
run: | |
| 119 |
sleep 30 # Wait 30s before retrying |
| 120 |
sleep $((1 + RANDOM % 30)) |
| 121 |
- name: Start EC2 runner (retry) |
| 122 |
id: start-ec2-runner-second |
| 123 |
if: steps.start-ec2-runner-first.outcome == 'failure' |
| 124 |
uses: machulav/ec2-github-runner@a6dbcefcf8a31a861f5e078bb153ed332130c512 |
| 125 |
with: |
| 126 |
mode: start |
| 127 |
github-token: ${{ secrets.AWS_GITHUB_TOKEN }} |
| 128 |
ec2-image-id: ${{ steps.det_ami_id.outputs.AMI_ID }} |
| 129 |
ec2-instance-type: ${{ inputs.ec2_instance_type }} |
| 130 |
subnet-id: subnet-094d73eb42eb6bf5b |
| 131 |
security-group-id: sg-0282706dbc92a1579 |
| 132 |
- name: Remember runner |
| 133 |
id: remember-runner |
| 134 |
shell: bash |
| 135 |
run: | |
| 136 |
if [[ "${{ steps.start-ec2-runner-first.outcome }}" == "failure" ]]; then |
| 137 |
echo "label=${{ steps.start-ec2-runner-second.outputs.label }}" >> "$GITHUB_OUTPUT" |
| 138 |
echo "ec2-instance-id=${{ steps.start-ec2-runner-second.outputs.ec2-instance-id }}" >> "$GITHUB_OUTPUT" |
| 139 |
else |
| 140 |
echo "label=${{ steps.start-ec2-runner-first.outputs.label }}" >> "$GITHUB_OUTPUT" |
| 141 |
echo "ec2-instance-id=${{ steps.start-ec2-runner-first.outputs.ec2-instance-id }}" >> "$GITHUB_OUTPUT" |
| 142 |
fi |
| 143 |
|
| 144 |
tests: |
| 145 |
name: Run tests |
| 146 |
needs: start-ec2-runner |
| 147 |
if: ${{ inputs.container != '' }} |
| 148 |
runs-on: ${{ needs.start-ec2-runner.outputs.label }} |
| 149 |
container: |
| 150 |
localhost:5000/${{ inputs.container }} |
| 151 |
steps: |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
- name: Manual checkout |
| 158 |
shell: bash |
| 159 |
run: | |
| 160 |
if /usr/bin/which yum; then |
| 161 |
yum install git -y |
| 162 |
elif /usr/bin/which apt; then |
| 163 |
apt update |
| 164 |
apt install git -y |
| 165 |
fi |
| 166 |
|
| 167 |
git init |
| 168 |
git remote add origin $GITHUB_SERVER_URL/$GITHUB_REPOSITORY |
| 169 |
git fetch origin --depth 1 $GITHUB_SHA |
| 170 |
git checkout FETCH_HEAD |
| 171 |
- uses: ./.github/actions/setup-os |
| 172 |
with: |
| 173 |
sudo: "" |
| 174 |
- name: make quickcheck |
| 175 |
if: ${{ inputs.quickcheck }} |
| 176 |
run: | |
| 177 |
OPT=0 make quickcheck |
| 178 |
make clean >/dev/null |
| 179 |
OPT=1 make quickcheck |
| 180 |
- name: Functional Tests |
| 181 |
uses: ./.github/actions/multi-functest |
| 182 |
with: |
| 183 |
nix-shell: "" |
| 184 |
gh_token: ${{ secrets.AWS_GITHUB_TOKEN }} |
| 185 |
cflags: ${{ inputs.cflags }} |
| 186 |
compile_mode: ${{ inputs.compile_mode }} |
| 187 |
opt: ${{ inputs.opt }} |
| 188 |
func: ${{ inputs.functest }} |
| 189 |
kat: ${{ inputs.kattest }} |
| 190 |
acvp: ${{ inputs.acvptest }} |
| 191 |
stop-ec2-runner: |
| 192 |
name: Stop instance (${{ inputs.ec2_instance_type }}) |
| 193 |
permissions: |
| 194 |
contents: 'read' |
| 195 |
id-token: 'write' |
| 196 |
needs: |
| 197 |
- start-ec2-runner |
| 198 |
- tests |
| 199 |
runs-on: ubuntu-latest |
| 200 |
if: ${{ always() }} |
| 201 |
steps: |
| 202 |
- name: Configure AWS credentials |
| 203 |
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 |
| 204 |
with: |
| 205 |
role-to-assume: ${{ env.AWS_ROLE }} |
| 206 |
aws-region: ${{ env.AWS_REGION }} |
| 207 |
- name: Stop EC2 runner |
| 208 |
uses: machulav/ec2-github-runner@a6dbcefcf8a31a861f5e078bb153ed332130c512 |
| 209 |
with: |
| 210 |
mode: stop |
| 211 |
github-token: ${{ secrets.AWS_GITHUB_TOKEN }} |
| 212 |
label: ${{ needs.start-ec2-runner.outputs.label }} |
| 213 |
ec2-instance-id: ${{ needs.start-ec2-runner.outputs.ec2-instance-id }} |