Skip to content

init commit

init commit #7

Workflow file for this run

name: Test Examples
on:
push:
branches: ["main", "compat/**"]
paths:
- "examples/**"
- "templates/**"
pull_request:
paths:
- "examples/**"
- "templates/**"
workflow_dispatch:
inputs:
example:
description: "Single example to test, with parent folder (e.g. examples/cryptolibrary)"
required: false
default: ""
jobs:
# ── Stage 1: detect which examples changed ──────────────────────────────────
detect-changes:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Detect changed examples
id: set-matrix
run: |
# Manual trigger with explicit example override
if [[ -n "${{ github.event.inputs.example }}" ]]; then
echo "matrix=[\"${{ github.event.inputs.example }}\"]" >> "$GITHUB_OUTPUT"
exit 0
fi
# Detect changed folders under examples/ and templates/
CHANGED=$(git diff --name-only HEAD~1 HEAD \
| grep -E '^(examples|templates)/' \
| cut -d/ -f1-2 \
| sort -u \
| jq -R . | jq -sc .)
# Fall back to all examples + templates if nothing detected (e.g. first commit)
if [[ "${CHANGED}" == "[]" || -z "${CHANGED}" ]]; then
CHANGED=$(ls -d examples/*/ templates/*/ 2>/dev/null | sed 's|/$||' | jq -R . | jq -sc .)
fi
echo "matrix=${CHANGED}" >> "$GITHUB_OUTPUT"
echo "The following subfolder have changed and will be tested:"
echo "${CHANGED}"
# ── Stage 2: test matrix (os × example) ─────────────────────────────────────
test:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.matrix != '[]' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
example: ${{ fromJson(needs.detect-changes.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Read RCC space from .rcc file
id: rcc-space
shell: bash
run: |
SPACE=$(grep '^SPACE=' ${{ matrix.example }}/.rcc | cut -d= -f2 | tr -d '[:space:]')
echo "space=${SPACE}" >> "$GITHUB_OUTPUT"
# Sanitize matrix.example (e.g. examples/cryptolibrary → examples-cryptolibrary)
echo "safe_name=$(echo '${{ matrix.example }}' | tr '/' '-')" >> "$GITHUB_OUTPUT"
- name: Download RCC
shell: bash
run: |
BASE="https://github.com/elabit/robotmk/releases/download/v4.0.0"
if [[ "${{ runner.os }}" == "Windows" ]]; then
curl -fsSL -o rcc.exe "${BASE}/rcc_windows64.exe"
echo "RCC_BIN=./rcc.exe" >> "$GITHUB_ENV"
else
curl -fsSL -o rcc "${BASE}/rcc_linux64"
chmod +x rcc
echo "RCC_BIN=./rcc" >> "$GITHUB_ENV"
fi
${RCC_BIN:-./rcc} --version
- name: Build RCC holotree environment
shell: bash
run: |
$RCC_BIN holotree vars \
--space ${{ steps.rcc-space.outputs.space }} \
--robot ${{ matrix.example }}/robot.yaml
- name: Run Robot Framework suite
shell: bash
run: |
$RCC_BIN task script \
--space ${{ steps.rcc-space.outputs.space }} \
--robot ${{ matrix.example }}/robot.yaml \
-- robot .
- name: Upload RF output artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: rf-output-${{ steps.rcc-space.outputs.safe_name }}-${{ matrix.os }}
path: ${{ matrix.example }}/output/
if-no-files-found: ignore