1- name : Demo – x86 and ARM instances
1+ name : Demo – OS and architecture matrix
22on :
33 workflow_dispatch :
4+ inputs :
5+ sleep :
6+ description : " Sleep duration in seconds for workload simulation"
7+ required : false
8+ type : string
9+ default : " 10"
410 workflow_call : # Tested by `demos.yml`
11+ inputs :
12+ sleep :
13+ required : false
14+ type : string
15+ default : " 10"
16+
517permissions :
618 id-token : write # Required for AWS OIDC authentication
719 contents : read # Required for actions/checkout
20+
821jobs :
9- # Launch EC2 runners for each architecture
10- x86 :
11- name : Launch x86
22+ # Launch EC2 runners for each OS/ architecture combination
23+ ubuntu-amd64 :
24+ name : Launch Ubuntu AMD64
1225 uses : ./.github/workflows/runner.yml
1326 with :
1427 ec2_instance_type : t3.medium
15- ec2_image_id : ami-0e86e20dae9224db8 # Ubuntu 24.04 LTS x86_64 (us-east-1)
28+ ec2_image_id : ami-0ca5a2f40c2601df6 # Ubuntu 24.04 LTS x86_64 (us-east-1)
29+ instance_name : " Ubuntu-AMD64/$name#$run_number"
1630 secrets : inherit
17- arm :
18- name : Launch ARM
31+
32+ ubuntu-arm64 :
33+ name : Launch Ubuntu ARM64
1934 uses : ./.github/workflows/runner.yml
2035 with :
2136 ec2_instance_type : t4g.medium
2237 ec2_image_id : ami-0aa307ed50ca3e58f # Ubuntu 24.04 LTS arm64 (us-east-1)
38+ instance_name : " Ubuntu-ARM64/$name#$run_number"
2339 secrets : inherit
2440
25- # Run jobs directly on launched instances
26- test-x86 :
27- needs : x86
28- if : needs.x86.outputs.id != ''
29- name : Test x86
30- runs-on : ${{ needs.x86.outputs.id }}
31- steps :
32- - name : Architecture test on t3.medium
33- run : |
34- echo "Architecture: $(uname -m)"
35- echo "Processor: $(lscpu | grep 'Architecture:' | awk '{print $2}')"
36- echo "Instance type: $(curl -s http://169.254.169.254/latest/meta-data/instance-type)"
37- test-arm :
38- needs : arm
39- if : needs.arm.outputs.id != ''
40- name : Test ARM
41- runs-on : ${{ needs.arm.outputs.id }}
42- steps :
43- - name : Architecture test on t4g.medium
44- run : |
45- echo "Architecture: $(uname -m)"
46- echo "Processor: $(lscpu | grep 'Architecture:' | awk '{print $2}')"
47- echo "Instance type: $(curl -s http://169.254.169.254/latest/meta-data/instance-type)"
41+ debian-amd64 :
42+ name : Launch Debian AMD64
43+ uses : ./.github/workflows/runner.yml
44+ with :
45+ ec2_instance_type : t3.large
46+ ec2_image_id : ami-0b0012dad04fbe3d7 # Debian 13 x86_64 (us-east-1)
47+ instance_name : " Debian-AMD64/$name#$run_number"
48+ secrets : inherit
49+
50+ debian-arm64 :
51+ name : Launch Debian ARM64
52+ uses : ./.github/workflows/runner.yml
53+ with :
54+ ec2_instance_type : t4g.large
55+ ec2_image_id : ami-01b1eba85c1cd6a3d # Debian 13 arm64 (us-east-1)
56+ instance_name : " Debian-ARM64/$name#$run_number"
57+ secrets : inherit
58+
59+ al2023-amd64 :
60+ name : Launch AL2023 AMD64
61+ uses : ./.github/workflows/runner.yml
62+ with :
63+ ec2_instance_type : t3.small
64+ ec2_image_id : ami-00ca32bbc84273381 # Amazon Linux 2023 x86_64 (us-east-1)
65+ instance_name : " AL2023-AMD64/$name#$run_number"
66+ secrets : inherit
4867
49- # Use a `matrix` to run jobs on multiple instances
68+ al2023-arm64 :
69+ name : Launch AL2023 ARM64
70+ uses : ./.github/workflows/runner.yml
71+ with :
72+ ec2_instance_type : t4g.small
73+ ec2_image_id : ami-0aa7db6294d00216f # Amazon Linux 2023 arm64 (us-east-1)
74+ instance_name : " AL2023-ARM64/$name#$run_number"
75+ secrets : inherit
76+
77+ # Run test jobs on the launched instances using a matrix
5078 test-matrix :
51- needs : [x86, arm]
52- if : always() && (needs.x86.outputs.id != '' || needs.arm.outputs.id != '')
53- name : Test ${{ matrix.arch }} (matrix)
54- continue-on-error : true
79+ needs : [ubuntu-amd64, ubuntu-arm64, debian-amd64, debian-arm64, al2023-amd64, al2023-arm64]
80+ name : Test ${{ matrix.os }} ${{ matrix.arch }}
5581 strategy :
5682 matrix :
5783 include :
58- - arch : x86
59- runner : ${{ needs.x86.outputs.id }}
60- - arch : arm
61- runner : ${{ needs.arm.outputs.id }}
84+ - os : Ubuntu
85+ arch : AMD64
86+ runner : ${{ needs.ubuntu-amd64.outputs.id }}
87+ expected_arch : x86_64
88+ expected_os_pattern : " Ubuntu"
89+ instance_type : t3.medium
90+ - os : Ubuntu
91+ arch : ARM64
92+ runner : ${{ needs.ubuntu-arm64.outputs.id }}
93+ expected_arch : aarch64
94+ expected_os_pattern : " Ubuntu"
95+ instance_type : t4g.medium
96+ - os : Debian
97+ arch : AMD64
98+ runner : ${{ needs.debian-amd64.outputs.id }}
99+ expected_arch : x86_64
100+ expected_os_pattern : " Debian"
101+ instance_type : t3.large
102+ - os : Debian
103+ arch : ARM64
104+ runner : ${{ needs.debian-arm64.outputs.id }}
105+ expected_arch : aarch64
106+ expected_os_pattern : " Debian"
107+ instance_type : t4g.large
108+ - os : AL2023
109+ arch : AMD64
110+ runner : ${{ needs.al2023-amd64.outputs.id }}
111+ expected_arch : x86_64
112+ expected_os_pattern : " Amazon Linux"
113+ instance_type : t3.small
114+ - os : AL2023
115+ arch : ARM64
116+ runner : ${{ needs.al2023-arm64.outputs.id }}
117+ expected_arch : aarch64
118+ expected_os_pattern : " Amazon Linux"
119+ instance_type : t4g.small
62120 fail-fast : false
63121 runs-on : ${{ matrix.runner }}
64122 steps :
65- - name : Matrix architecture test
66- run : |
67- echo "Running on ${{ matrix.arch }}"
68- echo "Architecture: $(uname -m)"
69- echo "Instance type: $(curl -s http://169.254.169.254/latest/meta-data/instance-type)"
70-
71- # Verify expected architecture
72- if [[ "${{ matrix.arch }}" == "x86" ]]; then
73- echo "Verifying x86_64 architecture..."
74- [[ "$(uname -m)" == "x86_64" ]] && echo "✓ Confirmed x86_64" || exit 1
75- elif [[ "${{ matrix.arch }}" == "arm" ]]; then
76- echo "Verifying ARM architecture..."
77- [[ "$(uname -m)" == "aarch64" ]] && echo "✓ Confirmed aarch64" || exit 1
78- fi
123+ - name : System information
124+ run : |
125+ echo "=== System Information ==="
126+ echo "OS: ${{ matrix.os }}"
127+ echo "Architecture: ${{ matrix.arch }}"
128+ echo "Expected instance type: ${{ matrix.instance_type }}"
129+ echo ""
130+ echo "=== Actual System Details ==="
131+ echo "Hostname: $(hostname)"
132+ echo "Kernel: $(uname -r)"
133+ echo "Architecture: $(uname -m)"
134+ echo "OS Release:"
135+ cat /etc/os-release | head -5
136+ echo ""
137+ echo "=== AWS Instance Details ==="
138+ echo "Instance ID: $(curl -s http://169.254.169.254/latest/meta-data/instance-id)"
139+ echo "Instance type: $(curl -s http://169.254.169.254/latest/meta-data/instance-type)"
140+ echo "Region: $(curl -s http://169.254.169.254/latest/meta-data/placement/region)"
141+ echo "AZ: $(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)"
142+
143+ - name : Verify OS and architecture
144+ run : |
145+ echo "=== Verification ==="
146+ ACTUAL_ARCH=$(uname -m)
147+ OS_NAME=$(grep '^NAME=' /etc/os-release | cut -d'"' -f2)
148+ ACTUAL_INSTANCE_TYPE=$(curl -s http://169.254.169.254/latest/meta-data/instance-type)
149+
150+ # Verify architecture
151+ if [[ "$ACTUAL_ARCH" == "${{ matrix.expected_arch }}" ]]; then
152+ echo "✓ Architecture verified: $ACTUAL_ARCH matches expected ${{ matrix.expected_arch }}"
153+ else
154+ echo "✗ Architecture mismatch: got $ACTUAL_ARCH, expected ${{ matrix.expected_arch }}"
155+ exit 1
156+ fi
157+
158+ # Verify OS
159+ if echo "$OS_NAME" | grep -q "${{ matrix.expected_os_pattern }}"; then
160+ echo "✓ OS verified: $OS_NAME matches expected pattern '${{ matrix.expected_os_pattern }}'"
161+ else
162+ echo "✗ OS mismatch: $OS_NAME does not match expected pattern '${{ matrix.expected_os_pattern }}'"
163+ exit 1
164+ fi
165+
166+ # Verify instance type
167+ if [[ "$ACTUAL_INSTANCE_TYPE" == "${{ matrix.instance_type }}" ]]; then
168+ echo "✓ Instance type verified: $ACTUAL_INSTANCE_TYPE"
169+ else
170+ echo "✗ Instance type mismatch: got $ACTUAL_INSTANCE_TYPE, expected ${{ matrix.instance_type }}"
171+ exit 1
172+ fi
173+
174+ - name : Performance characteristics
175+ run : |
176+ echo "=== Performance Characteristics ==="
177+ echo "CPU cores: $(nproc)"
178+ echo "CPU model: $(lscpu | grep 'Model name:' | cut -d: -f2 | xargs)"
179+ echo "Memory: $(free -h | grep Mem | awk '{print $2}')"
180+ echo "Disk: $(df -h / | tail -1 | awk '{print $2}')"
181+ echo ""
182+ echo "CPU details:"
183+ lscpu | grep -E "Architecture:|CPU\(s\):|Thread\(s\) per core:|Core\(s\) per socket:|Socket\(s\):"
184+
185+ - name : Simulate workload
186+ run : |
187+ DURATION=${{ inputs.sleep }}
188+ echo "=== Workload Simulation ==="
189+ echo "Starting workload at: $(date '+%Y-%m-%d %H:%M:%S.%3N')"
190+ echo "Running on ${{ matrix.os }} ${{ matrix.arch }} for ${DURATION} seconds..."
191+
192+ # Architecture-specific workload
193+ if [[ "${{ matrix.arch }}" == "ARM64" ]]; then
194+ echo "Running ARM-optimized workload simulation..."
195+ # Simulate ARM-specific operations
196+ echo "ARM NEON/SVE capabilities check:"
197+ grep -E "Features|flags" /proc/cpuinfo | head -2 || true
198+ else
199+ echo "Running x86-optimized workload simulation..."
200+ # Simulate x86-specific operations
201+ echo "x86 instruction set extensions:"
202+ grep -E "flags" /proc/cpuinfo | head -1 | grep -o -E "sse|avx|avx2|avx512" | sort -u || true
203+ fi
204+
205+ sleep $DURATION
206+ echo "Workload complete at: $(date '+%Y-%m-%d %H:%M:%S.%3N')"
207+
208+ - name : Package manager test
209+ run : |
210+ echo "=== Package Manager Test ==="
211+ if [[ "${{ matrix.os }}" == "Ubuntu" ]]; then
212+ echo "Ubuntu uses APT package manager"
213+ echo "APT version: $(apt-get --version | head -1)"
214+ echo "Distribution: $(lsb_release -ds 2>/dev/null || cat /etc/os-release | grep PRETTY_NAME | cut -d'"' -f2)"
215+ elif [[ "${{ matrix.os }}" == "Debian" ]]; then
216+ echo "Debian uses APT package manager"
217+ echo "APT version: $(apt-get --version | head -1)"
218+ echo "Distribution: $(cat /etc/debian_version)"
219+ elif [[ "${{ matrix.os }}" == "AL2023" ]]; then
220+ echo "Amazon Linux 2023 uses DNF/YUM package manager"
221+ echo "DNF version: $(dnf --version | head -1)"
222+ echo "Distribution: $(cat /etc/os-release | grep PRETTY_NAME | cut -d'"' -f2)"
223+ fi
224+
225+ # Show architecture-specific packages available
226+ echo ""
227+ echo "Architecture-specific package availability:"
228+ if [[ "${{ matrix.arch }}" == "ARM64" ]]; then
229+ echo "Checking for ARM64-specific packages..."
230+ if [[ "${{ matrix.os }}" == "AL2023" ]]; then
231+ rpm --eval '%{_arch}'
232+ dnf repolist | head -5
233+ else
234+ dpkg --print-architecture
235+ dpkg --print-foreign-architectures || echo "No foreign architectures configured"
236+ fi
237+ else
238+ echo "Checking for AMD64-specific packages..."
239+ if [[ "${{ matrix.os }}" == "AL2023" ]]; then
240+ rpm --eval '%{_arch}'
241+ dnf repolist | head -5
242+ else
243+ dpkg --print-architecture
244+ dpkg --print-foreign-architectures || echo "No foreign architectures configured"
245+ fi
246+ fi
247+
248+ - name : Summary
249+ run : |
250+ echo "=== Test Summary ==="
251+ echo "✓ Successfully tested ${{ matrix.os }} on ${{ matrix.arch }} architecture"
252+ echo "✓ Instance type: ${{ matrix.instance_type }}"
253+ echo "✓ All verifications passed"
254+ echo ""
255+ echo "Matrix configuration demonstrated:"
256+ echo "- OS diversity: Ubuntu 24.04, Debian 13, and Amazon Linux 2023"
257+ echo "- Architecture diversity: AMD64 (x86_64) and ARM64 (aarch64)"
258+ echo "- Instance type variety: t3.small, t3.medium, t3.large, t4g.small, t4g.medium, t4g.large"
259+ echo ""
260+ echo "This workflow shows ec2-gha's ability to:"
261+ echo "1. Launch runners on different OS distributions"
262+ echo "2. Support both x86 and ARM architectures"
263+ echo "3. Use appropriate instance types for each architecture"
264+ echo "4. Run parallel jobs across diverse infrastructure"
0 commit comments