Skip to content

ci: add test step

ci: add test step #6

name: Build and upload AML artifacts
on:
push:
pull_request:
workflow_dispatch:
jobs:
build:
name: Configure, build and upload per-platform artifacts
runs-on: ubuntu-latest
outputs:
platforms: ${{ steps.prepare.outputs.platforms }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake ninja-build python3 python3-pip jq
- name: Configure CMake
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build -- -j$(nproc)
- name: Run test suite
run: |
set -euo pipefail
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 test/run_all_tests.py
- name: Collect AMLs into per-platform directories
id: prepare
run: |
set -euo pipefail
mkdir -p artifacts
platforms=()
for dir in build/*/builtin; do
if [ -d "$dir" ]; then
shopt -s nullglob
aml_files=("$dir"/*.aml)
if [ ${#aml_files[@]} -gt 0 ]; then
platform=$(basename "$(dirname "$dir")")
echo "Packaging $platform into directory..."
mkdir -p "artifacts/${platform}"
cp -f "$dir"/*.aml "artifacts/${platform}/" || true
platforms+=("$platform")
fi
shopt -u nullglob
fi
done
# Convert platforms array to JSON using jq
if [ ${#platforms[@]} -gt 0 ]; then
PLATFORMS_JSON=$(printf '%s\n' "${platforms[@]}" | jq -R -s -c 'split("\n")[:-1]')
else
PLATFORMS_JSON='[]'
fi
echo "Found platforms: $PLATFORMS_JSON"
echo "platforms=$PLATFORMS_JSON" >> $GITHUB_OUTPUT
- name: Upload all platform directories as a single artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: aml-all
path: artifacts
upload:
name: Upload platform artifacts
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform: ${{ fromJson(needs.build.outputs.platforms) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download aml-all artifact
uses: actions/download-artifact@v4
with:
name: aml-all
path: ./
- name: Upload per-platform artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}
path: aml-all/artifacts/${{ matrix.platform }}