Skip to content

Demo – OS and architecture matrix #7

Demo – OS and architecture matrix

Demo – OS and architecture matrix #7

Workflow file for this run

name: Demo – x86 and ARM instances
on:
workflow_dispatch:
workflow_call: # Tested by `demos.yml`
permissions:
id-token: write # Required for AWS OIDC authentication
contents: read # Required for actions/checkout
jobs:
# Launch EC2 runners for each architecture
x86:
name: Launch x86
uses: ./.github/workflows/runner.yml
with:
ec2_instance_type: t3.medium
# Ubuntu 24.04 LTS x86_64 (default AMI)
secrets: inherit
arm:
name: Launch ARM
uses: ./.github/workflows/runner.yml
with:
ec2_instance_type: t4g.medium
ec2_image_id: ami-0aa307ed50ca3e58f # Ubuntu 24.04 LTS arm64 (us-east-1)
secrets: inherit
# Run jobs directly on launched instances
test-x86:
needs: x86
if: needs.x86.outputs.id != ''
name: Test x86
runs-on: ${{ needs.x86.outputs.id }}
steps:
- name: Architecture test on t3.medium
run: |
echo "Architecture: $(uname -m)"
echo "Processor: $(lscpu | grep 'Architecture:' | awk '{print $2}')"
echo "Instance type: $(curl -s http://169.254.169.254/latest/meta-data/instance-type)"
test-arm:
needs: arm
if: needs.arm.outputs.id != ''
name: Test ARM
runs-on: ${{ needs.arm.outputs.id }}
steps:
- name: Architecture test on t4g.medium
run: |
echo "Architecture: $(uname -m)"
echo "Processor: $(lscpu | grep 'Architecture:' | awk '{print $2}')"
echo "Instance type: $(curl -s http://169.254.169.254/latest/meta-data/instance-type)"
# Use a `matrix` to run jobs on multiple instances
test-matrix:
needs: [x86, arm]
if: always() && (needs.x86.outputs.id != '' || needs.arm.outputs.id != '')
name: Test ${{ matrix.arch }} (matrix)
continue-on-error: true
strategy:
matrix:
include:
- arch: x86
runner: ${{ needs.x86.outputs.id }}
- arch: arm
runner: ${{ needs.arm.outputs.id }}
fail-fast: false
runs-on: ${{ matrix.runner }}
steps:
- name: Matrix architecture test
run: |
echo "Running on ${{ matrix.arch }}"
echo "Architecture: $(uname -m)"
echo "Instance type: $(curl -s http://169.254.169.254/latest/meta-data/instance-type)"
# Verify expected architecture
if [[ "${{ matrix.arch }}" == "x86" ]]; then
echo "Verifying x86_64 architecture..."
[[ "$(uname -m)" == "x86_64" ]] && echo "✓ Confirmed x86_64" || exit 1
elif [[ "${{ matrix.arch }}" == "arm" ]]; then
echo "Verifying ARM architecture..."
[[ "$(uname -m)" == "aarch64" ]] && echo "✓ Confirmed aarch64" || exit 1
fi