|
| 1 | +name: Run Suites |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main", "compat/**"] |
| 6 | + paths: |
| 7 | + - "examples/**" |
| 8 | + - "templates/**" |
| 9 | + pull_request: |
| 10 | + paths: |
| 11 | + - "examples/**" |
| 12 | + - "templates/**" |
| 13 | + workflow_dispatch: |
| 14 | + inputs: |
| 15 | + suite: |
| 16 | + description: "Single suite to test, with parent folder (e.g. examples/cryptolibrary)" |
| 17 | + required: false |
| 18 | + default: "" |
| 19 | + |
| 20 | +jobs: |
| 21 | + # ── Stage 1: detect which suites changed ────────────────────────────────── |
| 22 | + detect-changes: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + outputs: |
| 25 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 2 |
| 30 | + |
| 31 | + - name: Detect changed suites |
| 32 | + id: set-matrix |
| 33 | + run: | |
| 34 | + # Manual trigger with explicit suite override |
| 35 | + if [[ -n "${{ github.event.inputs.suite }}" ]]; then |
| 36 | + echo "matrix=[\"${{ github.event.inputs.suite }}\"]" >> "$GITHUB_OUTPUT" |
| 37 | + exit 0 |
| 38 | + fi |
| 39 | +
|
| 40 | + # Detect changed folders under examples/ and templates/ |
| 41 | + CHANGED=$(git diff --name-only HEAD~1 HEAD \ |
| 42 | + | grep -E '^(examples|templates)/' \ |
| 43 | + | cut -d/ -f1-2 \ |
| 44 | + | sort -u \ |
| 45 | + | jq -R . | jq -sc .) |
| 46 | +
|
| 47 | + # Fall back to all examples + templates if nothing detected (e.g. first commit) |
| 48 | + if [[ "${CHANGED}" == "[]" || -z "${CHANGED}" ]]; then |
| 49 | + CHANGED=$(ls -d examples/*/ templates/*/ 2>/dev/null | sed 's|/$||' | jq -R . | jq -sc .) |
| 50 | + fi |
| 51 | +
|
| 52 | + echo "matrix=${CHANGED}" >> "$GITHUB_OUTPUT" |
| 53 | + echo "The following subfolder have changed and will be tested:" |
| 54 | + echo "${CHANGED}" |
| 55 | +
|
| 56 | + # ── Stage 2: test matrix (os × suite) ───────────────────────────────────── |
| 57 | + test: |
| 58 | + needs: detect-changes |
| 59 | + if: ${{ needs.detect-changes.outputs.matrix != '[]' }} |
| 60 | + runs-on: ${{ matrix.os }} |
| 61 | + strategy: |
| 62 | + fail-fast: false |
| 63 | + matrix: |
| 64 | + os: [ubuntu-latest, windows-latest] |
| 65 | + suite: ${{ fromJson(needs.detect-changes.outputs.matrix) }} |
| 66 | + |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - name: Read RCC space from .rcc file |
| 71 | + id: rcc-space |
| 72 | + shell: bash |
| 73 | + run: | |
| 74 | + SPACE=$(grep '^SPACE=' ${{ matrix.suite }}/.rcc | cut -d= -f2 | tr -d '[:space:]') |
| 75 | + echo "space=${SPACE}" >> "$GITHUB_OUTPUT" |
| 76 | + # Sanitize matrix.suite (e.g. examples/cryptolibrary → examples-cryptolibrary) |
| 77 | + echo "safe_name=$(echo '${{ matrix.suite }}' | tr '/' '-')" >> "$GITHUB_OUTPUT" |
| 78 | +
|
| 79 | + - name: Download RCC |
| 80 | + shell: bash |
| 81 | + run: | |
| 82 | + BASE="https://github.com/elabit/robotmk/releases/download/v4.0.0" |
| 83 | + if [[ "${{ runner.os }}" == "Windows" ]]; then |
| 84 | + curl -fsSL -o rcc.exe "${BASE}/rcc_windows64.exe" |
| 85 | + echo "RCC_BIN=./rcc.exe" >> "$GITHUB_ENV" |
| 86 | + else |
| 87 | + curl -fsSL -o rcc "${BASE}/rcc_linux64" |
| 88 | + chmod +x rcc |
| 89 | + echo "RCC_BIN=./rcc" >> "$GITHUB_ENV" |
| 90 | + fi |
| 91 | + ${RCC_BIN:-./rcc} --version |
| 92 | +
|
| 93 | + - name: Build RCC holotree environment |
| 94 | + shell: bash |
| 95 | + run: | |
| 96 | + $RCC_BIN holotree vars \ |
| 97 | + --space ${{ steps.rcc-space.outputs.space }} \ |
| 98 | + --robot ${{ matrix.suite }}/robot.yaml |
| 99 | +
|
| 100 | + - name: Load .env if present |
| 101 | + shell: bash |
| 102 | + run: | |
| 103 | + ENV_FILE="${{ matrix.suite }}/.env" |
| 104 | + if [[ -f "${ENV_FILE}" ]]; then |
| 105 | + echo "Loading variables from ${ENV_FILE}" |
| 106 | + grep -v '^\s*#' "${ENV_FILE}" | grep -v '^\s*$' >> "$GITHUB_ENV" |
| 107 | + fi |
| 108 | +
|
| 109 | + - name: Run Robot Framework suite |
| 110 | + shell: bash |
| 111 | + run: | |
| 112 | + $RCC_BIN task script \ |
| 113 | + --space ${{ steps.rcc-space.outputs.space }} \ |
| 114 | + --robot ${{ matrix.suite }}/robot.yaml \ |
| 115 | + -- robot . |
| 116 | +
|
| 117 | + - name: Upload RF output artifacts |
| 118 | + if: always() |
| 119 | + uses: actions/upload-artifact@v4 |
| 120 | + with: |
| 121 | + name: rf-output-${{ steps.rcc-space.outputs.safe_name }}-${{ matrix.os }} |
| 122 | + path: ${{ matrix.suite }}/output/ |
| 123 | + if-no-files-found: ignore |
0 commit comments