Skip to content

Commit a384c7c

Browse files
authored
Merge pull request CoplayDev#1143 from Scriptwonder/ci/unity-tests-on-pr
ci: fire unity-tests on every PR (mirrors python-tests pattern)
2 parents 2999427 + a30e596 commit a384c7c

2 files changed

Lines changed: 27 additions & 5 deletions

File tree

.github/workflows/unity-tests.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ on:
1616
- MCPForUnity/Editor/**
1717
- MCPForUnity/Runtime/**
1818
- .github/workflows/unity-tests.yml
19+
# Same-repo PRs get a unity-tests status check on every open / push via this trigger
20+
# (mirrors python-tests.yml). Fork PRs ALSO fire this trigger but run in the fork's
21+
# context without secrets — the detect step downstream writes unity_ok=false and the
22+
# job exits clean with a "missing license secrets" notice so the status check still
23+
# appears. Maintainers apply 'safe-to-test' to invoke pull_request_target below for
24+
# a real fork-PR test run.
25+
pull_request:
26+
branches: [main, beta]
27+
paths:
28+
- TestProjects/UnityMCPTests/**
29+
- MCPForUnity/Editor/**
30+
- MCPForUnity/Runtime/**
31+
- .github/workflows/unity-tests.yml
1932
# Fork PRs: maintainer applies the 'safe-to-test' label after reviewing
2033
# the diff. The workflow runs with UNITY_LICENSE in scope against the
2134
# PR's head SHA. Re-pushed commits do NOT auto-trigger — maintainer must
@@ -29,6 +42,13 @@ on:
2942
- MCPForUnity/Runtime/**
3043
- .github/workflows/unity-tests.yml
3144

45+
# Dedup runs for the same branch across push / pull_request / pull_request_target / workflow_call.
46+
# Same-repo PRs would otherwise fire both push (on the branch SHA) AND pull_request (on the PR);
47+
# concurrency keeps only the newer in-flight run per branch.
48+
concurrency:
49+
group: unity-tests-${{ github.head_ref || github.ref }}
50+
cancel-in-progress: true
51+
3252
jobs:
3353
matrix:
3454
name: Compute Unity version matrix
@@ -71,12 +91,12 @@ jobs:
7191
run: |
7292
set -euo pipefail
7393
# Full matrix on: beta push, workflow_call (release pipelines), workflow_dispatch,
74-
# or any PR labeled with 'full-matrix'.
94+
# or any PR (pull_request OR pull_request_target) labeled with 'full-matrix'.
7595
# Default (single defaultVersion from tools/unity-versions.json) otherwise — fast PR feedback.
7696
if [[ "$EVENT_NAME" == "workflow_dispatch" ]] || \
7797
[[ "$EVENT_NAME" == "workflow_call" ]] || \
7898
{ [[ "$EVENT_NAME" == "push" ]] && [[ "$GH_REF" == "refs/heads/beta" ]]; } || \
79-
{ [[ "$EVENT_NAME" == "pull_request_target" ]] && [[ "$FULL_MATRIX_LABEL" == "true" ]]; }; then
99+
{ { [[ "$EVENT_NAME" == "pull_request" ]] || [[ "$EVENT_NAME" == "pull_request_target" ]]; } && [[ "$FULL_MATRIX_LABEL" == "true" ]]; }; then
80100
versions=$(jq -c '[.versions[].id]' tools/unity-versions.json)
81101
echo "Trigger '$EVENT_NAME' on ref '$GH_REF' (full_matrix_label=$FULL_MATRIX_LABEL) → full matrix: $versions"
82102
else

docs/development/README-DEV.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,18 @@ open htmlcov/index.html
142142

143143
CI exercises the package across multiple Unity versions to catch breaks in `#if UNITY_*_OR_NEWER` branches. The matrix is configured in `tools/unity-versions.json` and consumed by `.github/workflows/unity-tests.yml`.
144144

145+
**Every PR gets a unity-tests status check on open** (mirrors `python-tests.yml`). For same-repo PRs the default Unity 6 leg actually runs; for fork PRs the workflow appears but skips with a "missing license secrets" notice until a maintainer applies `safe-to-test` (existing secret-safety gate). The full 4-version matrix is opt-in via the `full-matrix` label.
146+
145147
**When the full matrix runs (all 4 versions in parallel):**
146148

147149
- Push to `beta` (the release gate).
148150
- `workflow_call` from `beta-release.yml` / `release.yml`.
149151
- Manual `workflow_dispatch` from the Actions tab.
150-
- Any PR (in-repo or fork) labeled with **`full-matrix`** — apply this label when your change touches compat shims, conditional compilation, or anything else version-sensitive. The workflow re-runs with the full matrix on the next `pull_request_target` event. Cost is ~6-8 min wall clock vs ~3 min for the default leg.
152+
- Any PR (in-repo or fork) labeled with **`full-matrix`** — apply when your change touches compat shims, conditional compilation, or anything else version-sensitive. Triggers a full-matrix run on the next `pull_request` or `pull_request_target` event. Cost is ~6-8 min wall clock vs ~3 min for the default leg.
151153

152-
Fork PRs still need `safe-to-test` as the base gate (existing secret-safety pattern); `full-matrix` is layered on top of that for fork-PR full-matrix runs.
154+
Fork PRs still need `safe-to-test` as the base gate (so secrets are exposed against reviewed-only fork code); `full-matrix` is layered on top for fork-PR full-matrix runs.
153155

154-
**Default (single leg) runs on every other path** — feature-branch pushes and unlabeled in-repo PRs run only against `defaultVersion` from `tools/unity-versions.json` (currently Unity 6.0 LTS, `6000.0.75f1`). The `floor` role (`2021.3.45f2`) still identifies the package minimum and runs as part of the full matrix; it's no longer the default-leg version.
156+
**Default (single leg)**every other path runs only against `defaultVersion` from `tools/unity-versions.json` (currently Unity 6.0 LTS, `6000.0.75f1`). The `floor` role (`2021.3.45f2`) still identifies the package minimum and runs as part of the full matrix; it's no longer the default-leg version.
155157

156158
## Local Unity-version parity check
157159

0 commit comments

Comments
 (0)