init commit #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 (leave empty for all changed)" | |
| 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/ or templates/ | |
| CHANGED=$(git diff --name-only HEAD~1 HEAD \ | |
| | grep -E '^(examples|templates)/' \ | |
| | awk -F'/' '{print $2}' \ | |
| | sort -u \ | |
| | jq -R . | jq -sc .) | |
| # Fall back to all examples if nothing detected (e.g. first commit) | |
| if [[ "${CHANGED}" == "[]" || -z "${CHANGED}" ]]; then | |
| CHANGED=$(ls examples/ | jq -R . | jq -sc .) | |
| fi | |
| echo "matrix=${CHANGED}" >> "$GITHUB_OUTPUT" | |
| echo "Changed examples: ${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=' examples/${{ matrix.example }}/.rcc | cut -d= -f2 | tr -d '[:space:]') | |
| echo "space=${SPACE}" >> "$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 examples/${{ matrix.example }}/robot.yaml | |
| - name: Run Robot Framework suite | |
| shell: bash | |
| run: | | |
| $RCC_BIN task script \ | |
| --space ${{ steps.rcc-space.outputs.space }} \ | |
| --robot examples/${{ matrix.example }}/robot.yaml \ | |
| -- robot examples/${{ matrix.example }} | |
| - name: Upload RF output artifacts | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: rf-output-${{ matrix.example }}-${{ matrix.os }} | |
| path: examples/${{ matrix.example }}/output/ | |
| if-no-files-found: ignore |