Lazify pat-upload: split registration from implementation #236
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: Robot Tests (Coredev) | |
| # Trigger commands (PR comments): | |
| # /run-coredev-robottests -> tests against the buildout.coredev default branch | |
| # /run-coredev-6.3-robottests -> tests against an explicit coredev branch (6.1, 6.2, 6.3, ...) | |
| on: | |
| issue_comment: | |
| types: [created] | |
| jobs: | |
| create-check: | |
| if: > | |
| github.event.issue.pull_request && | |
| contains(github.event.comment.body, '/run-coredev') && | |
| contains(github.event.comment.body, '-robottests') | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matched: ${{ steps.create.outputs.matched }} | |
| coredev_branch: ${{ steps.create.outputs.coredev_branch }} | |
| check_run_id: ${{ steps.create.outputs.check_run_id }} | |
| sha: ${{ steps.create.outputs.sha }} | |
| steps: | |
| - name: Parse command, get PR SHA and create Check Run | |
| id: create | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const body = context.payload.comment.body; | |
| // "/run-coredev-robottests" or "/run-coredev-<major.minor>-robottests" | |
| const match = body.match(/\/run-coredev(?:-([0-9]+\.[0-9]+))?-robottests/); | |
| if (!match) { | |
| core.setOutput('matched', 'false'); | |
| core.notice(`Comment matched the coarse filter but not the command syntax.`); | |
| return; | |
| } | |
| const coredevBranch = match[1] || ''; | |
| core.setOutput('matched', 'true'); | |
| core.setOutput('coredev_branch', coredevBranch); | |
| if (coredevBranch) { | |
| try { | |
| await github.rest.repos.getBranch({ | |
| owner: 'plone', | |
| repo: 'buildout.coredev', | |
| branch: coredevBranch, | |
| }); | |
| } catch (e) { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: `:x: Branch \`${coredevBranch}\` does not exist on plone/buildout.coredev.`, | |
| }); | |
| core.setFailed(`Unknown coredev branch: ${coredevBranch}`); | |
| return; | |
| } | |
| } | |
| const pr = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.issue.number, | |
| }); | |
| const sha = pr.data.head.sha; | |
| const checkName = coredevBranch | |
| ? `Coredev robot tests (${coredevBranch})` | |
| : 'Coredev robot tests'; | |
| const check = await github.rest.checks.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| name: checkName, | |
| head_sha: sha, | |
| status: 'in_progress', | |
| details_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, | |
| }); | |
| core.setOutput('sha', sha); | |
| core.setOutput('check_run_id', String(check.data.id)); | |
| robot-tests: | |
| needs: create-check | |
| if: needs.create-check.outputs.matched == 'true' | |
| name: Coredev robot tests ${{ needs.create-check.outputs.coredev_branch }} | |
| runs-on: ubuntu-latest | |
| env: | |
| PYTHONWARNINGS: ignore | |
| GIT_CLONE_DEPTH: 1 | |
| zope_i18n_compile_mo_files: 'true' | |
| ROBOTSUITE_LOGLEVEL: ERROR | |
| ROBOTSUITE_PREFIX: ONLYROBOT | |
| NODE_OPTIONS: "--max_old_space_size=8192" | |
| steps: | |
| - name: Acknowledge command | |
| uses: peter-evans/create-or-update-comment@v4 | |
| with: | |
| comment-id: ${{ github.event.comment.id }} | |
| reactions: '+1' | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Info | |
| run: | | |
| echo "Workflow triggered by comment on PR #${{ github.event.issue.number }}" | |
| echo "buildout.coredev branch: '${{ needs.create-check.outputs.coredev_branch }}' (empty = default branch)" | |
| - name: locale | |
| # needed for CMFPlone testUnicodeSplitter test on Ubuntu | |
| run: | | |
| sudo locale-gen nl_NL@euro | |
| sudo update-locale | |
| # ── 1. Checkout repositories ───────────────────────────────────────────── | |
| - name: Checkout mockup PR | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.create-check.outputs.sha }} | |
| - name: Checkout buildout.coredev | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: plone/buildout.coredev | |
| ref: ${{ needs.create-check.outputs.coredev_branch }} | |
| path: tests | |
| # ── 2. Node.js setup ────────────────────────────────────────────────────── | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: pnpm | |
| - name: Install pnpm dependencies | |
| run: pnpm install | |
| # ── 3. Python / make install ───────────────────────────────────────────── | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| cache: pip | |
| cache-dependency-path: tests/requirements.txt | |
| - name: Mark plone.staticresources as source checkout | |
| run: | | |
| echo " plone.staticresources" >> tests/checkouts.cfg | |
| - name: Install (checks out plone.staticresources via mxdev) | |
| working-directory: tests | |
| run: make install | |
| # ── 2b. Build mockup bundle into tests/src/plone.staticresources ───────── | |
| - name: Build mockup for tests (webpack) | |
| run: pnpm build:webpack:tests | |
| # ── 4. Install Playwright / rfbrowser ──────────────────────────────────── | |
| - name: install rfbrowser | |
| working-directory: tests | |
| run: .venv/bin/rfbrowser init chromium | |
| - name: Run Coredev robot tests | |
| working-directory: tests | |
| run: ROBOTSUITE_PREFIX=ONLYROBOT TEST_ARGS="--all -t ONLYROBOT" make test | |
| - name: Upload robot test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: robot-results-${{ needs.create-check.outputs.coredev_branch || 'default' }} | |
| path: | | |
| tests/test_* | |
| tests/robot_* | |
| if-no-files-found: ignore | |
| update-check: | |
| needs: [create-check, robot-tests] | |
| if: always() && needs.create-check.outputs.check_run_id | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Update Check Run | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| await github.rest.checks.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| check_run_id: ${{ needs.create-check.outputs.check_run_id }}, | |
| status: 'completed', | |
| conclusion: '${{ needs.robot-tests.result }}', | |
| }); |