Skip to content

u

u #9

Workflow file for this run

name: AMI Prebuild
# Schedule to run every 15 days to keep runner agent up to date
# GitHub stops routing jobs to runners with agents older than 30 days
on:
# TODO: Remove push trigger after testing
push:
branches: [ji/ami-prebuild]
paths:
- ".github/workflows/ami-prebuild.yml"
- ".github/packer/**"
schedule:
# Run at 00:00 UTC on the 1st and 16th of each month (~15 days apart)
- cron: "0 0 1,16 * *"
workflow_dispatch:
inputs:
arch:
description: "Architecture to build (leave empty for both)"
required: false
type: choice
options:
- ""
- x64
- arm64
retention-days:
description: "Days until AMI deprecation"
required: false
type: number
default: 30
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
permissions:
contents: read
id-token: write
env:
AWS_REGION: eu-west-1
jobs:
build-x64:
name: "Build AMI (x64)"
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.arch == '' || github.event.inputs.arch == 'x64' }}
runs-on: ubuntu-latest
timeout-minutes: 60
outputs:
ami-id: ${{ steps.build.outputs.ami_id }}
ami-name: ${{ steps.build.outputs.ami_name }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::375504701696:role/GitHubBenchmarkRole
aws-region: ${{ env.AWS_REGION }}
- name: Setup Packer
uses: hashicorp/setup-packer@main
with:
version: "1.11.2"
- name: Packer Init
working-directory: .github/packer
run: packer init vortex-ci.pkr.hcl
- name: Packer Build
id: build
working-directory: .github/packer
run: |
packer build \
-var "arch=x64" \
-var "aws_region=${{ env.AWS_REGION }}" \
-var "subnet_id=${{ secrets.AWS_SUBNET_ID }}" \
-machine-readable \
vortex-ci.pkr.hcl | tee packer-output.log
# Extract AMI ID from Packer output
AMI_ID=$(grep 'artifact,0,id' packer-output.log | tail -1 | cut -d',' -f6 | cut -d':' -f2)
AMI_NAME=$(grep 'artifact,0,string' packer-output.log | tail -1 | grep -oP 'AMIs were created:.*' | sed 's/AMIs were created:\\n\\n//' | head -1 || echo "vortex-ci-x64")
echo "ami_id=$AMI_ID" >> $GITHUB_OUTPUT
echo "ami_name=$AMI_NAME" >> $GITHUB_OUTPUT
echo "Built AMI: $AMI_ID"
- name: Set AMI Deprecation
run: |
RETENTION_DAYS=${{ inputs.retention-days || '30' }}
DEPRECATION_TIME=$(date -u -d "+${RETENTION_DAYS} days" +%Y-%m-%dT%H:%M:%SZ)
aws ec2 enable-image-deprecation \
--image-id "${{ steps.build.outputs.ami_id }}" \
--deprecate-at "$DEPRECATION_TIME"
echo "AMI will be deprecated at $DEPRECATION_TIME"
- name: Summary
run: |
echo "## AMI Build Complete (x64)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **AMI ID:** ${{ steps.build.outputs.ami_id }}" >> $GITHUB_STEP_SUMMARY
echo "- **Deprecation:** ${{ inputs.retention-days || '30' }} days" >> $GITHUB_STEP_SUMMARY
build-arm64:
name: "Build AMI (arm64)"
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.arch == '' || github.event.inputs.arch == 'arm64' }}
runs-on: ubuntu-latest
timeout-minutes: 60
outputs:
ami-id: ${{ steps.build.outputs.ami_id }}
ami-name: ${{ steps.build.outputs.ami_name }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::375504701696:role/GitHubBenchmarkRole
aws-region: ${{ env.AWS_REGION }}
- name: Setup Packer
uses: hashicorp/setup-packer@main
with:
version: "1.11.2"
- name: Packer Init
working-directory: .github/packer
run: packer init vortex-ci.pkr.hcl
- name: Packer Build
id: build
working-directory: .github/packer
run: |
packer build \
-var "arch=arm64" \
-var "aws_region=${{ env.AWS_REGION }}" \
-var "subnet_id=${{ secrets.AWS_SUBNET_ID }}" \
-machine-readable \
vortex-ci.pkr.hcl | tee packer-output.log
# Extract AMI ID from Packer output
AMI_ID=$(grep 'artifact,0,id' packer-output.log | tail -1 | cut -d',' -f6 | cut -d':' -f2)
AMI_NAME=$(grep 'artifact,0,string' packer-output.log | tail -1 | grep -oP 'AMIs were created:.*' | sed 's/AMIs were created:\\n\\n//' | head -1 || echo "vortex-ci-arm64")
echo "ami_id=$AMI_ID" >> $GITHUB_OUTPUT
echo "ami_name=$AMI_NAME" >> $GITHUB_OUTPUT
echo "Built AMI: $AMI_ID"
- name: Set AMI Deprecation
run: |
RETENTION_DAYS=${{ inputs.retention-days || '30' }}
DEPRECATION_TIME=$(date -u -d "+${RETENTION_DAYS} days" +%Y-%m-%dT%H:%M:%SZ)
aws ec2 enable-image-deprecation \
--image-id "${{ steps.build.outputs.ami_id }}" \
--deprecate-at "$DEPRECATION_TIME"
echo "AMI will be deprecated at $DEPRECATION_TIME"
- name: Summary
run: |
echo "## AMI Build Complete (arm64)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **AMI ID:** ${{ steps.build.outputs.ami_id }}" >> $GITHUB_STEP_SUMMARY
echo "- **Deprecation:** ${{ inputs.retention-days || '30' }} days" >> $GITHUB_STEP_SUMMARY
# Test the newly built AMI
test-x64:
name: "Test AMI (x64)"
needs: build-x64
runs-on:
- runs-on=${{ github.run_id }}
- family=m7i+m7i-flex+m7a
- cpu=4
- image=vortex-ci-amd64
- tag=test-ami-x64
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- name: Verify tools are installed
run: |
echo "Checking installed tools..."
cargo --version
rustc --version
rustup show
protoc --version
flatc --version
- name: Run cargo check
run: cargo check --locked
test-arm64:
name: "Test AMI (arm64)"
needs: build-arm64
runs-on:
- runs-on=${{ github.run_id }}
- family=m7g
- cpu=4
- image=vortex-ci-arm64
- tag=test-ami-arm64
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- name: Verify tools are installed
run: |
echo "Checking installed tools..."
cargo --version
rustc --version
rustup show
protoc --version
flatc --version
- name: Run cargo check
run: cargo check --locked