|
1 | 1 | name: Robot Tests (Coredev) |
2 | 2 |
|
| 3 | +# Trigger commands (PR comments): |
| 4 | +# /run-coredev-robottests -> tests against the buildout.coredev default branch |
| 5 | +# /run-coredev-6.3-robottests -> tests against an explicit coredev branch (6.1, 6.2, 6.3, ...) |
3 | 6 | on: |
4 | 7 | issue_comment: |
5 | 8 | types: [created] |
|
8 | 11 | create-check: |
9 | 12 | if: > |
10 | 13 | github.event.issue.pull_request && |
11 | | - contains(github.event.comment.body, '/run-coredev-robottests') |
| 14 | + contains(github.event.comment.body, '/run-coredev') && |
| 15 | + contains(github.event.comment.body, '-robottests') |
12 | 16 | runs-on: ubuntu-latest |
13 | 17 | outputs: |
| 18 | + matched: ${{ steps.create.outputs.matched }} |
| 19 | + coredev_branch: ${{ steps.create.outputs.coredev_branch }} |
14 | 20 | check_run_id: ${{ steps.create.outputs.check_run_id }} |
15 | 21 | sha: ${{ steps.create.outputs.sha }} |
16 | 22 | steps: |
17 | | - - name: Get PR SHA and create Check Run |
| 23 | + - name: Parse command, get PR SHA and create Check Run |
18 | 24 | id: create |
19 | 25 | uses: actions/github-script@v9 |
20 | 26 | with: |
21 | 27 | script: | |
| 28 | + const body = context.payload.comment.body; |
| 29 | + // "/run-coredev-robottests" or "/run-coredev-<major.minor>-robottests" |
| 30 | + const match = body.match(/\/run-coredev(?:-([0-9]+\.[0-9]+))?-robottests/); |
| 31 | + if (!match) { |
| 32 | + core.setOutput('matched', 'false'); |
| 33 | + core.notice(`Comment matched the coarse filter but not the command syntax.`); |
| 34 | + return; |
| 35 | + } |
| 36 | + const coredevBranch = match[1] || ''; |
| 37 | + core.setOutput('matched', 'true'); |
| 38 | + core.setOutput('coredev_branch', coredevBranch); |
| 39 | +
|
| 40 | + if (coredevBranch) { |
| 41 | + try { |
| 42 | + await github.rest.repos.getBranch({ |
| 43 | + owner: 'plone', |
| 44 | + repo: 'buildout.coredev', |
| 45 | + branch: coredevBranch, |
| 46 | + }); |
| 47 | + } catch (e) { |
| 48 | + await github.rest.issues.createComment({ |
| 49 | + owner: context.repo.owner, |
| 50 | + repo: context.repo.repo, |
| 51 | + issue_number: context.issue.number, |
| 52 | + body: `:x: Branch \`${coredevBranch}\` does not exist on plone/buildout.coredev.`, |
| 53 | + }); |
| 54 | + core.setFailed(`Unknown coredev branch: ${coredevBranch}`); |
| 55 | + return; |
| 56 | + } |
| 57 | + } |
| 58 | +
|
22 | 59 | const pr = await github.rest.pulls.get({ |
23 | 60 | owner: context.repo.owner, |
24 | 61 | repo: context.repo.repo, |
25 | 62 | pull_number: context.issue.number, |
26 | 63 | }); |
27 | 64 | const sha = pr.data.head.sha; |
28 | 65 |
|
| 66 | + const checkName = coredevBranch |
| 67 | + ? `Coredev robot tests (${coredevBranch})` |
| 68 | + : 'Coredev robot tests'; |
29 | 69 | const check = await github.rest.checks.create({ |
30 | 70 | owner: context.repo.owner, |
31 | 71 | repo: context.repo.repo, |
32 | | - name: 'Coredev robot tests', |
| 72 | + name: checkName, |
33 | 73 | head_sha: sha, |
34 | 74 | status: 'in_progress', |
35 | 75 | details_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, |
|
40 | 80 |
|
41 | 81 | robot-tests: |
42 | 82 | needs: create-check |
| 83 | + if: needs.create-check.outputs.matched == 'true' |
43 | 84 |
|
44 | | - name: Coredev robot tests |
| 85 | + name: Coredev robot tests ${{ needs.create-check.outputs.coredev_branch }} |
45 | 86 | runs-on: ubuntu-latest |
46 | 87 | env: |
47 | 88 | PYTHONWARNINGS: ignore |
|
61 | 102 |
|
62 | 103 | - name: Info |
63 | 104 | run: | |
64 | | - echo "Workflow triggered with comment '/run-coredev-robottests' " |
65 | | - echo "on PR #${{ github.event.issue.number }}" |
| 105 | + echo "Workflow triggered by comment on PR #${{ github.event.issue.number }}" |
| 106 | + echo "buildout.coredev branch: '${{ needs.create-check.outputs.coredev_branch }}' (empty = default branch)" |
66 | 107 |
|
67 | 108 | - name: locale |
68 | 109 | # needed for CMFPlone testUnicodeSplitter test on Ubuntu |
|
80 | 121 | uses: actions/checkout@v4 |
81 | 122 | with: |
82 | 123 | repository: plone/buildout.coredev |
| 124 | + ref: ${{ needs.create-check.outputs.coredev_branch }} |
83 | 125 | path: tests |
84 | 126 |
|
85 | 127 | # ── 2. Node.js setup ────────────────────────────────────────────────────── |
@@ -128,15 +170,15 @@ jobs: |
128 | 170 | if: always() |
129 | 171 | uses: actions/upload-artifact@v4 |
130 | 172 | with: |
131 | | - name: robot-results |
| 173 | + name: robot-results-${{ needs.create-check.outputs.coredev_branch || 'default' }} |
132 | 174 | path: | |
133 | 175 | tests/test_* |
134 | 176 | tests/robot_* |
135 | 177 | if-no-files-found: ignore |
136 | 178 |
|
137 | 179 | update-check: |
138 | 180 | needs: [create-check, robot-tests] |
139 | | - if: needs.create-check.outputs.check_run_id |
| 181 | + if: always() && needs.create-check.outputs.check_run_id |
140 | 182 | runs-on: ubuntu-latest |
141 | 183 | steps: |
142 | 184 | - name: Update Check Run |
|
0 commit comments