Skip to content

Commit 666ef8f

Browse files
committed
chore(ci): strengthen Unity and native release gates
1 parent 43f5077 commit 666ef8f

8 files changed

Lines changed: 180 additions & 2 deletions

File tree

.github/pull_request_template.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,14 @@ Descrivi il comportamento modificato e il motivo.
2121
## Evidenza manuale
2222

2323
Indica sistema operativo, versione Unity, dispositivo di input e risultato.
24+
Per modifiche Unity, registra separatamente i totali EditMode e PlayMode usando
25+
il gate descritto in `docs/development/unity-test-gate.md`. Se il job automatico
26+
e disattivato o non riceve i secret nelle PR da fork, questa evidenza e
27+
obbligatoria prima del merge.
28+
29+
- Commit testato:
30+
- Unity Editor:
31+
- Sistema/architettura:
32+
- EditMode (passed/failed/skipped):
33+
- PlayMode (passed/failed/skipped):
34+
- Motivo di eventuali test non eseguiti:

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,57 @@ jobs:
7171

7272
native-coremidi:
7373
runs-on: macos-15
74+
timeout-minutes: 15
7475
steps:
7576
- uses: actions/checkout@v7
7677
with:
7778
persist-credentials: false
7879
- name: Build and test the macOS arm64 CoreMIDI plug-in
7980
run: ./scripts/build-coremidi-plugin-macos-arm64.sh
81+
82+
unity-tests:
83+
name: Unity ${{ matrix.test-mode }}
84+
if: >-
85+
vars.UNITY_CI_ENABLED == 'true' &&
86+
(github.event_name != 'pull_request' ||
87+
github.event.pull_request.head.repo.full_name == github.repository)
88+
runs-on: ubuntu-latest
89+
timeout-minutes: 45
90+
permissions:
91+
contents: read
92+
checks: write
93+
strategy:
94+
fail-fast: false
95+
matrix:
96+
test-mode: [editmode, playmode]
97+
steps:
98+
- uses: actions/checkout@v7
99+
with:
100+
persist-credentials: false
101+
- uses: actions/setup-dotnet@v6
102+
with:
103+
global-json-file: global.json
104+
- name: Synchronize tested Core assembly into Unity
105+
run: ./scripts/sync-core-to-unity.sh
106+
- name: Run Unity tests
107+
id: unity-tests
108+
uses: game-ci/unity-test-runner@v4
109+
env:
110+
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
111+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
112+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
113+
with:
114+
projectPath: src/HitTheKit.Unity
115+
unityVersion: 6000.5.6f1
116+
testMode: ${{ matrix.test-mode }}
117+
artifactsPath: artifacts/unity-${{ matrix.test-mode }}
118+
githubToken: ${{ secrets.GITHUB_TOKEN }}
119+
checkName: Unity ${{ matrix.test-mode }} results
120+
- name: Upload Unity test evidence
121+
if: always()
122+
uses: actions/upload-artifact@v7
123+
with:
124+
name: unity-${{ matrix.test-mode }}-results
125+
path: ${{ steps.unity-tests.outputs.artifactsPath }}
126+
if-no-files-found: warn
127+
retention-days: 14

.github/workflows/codeql.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ permissions:
1212
security-events: write
1313

1414
jobs:
15-
analyze:
15+
analyze-csharp:
16+
name: Analyze C#
1617
runs-on: ubuntu-latest
1718
steps:
1819
- uses: actions/checkout@v7
@@ -26,3 +27,23 @@ jobs:
2627
languages: csharp
2728
- uses: github/codeql-action/autobuild@v4
2829
- uses: github/codeql-action/analyze@v4
30+
with:
31+
category: /language:csharp
32+
33+
analyze-cpp:
34+
name: Analyze CoreMIDI C++
35+
runs-on: macos-15
36+
timeout-minutes: 20
37+
steps:
38+
- uses: actions/checkout@v7
39+
with:
40+
persist-credentials: false
41+
- uses: github/codeql-action/init@v4
42+
with:
43+
languages: c-cpp
44+
build-mode: manual
45+
- name: Build and test the native CoreMIDI plug-in under CodeQL
46+
run: ./scripts/build-coremidi-plugin-macos-arm64.sh
47+
- uses: github/codeql-action/analyze@v4
48+
with:
49+
category: /language:c-cpp

.github/workflows/source-release.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,26 @@ jobs:
4040
mkdir -p artifacts/source
4141
./scripts/create-public-source-snapshot.sh "artifacts/source/HitTheKit-source-$RELEASE_VERSION.tar.gz"
4242
sha256sum "artifacts/source/HitTheKit-source-$RELEASE_VERSION.tar.gz" > artifacts/source/SHA256SUMS
43+
- name: Verify source snapshot checksum
44+
working-directory: artifacts/source
45+
run: sha256sum --check SHA256SUMS
4346
- name: Attest source provenance
47+
id: attest-source
4448
uses: actions/attest@v4
4549
with:
4650
subject-path: artifacts/source/HitTheKit-source-${{ inputs.version }}.tar.gz
51+
- name: Record source release evidence
52+
run: |
53+
{
54+
printf 'repository=%s\n' "$GITHUB_REPOSITORY"
55+
printf 'commit=%s\n' "$GITHUB_SHA"
56+
printf 'version=%s\n' "$RELEASE_VERSION"
57+
printf 'attestation-url=%s\n' '${{ steps.attest-source.outputs.attestation-url }}'
58+
} > artifacts/source/RELEASE-EVIDENCE.txt
4759
- name: Upload source release evidence
4860
uses: actions/upload-artifact@v7
4961
with:
5062
name: HitTheKit-source-${{ inputs.version }}
5163
path: artifacts/source
5264
if-no-files-found: error
65+
retention-days: 30

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ without creating an unreviewed second source of truth.
5252
- [Portable MIDI capture](development/portable-midi-capture.md)
5353
- [CoreMIDI plug-in build](development/coremidi-plugin-build.md)
5454
- [CoreMIDI hardware smoke test](development/coremidi-hardware-smoke.md)
55+
- [Unity EditMode/PlayMode gate](development/unity-test-gate.md)
5556
- [URP migration](development/urp-migration.md)
5657

5758
## Packaging and release
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Unity EditMode/PlayMode gate
2+
3+
Unity changes are not considered validated by the .NET suite alone. The exact
4+
candidate commit must pass both Unity EditMode and PlayMode using Unity
5+
`6000.5.6f1`.
6+
7+
## Automated gate
8+
9+
The `unity-tests` CI matrix contains independent `editmode` and `playmode`
10+
jobs. It is deliberately controlled by the repository variable
11+
`UNITY_CI_ENABLED`.
12+
13+
Keep the variable set to `false` until these repository secrets contain valid
14+
Unity Personal or Professional CI credentials:
15+
16+
- `UNITY_LICENSE`;
17+
- `UNITY_EMAIL`;
18+
- `UNITY_PASSWORD`.
19+
20+
After replacing the placeholder values, set `UNITY_CI_ENABLED=true` and run the
21+
workflow manually or update a trusted branch. Confirm both jobs produce XML and
22+
log artifacts before making them required branch checks.
23+
24+
Repository secrets are unavailable to pull requests from forks by design. Do
25+
not use `pull_request_target` to execute untrusted Unity project code with
26+
secrets. A maintainer must run the manual gate on the fork commit instead.
27+
28+
## Manual gate
29+
30+
From a clean checkout on macOS with Unity Hub Editor `6000.5.6f1` installed:
31+
32+
```sh
33+
./scripts/sync-core-to-unity.sh
34+
35+
UNITY_EDITOR=/Applications/Unity/Hub/Editor/6000.5.6f1/Unity.app/Contents/MacOS/Unity
36+
PROJECT_PATH="$PWD/src/HitTheKit.Unity"
37+
RESULT_ROOT="$PWD/artifacts/unity-tests"
38+
mkdir -p "$RESULT_ROOT"
39+
40+
"$UNITY_EDITOR" -batchmode -projectPath "$PROJECT_PATH" \
41+
-runTests -testPlatform EditMode \
42+
-testResults "$RESULT_ROOT/editmode-results.xml" \
43+
-logFile "$RESULT_ROOT/editmode.log"
44+
45+
"$UNITY_EDITOR" -batchmode -projectPath "$PROJECT_PATH" \
46+
-runTests -testPlatform PlayMode \
47+
-testResults "$RESULT_ROOT/playmode-results.xml" \
48+
-logFile "$RESULT_ROOT/playmode.log"
49+
```
50+
51+
Both commands must exit zero. Inspect the XML and logs rather than reporting
52+
only the process exit status. Record the commit SHA, operating system, Editor
53+
revision, architecture, totals, failures and skipped tests in the pull request.
54+
55+
Documentation-only changes may state that Unity was not required. Runtime,
56+
scene, prefab, package, ProjectSettings, UXML, USS and Editor-tool changes must
57+
provide Unity evidence.
58+
59+
## Activation boundary
60+
61+
Never commit a Unity license file, account password or serial. Store credentials
62+
only as encrypted repository or environment secrets. Placeholder secrets are
63+
not valid credentials and the activation variable must remain `false` while
64+
they are present.

docs/release/RELEASE_PROCESS.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ release notes.
3232

3333
Use Unity `6000.5.6f1` and the exact candidate commit:
3434

35+
The canonical local commands and the relationship between automated and manual
36+
evidence are documented in
37+
[`unity-test-gate.md`](../development/unity-test-gate.md). Automated Unity jobs
38+
remain disabled until the repository variable `UNITY_CI_ENABLED` is explicitly
39+
set to `true` after valid license secrets have been installed. Pull requests
40+
from forks must provide maintainer-generated manual evidence because repository
41+
secrets are intentionally unavailable to untrusted fork workflows.
42+
3543
1. synchronize the core assembly;
3644
2. build the current CoreMIDI plug-in on macOS;
3745
3. run all Unity EditMode tests;
@@ -97,9 +105,11 @@ The release record must include:
97105

98106
In the public repository, dispatch `.github/workflows/source-release.yml` for
99107
the approved exact version to create an attested, rights-clean source snapshot.
100-
Verify the downloaded artifact with:
108+
The artifact contains the snapshot, `SHA256SUMS`, and
109+
`RELEASE-EVIDENCE.txt`. Verify the downloaded artifact with:
101110

102111
```sh
112+
shasum -a 256 -c SHA256SUMS
103113
gh attestation verify HitTheKit-source-0.5.0.tar.gz -R Codewriter90x/HitTheKit
104114
```
105115

tests/scripts/public-readiness-contract-tests.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ for path in \
4141
docs/legal/ASSET_PROVENANCE.md \
4242
docs/legal/ASSET_PROVENANCE.sha256 \
4343
docs/development/windows-playtest-package.md \
44+
docs/development/unity-test-gate.md \
4445
docs/release/PUBLIC_RELEASE_CHECKLIST.md \
4546
docs/release/RELEASE_PROCESS.md \
4647
scripts/package-game-windows-x64.sh \
@@ -51,6 +52,15 @@ for path in \
5152
[ -s "$path" ] || fail "required public file is missing or empty: $path"
5253
done
5354

55+
grep -Fq "vars.UNITY_CI_ENABLED == 'true'" .github/workflows/ci.yml || \
56+
fail "Unity CI must stay behind the explicit activation variable"
57+
grep -Fq 'test-mode: [editmode, playmode]' .github/workflows/ci.yml || \
58+
fail "Unity CI must define both EditMode and PlayMode"
59+
grep -Fq 'languages: c-cpp' .github/workflows/codeql.yml || \
60+
fail "CodeQL must analyze the native C++ boundary"
61+
grep -Fq 'Verify source snapshot checksum' .github/workflows/source-release.yml || \
62+
fail "source release workflow must verify its checksum manifest"
63+
5464
case "$PUBLICATION_STATE" in
5565
private-preparation)
5666
for path in \

0 commit comments

Comments
 (0)