Skip to content

Demo – OS and architecture matrix #17

Demo – OS and architecture matrix

Demo – OS and architecture matrix #17

Workflow file for this run

name: Demo – OS and architecture matrix
on:
workflow_dispatch:
inputs:
sleep:
description: "Sleep duration in seconds for workload simulation"
required: false
type: string
default: "10"
workflow_call: # Tested by `demos.yml`
inputs:
sleep:
required: false
type: string
default: "10"
permissions:
id-token: write # Required for AWS OIDC authentication
contents: read # Required for actions/checkout
jobs:
# Launch EC2 runners for each OS/architecture combination
ubuntu-amd64:
name: Launch Ubuntu AMD64
uses: ./.github/workflows/runner.yml
with:
ec2_instance_type: t3.medium
ec2_image_id: ami-0ca5a2f40c2601df6 # Ubuntu 24.04 LTS x86_64 (us-east-1)
instance_name: "Ubuntu-AMD64/$name#$run_number"
secrets: inherit
ubuntu-arm64:
name: Launch Ubuntu ARM64
uses: ./.github/workflows/runner.yml
with:
ec2_instance_type: t4g.medium
ec2_image_id: ami-0aa307ed50ca3e58f # Ubuntu 24.04 LTS arm64 (us-east-1)
instance_name: "Ubuntu-ARM64/$name#$run_number"
secrets: inherit
debian-amd64:
name: Launch Debian AMD64
uses: ./.github/workflows/runner.yml
with:
ec2_instance_type: t3.large
ec2_image_id: ami-0b0012dad04fbe3d7 # Debian 13 x86_64 (us-east-1)
instance_name: "Debian-AMD64/$name#$run_number"
secrets: inherit
debian-arm64:
name: Launch Debian ARM64
uses: ./.github/workflows/runner.yml
with:
ec2_instance_type: t4g.large
ec2_image_id: ami-01b1eba85c1cd6a3d # Debian 13 arm64 (us-east-1)
instance_name: "Debian-ARM64/$name#$run_number"
secrets: inherit
al2023-amd64:
name: Launch AL2023 AMD64
uses: ./.github/workflows/runner.yml
with:
ec2_instance_type: t3.small
ec2_image_id: ami-00ca32bbc84273381 # Amazon Linux 2023 x86_64 (us-east-1)
instance_name: "AL2023-AMD64/$name#$run_number"
secrets: inherit
al2023-arm64:
name: Launch AL2023 ARM64
uses: ./.github/workflows/runner.yml
with:
ec2_instance_type: t4g.small
ec2_image_id: ami-0aa7db6294d00216f # Amazon Linux 2023 arm64 (us-east-1)
instance_name: "AL2023-ARM64/$name#$run_number"
secrets: inherit
# Run test jobs on the launched instances using a matrix
test-matrix:
needs: [ubuntu-amd64, ubuntu-arm64, debian-amd64, debian-arm64, al2023-amd64, al2023-arm64]
name: Test ${{ matrix.os }} ${{ matrix.arch }}
strategy:
matrix:
include:
- os: Ubuntu
arch: AMD64
runner: ${{ needs.ubuntu-amd64.outputs.id }}
expected_arch: x86_64
expected_os_pattern: "Ubuntu"
instance_type: t3.medium
- os: Ubuntu
arch: ARM64
runner: ${{ needs.ubuntu-arm64.outputs.id }}
expected_arch: aarch64
expected_os_pattern: "Ubuntu"
instance_type: t4g.medium
- os: Debian
arch: AMD64
runner: ${{ needs.debian-amd64.outputs.id }}
expected_arch: x86_64
expected_os_pattern: "Debian"
instance_type: t3.large
- os: Debian
arch: ARM64
runner: ${{ needs.debian-arm64.outputs.id }}
expected_arch: aarch64
expected_os_pattern: "Debian"
instance_type: t4g.large
- os: AL2023
arch: AMD64
runner: ${{ needs.al2023-amd64.outputs.id }}
expected_arch: x86_64
expected_os_pattern: "Amazon Linux"
instance_type: t3.small
- os: AL2023
arch: ARM64
runner: ${{ needs.al2023-arm64.outputs.id }}
expected_arch: aarch64
expected_os_pattern: "Amazon Linux"
instance_type: t4g.small
fail-fast: false
runs-on: ${{ matrix.runner }}
steps:
- name: System information
run: |
echo "=== System Information ==="
echo "OS: ${{ matrix.os }}"
echo "Architecture: ${{ matrix.arch }}"
echo "Expected instance type: ${{ matrix.instance_type }}"
echo ""
echo "=== Actual System Details ==="
echo "Hostname: $(hostname)"
echo "Kernel: $(uname -r)"
echo "Architecture: $(uname -m)"
echo "OS Release:"
cat /etc/os-release | head -5
echo ""
echo "=== AWS Instance Details ==="
echo "Instance ID: $(curl -s http://169.254.169.254/latest/meta-data/instance-id)"
echo "Instance type: $(curl -s http://169.254.169.254/latest/meta-data/instance-type)"
echo "Region: $(curl -s http://169.254.169.254/latest/meta-data/placement/region)"
echo "AZ: $(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)"
- name: Verify OS and architecture
run: |
echo "=== Verification ==="
ACTUAL_ARCH=$(uname -m)
OS_NAME=$(grep '^NAME=' /etc/os-release | cut -d'"' -f2)
ACTUAL_INSTANCE_TYPE=$(curl -s http://169.254.169.254/latest/meta-data/instance-type)
# Verify architecture
if [[ "$ACTUAL_ARCH" == "${{ matrix.expected_arch }}" ]]; then
echo "✓ Architecture verified: $ACTUAL_ARCH matches expected ${{ matrix.expected_arch }}"
else
echo "✗ Architecture mismatch: got $ACTUAL_ARCH, expected ${{ matrix.expected_arch }}"
exit 1
fi
# Verify OS
if echo "$OS_NAME" | grep -q "${{ matrix.expected_os_pattern }}"; then
echo "✓ OS verified: $OS_NAME matches expected pattern '${{ matrix.expected_os_pattern }}'"
else
echo "✗ OS mismatch: $OS_NAME does not match expected pattern '${{ matrix.expected_os_pattern }}'"
exit 1
fi
# Verify instance type
if [[ "$ACTUAL_INSTANCE_TYPE" == "${{ matrix.instance_type }}" ]]; then
echo "✓ Instance type verified: $ACTUAL_INSTANCE_TYPE"
else
echo "✗ Instance type mismatch: got $ACTUAL_INSTANCE_TYPE, expected ${{ matrix.instance_type }}"
exit 1
fi
- name: Performance characteristics
run: |
echo "=== Performance Characteristics ==="
echo "CPU cores: $(nproc)"
echo "CPU model: $(lscpu | grep 'Model name:' | cut -d: -f2 | xargs)"
echo "Memory: $(free -h | grep Mem | awk '{print $2}')"
echo "Disk: $(df -h / | tail -1 | awk '{print $2}')"
echo ""
echo "CPU details:"
lscpu | grep -E "Architecture:|CPU\(s\):|Thread\(s\) per core:|Core\(s\) per socket:|Socket\(s\):"
- name: Simulate workload
run: |
DURATION=${{ inputs.sleep }}
echo "=== Workload Simulation ==="
echo "Starting workload at: $(date '+%Y-%m-%d %H:%M:%S.%3N')"
echo "Running on ${{ matrix.os }} ${{ matrix.arch }} for ${DURATION} seconds..."
# Architecture-specific workload
if [[ "${{ matrix.arch }}" == "ARM64" ]]; then
echo "Running ARM-optimized workload simulation..."
# Simulate ARM-specific operations
echo "ARM NEON/SVE capabilities check:"
grep -E "Features|flags" /proc/cpuinfo | head -2 || true
else
echo "Running x86-optimized workload simulation..."
# Simulate x86-specific operations
echo "x86 instruction set extensions:"
grep -E "flags" /proc/cpuinfo | head -1 | grep -o -E "sse|avx|avx2|avx512" | sort -u || true
fi
sleep $DURATION
echo "Workload complete at: $(date '+%Y-%m-%d %H:%M:%S.%3N')"
- name: Package manager test
run: |
echo "=== Package Manager Test ==="
if [[ "${{ matrix.os }}" == "Ubuntu" ]]; then
echo "Ubuntu uses APT package manager"
echo "APT version: $(apt-get --version | head -1)"
echo "Distribution: $(lsb_release -ds 2>/dev/null || cat /etc/os-release | grep PRETTY_NAME | cut -d'"' -f2)"
elif [[ "${{ matrix.os }}" == "Debian" ]]; then
echo "Debian uses APT package manager"
echo "APT version: $(apt-get --version | head -1)"
echo "Distribution: $(cat /etc/debian_version)"
elif [[ "${{ matrix.os }}" == "AL2023" ]]; then
echo "Amazon Linux 2023 uses DNF/YUM package manager"
echo "DNF version: $(dnf --version | head -1)"
echo "Distribution: $(cat /etc/os-release | grep PRETTY_NAME | cut -d'"' -f2)"
fi
# Show architecture-specific packages available
echo ""
echo "Architecture-specific package availability:"
if [[ "${{ matrix.arch }}" == "ARM64" ]]; then
echo "Checking for ARM64-specific packages..."
if [[ "${{ matrix.os }}" == "AL2023" ]]; then
rpm --eval '%{_arch}'
dnf repolist | head -5
else
dpkg --print-architecture
dpkg --print-foreign-architectures || echo "No foreign architectures configured"
fi
else
echo "Checking for AMD64-specific packages..."
if [[ "${{ matrix.os }}" == "AL2023" ]]; then
rpm --eval '%{_arch}'
dnf repolist | head -5
else
dpkg --print-architecture
dpkg --print-foreign-architectures || echo "No foreign architectures configured"
fi
fi
- name: Summary
run: |
echo "=== Test Summary ==="
echo "✓ Successfully tested ${{ matrix.os }} on ${{ matrix.arch }} architecture"
echo "✓ Instance type: ${{ matrix.instance_type }}"
echo "✓ All verifications passed"
echo ""
echo "Matrix configuration demonstrated:"
echo "- OS diversity: Ubuntu 24.04, Debian 13, and Amazon Linux 2023"
echo "- Architecture diversity: AMD64 (x86_64) and ARM64 (aarch64)"
echo "- Instance type variety: t3.small, t3.medium, t3.large, t4g.small, t4g.medium, t4g.large"
echo ""
echo "This workflow shows ec2-gha's ability to:"
echo "1. Launch runners on different OS distributions"
echo "2. Support both x86 and ARM architectures"
echo "3. Use appropriate instance types for each architecture"
echo "4. Run parallel jobs across diverse infrastructure"