Skip to content

Commit 37ede50

Browse files
committed
👷 ci: add commit gate and editmode suite
1 parent f15c22b commit 37ede50

2 files changed

Lines changed: 150 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
name: Commit Sentinel
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
checks: write
14+
statuses: write
15+
16+
jobs:
17+
signature-and-style:
18+
name: Trust & Style Audit
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout full history
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Ensure commits are signed
27+
uses: zgosalvez/github-actions-ensure-commit-signed@v1
28+
with:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Lint commit titles
32+
shell: pwsh
33+
run: |
34+
$eventName = '${{ github.event_name }}'
35+
if ($eventName -eq 'pull_request') {
36+
$base = '${{ github.event.pull_request.base.sha }}'
37+
$head = '${{ github.event.pull_request.head.sha }}'
38+
$range = "$base..$head"
39+
} else {
40+
$before = '${{ github.event.before }}'
41+
$after = '${{ github.sha }}'
42+
if ($before -and $before -ne '0000000000000000000000000000000000000000') {
43+
$range = "$before..$after"
44+
} else {
45+
$range = $after
46+
}
47+
}
48+
49+
$pattern = '^:[a-z_]+: [a-z0-9-]+: .+'
50+
$invalid = @()
51+
git log --format='%h%x09%s' $range | ForEach-Object {
52+
$parts = $_ -split "\t", 2
53+
if ($parts.Length -lt 2) { return }
54+
$subject = $parts[1]
55+
if ($subject -notmatch $pattern) {
56+
$invalid += $subject
57+
}
58+
}
59+
60+
if ($invalid.Count -gt 0) {
61+
Write-Error "Commit message(s) violate ':gitmoji: scope: message' convention:`n- " + ($invalid -join "`n- ")
62+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
name: Unity EditMode Suite
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
checks: write
14+
statuses: write
15+
16+
concurrency:
17+
group: unity-editmode-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
env:
21+
UNITY_VERSION: 6000.0.0f1
22+
PROJECT_PATH: .
23+
TEST_PLATFORM: EditMode
24+
25+
jobs:
26+
editmode:
27+
name: EditMode Regression
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 30
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
with:
34+
lfs: true
35+
fetch-depth: 0
36+
37+
- name: Install Unity
38+
uses: game-ci/unity-setup@v4
39+
with:
40+
unityVersion: ${{ env.UNITY_VERSION }}
41+
githubToken: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Cache Library
44+
uses: actions/cache@v4
45+
with:
46+
path: Library
47+
key: ${{ runner.os }}-unity-${{ env.UNITY_VERSION }}-${{ hashFiles('Packages/packages-lock.json') }}
48+
restore-keys: |
49+
${{ runner.os }}-unity-${{ env.UNITY_VERSION }}-
50+
51+
- name: Run EditMode Tests
52+
uses: game-ci/unity-test-runner@v4
53+
with:
54+
githubToken: ${{ secrets.GITHUB_TOKEN }}
55+
projectPath: ${{ env.PROJECT_PATH }}
56+
unityVersion: ${{ env.UNITY_VERSION }}
57+
testMode: ${{ env.TEST_PLATFORM }}
58+
artifactsPath: Artifacts
59+
coverageOptions: generateAdditionalMetrics;generateHtmlReport;generateBadgeReport
60+
61+
- name: Publish Artifacts
62+
if: always()
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: editmode-suite
66+
path: Artifacts
67+
68+
- name: Surface Coverage Summary
69+
if: always()
70+
shell: pwsh
71+
run: |
72+
$summaryPath = Join-Path Artifacts "coverage/Report/Summary.xml"
73+
if (Test-Path $summaryPath) {
74+
[xml]$summary = Get-Content $summaryPath
75+
$attributes = $summary.Summary.Attributes
76+
$coverageAttr = $attributes.GetNamedItem('lineCoverage')
77+
if (-not $coverageAttr) {
78+
$coverageAttr = $attributes.GetNamedItem('linecoverage')
79+
}
80+
if ($coverageAttr) {
81+
$coverage = [math]::Round([double]$coverageAttr.Value, 2)
82+
Write-Host "::notice::Line coverage: $coverage%"
83+
} else {
84+
Write-Warning 'Coverage summary present but lineCoverage attribute missing.'
85+
}
86+
} else {
87+
Write-Warning 'Coverage summary not generated.'
88+
}

0 commit comments

Comments
 (0)