Skip to content

Commit d1369df

Browse files
committed
u
Signed-off-by: Joe Isaacs <[email protected]>
1 parent db44ca6 commit d1369df

File tree

3 files changed

+225
-2
lines changed

3 files changed

+225
-2
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: "Build Vortex CI AMI"
2+
description: "Build a custom Amazon Machine Image for Vortex CI runners"
3+
4+
inputs:
5+
arch:
6+
description: "Target architecture: x64 or arm64"
7+
required: true
8+
aws-region:
9+
description: "AWS region to build AMI in"
10+
required: false
11+
default: "us-east-1"
12+
ami-prefix:
13+
description: "Prefix for AMI name"
14+
required: false
15+
default: "vortex-ci"
16+
retention-days:
17+
description: "Number of days before AMI is deprecated"
18+
required: false
19+
default: "30"
20+
21+
outputs:
22+
ami-id:
23+
description: "The ID of the built AMI"
24+
value: ${{ steps.create-ami.outputs.ami_id }}
25+
ami-name:
26+
description: "The name of the built AMI"
27+
value: ${{ steps.create-ami.outputs.ami_name }}
28+
29+
runs:
30+
using: "composite"
31+
steps:
32+
- name: Setup Rust
33+
uses: ./.github/actions/setup-rust
34+
35+
- name: Setup flatc
36+
uses: ./.github/actions/setup-flatc
37+
38+
- name: Install extra dependencies
39+
shell: bash
40+
run: |
41+
sudo apt-get update
42+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
43+
cmake \
44+
ninja-build \
45+
clang \
46+
lld \
47+
llvm
48+
49+
- name: Install nightly toolchain
50+
shell: bash
51+
run: |
52+
rustup toolchain install nightly
53+
rustup component add --toolchain nightly rustfmt clippy rust-src miri llvm-tools-preview
54+
55+
- name: Install cargo tools
56+
shell: bash
57+
run: |
58+
cargo install cargo-nextest --locked
59+
cargo install cargo-hack --locked
60+
cargo install grcov --locked
61+
62+
- name: Get instance ID
63+
id: instance
64+
shell: bash
65+
run: |
66+
INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
67+
echo "instance_id=$INSTANCE_ID" >> $GITHUB_OUTPUT
68+
69+
- name: Create AMI
70+
id: create-ami
71+
shell: bash
72+
env:
73+
AWS_REGION: ${{ inputs.aws-region }}
74+
AMI_PREFIX: ${{ inputs.ami-prefix }}
75+
ARCH: ${{ inputs.arch }}
76+
RETENTION_DAYS: ${{ inputs.retention-days }}
77+
run: |
78+
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
79+
AMI_NAME="${AMI_PREFIX}-${ARCH}-${TIMESTAMP}"
80+
DEPRECATION_TIME=$(date -u -d "+${RETENTION_DAYS} days" +%Y-%m-%dT%H:%M:%SZ)
81+
82+
echo "Creating AMI: $AMI_NAME"
83+
AMI_ID=$(aws ec2 create-image \
84+
--instance-id "${{ steps.instance.outputs.instance_id }}" \
85+
--name "$AMI_NAME" \
86+
--description "Vortex CI runner image for ${ARCH}" \
87+
--no-reboot \
88+
--tag-specifications "ResourceType=image,Tags=[{Key=Name,Value=$AMI_NAME},{Key=Environment,Value=ci},{Key=Arch,Value=$ARCH},{Key=ManagedBy,Value=github-actions}]" \
89+
--query 'ImageId' \
90+
--output text)
91+
92+
echo "Waiting for AMI to be available..."
93+
aws ec2 wait image-available --image-ids "$AMI_ID"
94+
95+
echo "Setting deprecation time to $DEPRECATION_TIME"
96+
aws ec2 enable-image-deprecation \
97+
--image-id "$AMI_ID" \
98+
--deprecate-at "$DEPRECATION_TIME"
99+
100+
echo "ami_id=$AMI_ID" >> $GITHUB_OUTPUT
101+
echo "ami_name=$AMI_NAME" >> $GITHUB_OUTPUT
102+
echo "AMI created: $AMI_ID ($AMI_NAME)"

.github/runs-on.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
# Custom AMIs for Vortex CI runners
2+
# These AMIs are automatically rebuilt every 15 days by the ami-prebuild.yml workflow
3+
# to keep the GitHub Actions runner agent up to date (required to be <30 days old).
4+
#
5+
# AMI naming pattern: vortex-ci-{arch}-{timestamp}
6+
# Built with: .github/actions/build-ami and .github/packer/vortex-ci.pkr.hcl
17
images:
28
vortex-ci-amd64:
39
platform: "linux"
410
arch: "x64"
5-
name: "vortex-ci-*"
11+
name: "vortex-ci-x64-*"
612
owner: "375504701696"
713
vortex-ci-arm64:
814
platform: "linux"
915
arch: "arm64"
10-
name: "vortex-ci-*"
16+
name: "vortex-ci-arm64-*"
1117
owner: "375504701696"

.github/workflows/ami-prebuild.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: AMI Prebuild
2+
3+
# Schedule to run every 15 days to keep runner agent up to date
4+
# GitHub stops routing jobs to runners with agents older than 30 days
5+
on:
6+
# TODO: Remove push trigger after testing
7+
push:
8+
branches: [ji/ami-prebuild]
9+
paths:
10+
- ".github/workflows/ami-prebuild.yml"
11+
- ".github/actions/build-ami/**"
12+
schedule:
13+
# Run at 00:00 UTC on the 1st and 16th of each month (~15 days apart)
14+
- cron: "0 0 1,16 * *"
15+
workflow_dispatch:
16+
inputs:
17+
arch:
18+
description: "Architecture to build (leave empty for both)"
19+
required: false
20+
type: choice
21+
options:
22+
- ""
23+
- x64
24+
- arm64
25+
retention-days:
26+
description: "Days until AMI deprecation"
27+
required: false
28+
type: number
29+
default: 30
30+
31+
concurrency:
32+
group: ${{ github.workflow }}
33+
cancel-in-progress: false
34+
35+
permissions:
36+
contents: read
37+
id-token: write
38+
39+
env:
40+
AWS_REGION: us-east-1
41+
42+
jobs:
43+
build-x64:
44+
name: "Build AMI (x64)"
45+
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.arch == '' || github.event.inputs.arch == 'x64' }}
46+
runs-on:
47+
- runs-on=${{ github.run_id }}
48+
- family=m7i+m7i-flex+m7a
49+
- cpu=4
50+
- image=ubuntu24-full-x64
51+
- tag=ami-prebuild-x64
52+
timeout-minutes: 60
53+
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v6
57+
58+
- name: Configure AWS Credentials
59+
uses: aws-actions/configure-aws-credentials@v4
60+
with:
61+
role-to-assume: arn:aws:iam::375504701696:role/GitHubBenchmarkRole
62+
aws-region: ${{ env.AWS_REGION }}
63+
64+
- name: Build AMI
65+
id: build
66+
uses: ./.github/actions/build-ami
67+
with:
68+
arch: x64
69+
aws-region: ${{ env.AWS_REGION }}
70+
retention-days: ${{ inputs.retention-days || '30' }}
71+
72+
- name: Summary
73+
run: |
74+
echo "## AMI Build Complete (x64)" >> $GITHUB_STEP_SUMMARY
75+
echo "" >> $GITHUB_STEP_SUMMARY
76+
echo "- **AMI ID:** ${{ steps.build.outputs.ami-id }}" >> $GITHUB_STEP_SUMMARY
77+
echo "- **AMI Name:** ${{ steps.build.outputs.ami-name }}" >> $GITHUB_STEP_SUMMARY
78+
echo "- **Deprecation:** ${{ inputs.retention-days || '30' }} days" >> $GITHUB_STEP_SUMMARY
79+
80+
build-arm64:
81+
name: "Build AMI (arm64)"
82+
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.arch == '' || github.event.inputs.arch == 'arm64' }}
83+
runs-on:
84+
- runs-on=${{ github.run_id }}
85+
- family=m7g
86+
- cpu=4
87+
- image=ubuntu24-full-arm64
88+
- tag=ami-prebuild-arm64
89+
timeout-minutes: 60
90+
91+
steps:
92+
- name: Checkout
93+
uses: actions/checkout@v6
94+
95+
- name: Configure AWS Credentials
96+
uses: aws-actions/configure-aws-credentials@v4
97+
with:
98+
role-to-assume: arn:aws:iam::375504701696:role/GitHubBenchmarkRole
99+
aws-region: ${{ env.AWS_REGION }}
100+
101+
- name: Build AMI
102+
id: build
103+
uses: ./.github/actions/build-ami
104+
with:
105+
arch: arm64
106+
aws-region: ${{ env.AWS_REGION }}
107+
retention-days: ${{ inputs.retention-days || '30' }}
108+
109+
- name: Summary
110+
run: |
111+
echo "## AMI Build Complete (arm64)" >> $GITHUB_STEP_SUMMARY
112+
echo "" >> $GITHUB_STEP_SUMMARY
113+
echo "- **AMI ID:** ${{ steps.build.outputs.ami-id }}" >> $GITHUB_STEP_SUMMARY
114+
echo "- **AMI Name:** ${{ steps.build.outputs.ami-name }}" >> $GITHUB_STEP_SUMMARY
115+
echo "- **Deprecation:** ${{ inputs.retention-days || '30' }} days" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)