mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-06-10 07:53:52 -07:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c112e851c2 | |||
| fe2c4946b7 | |||
| ccbe1bcfbf |
@@ -12,6 +12,7 @@ jobs:
|
|||||||
buildForAllPlatformsMacOS:
|
buildForAllPlatformsMacOS:
|
||||||
name: ${{ matrix.targetPlatform }} on ${{ matrix.unityVersion }}
|
name: ${{ matrix.targetPlatform }} on ${{ matrix.unityVersion }}
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
continue-on-error: true
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
|||||||
@@ -0,0 +1,203 @@
|
|||||||
|
name: Validate Community Plugins
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# Run weekly on Sunday at 02:00 UTC
|
||||||
|
- cron: '0 2 * * 0'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
plugin_filter:
|
||||||
|
description: 'Filter plugins by name (regex pattern, empty = all)'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
unity_version:
|
||||||
|
description: 'Override Unity version (empty = use plugin default)'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
issues: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
load-plugins:
|
||||||
|
name: Load Plugin Registry
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
matrix: ${{ steps.parse.outputs.matrix }}
|
||||||
|
plugin_count: ${{ steps.parse.outputs.count }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Parse plugin registry
|
||||||
|
id: parse
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const fs = require('fs');
|
||||||
|
const yaml = require('js-yaml');
|
||||||
|
|
||||||
|
const registry = yaml.load(fs.readFileSync('community-plugins.yml', 'utf8'));
|
||||||
|
let plugins = registry.plugins || [];
|
||||||
|
|
||||||
|
// Apply name filter if provided
|
||||||
|
const filter = '${{ github.event.inputs.plugin_filter }}';
|
||||||
|
if (filter) {
|
||||||
|
const regex = new RegExp(filter, 'i');
|
||||||
|
plugins = plugins.filter(p => regex.test(p.name));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expand platform matrix
|
||||||
|
const matrix = [];
|
||||||
|
for (const plugin of plugins) {
|
||||||
|
const platforms = plugin.platforms || ['StandaloneLinux64'];
|
||||||
|
for (const platform of platforms) {
|
||||||
|
matrix.push({
|
||||||
|
name: plugin.name,
|
||||||
|
package: plugin.package,
|
||||||
|
source: plugin.source || 'git',
|
||||||
|
unity: '${{ github.event.inputs.unity_version }}' || plugin.unity || '2021.3',
|
||||||
|
platform: platform,
|
||||||
|
timeout: plugin.timeout || 30
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
core.setOutput('matrix', JSON.stringify({ include: matrix }));
|
||||||
|
core.setOutput('count', matrix.length);
|
||||||
|
console.log(`Found ${matrix.length} plugin-platform combinations to validate`);
|
||||||
|
|
||||||
|
validate:
|
||||||
|
name: '${{ matrix.name }} (${{ matrix.platform }})'
|
||||||
|
needs: load-plugins
|
||||||
|
if: needs.load-plugins.outputs.plugin_count > 0
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: ${{ fromJson(matrix.timeout) }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix: ${{ fromJson(needs.load-plugins.outputs.matrix) }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Create test project
|
||||||
|
run: |
|
||||||
|
mkdir -p test-project/Assets
|
||||||
|
mkdir -p test-project/Packages
|
||||||
|
mkdir -p test-project/ProjectSettings
|
||||||
|
|
||||||
|
# Create minimal manifest.json
|
||||||
|
if [ "${{ matrix.source }}" = "git" ]; then
|
||||||
|
cat > test-project/Packages/manifest.json << 'MANIFEST'
|
||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"com.unity.modules.imgui": "1.0.0",
|
||||||
|
"com.unity.modules.jsonserialize": "1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# Add git package via manifest
|
||||||
|
cd test-project
|
||||||
|
cat Packages/manifest.json | python3 -c "
|
||||||
|
import sys, json
|
||||||
|
manifest = json.load(sys.stdin)
|
||||||
|
manifest['dependencies']['${{ matrix.name }}'] = '${{ matrix.package }}'
|
||||||
|
json.dump(manifest, sys.stdout, indent=2)
|
||||||
|
" > Packages/manifest.tmp && mv Packages/manifest.tmp Packages/manifest.json
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create minimal ProjectSettings
|
||||||
|
cat > test-project/ProjectSettings/ProjectVersion.txt << EOF
|
||||||
|
m_EditorVersion: ${{ matrix.unity }}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Build with unity-builder
|
||||||
|
uses: ./
|
||||||
|
id: build
|
||||||
|
with:
|
||||||
|
projectPath: test-project
|
||||||
|
targetPlatform: ${{ matrix.platform }}
|
||||||
|
unityVersion: ${{ matrix.unity }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Record result
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
STATUS="${{ steps.build.outcome }}"
|
||||||
|
echo "## ${{ matrix.name }} — ${{ matrix.platform }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
if [ "$STATUS" = "success" ]; then
|
||||||
|
echo "✅ **PASSED** — Compiled and built successfully" >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
echo "❌ **FAILED** — Build or compilation failed" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "- Unity: ${{ matrix.unity }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "- Platform: ${{ matrix.platform }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "- Source: ${{ matrix.source }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "- Package: \`${{ matrix.package }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
report:
|
||||||
|
name: Validation Report
|
||||||
|
needs: [load-plugins, validate]
|
||||||
|
if: always()
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Generate summary
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const { data: run } = await github.rest.actions.listJobsForWorkflowRun({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
run_id: context.runId
|
||||||
|
});
|
||||||
|
|
||||||
|
const validateJobs = run.jobs.filter(j => j.name.startsWith('validate'));
|
||||||
|
const passed = validateJobs.filter(j => j.conclusion === 'success').length;
|
||||||
|
const failed = validateJobs.filter(j => j.conclusion === 'failure').length;
|
||||||
|
const total = validateJobs.length;
|
||||||
|
|
||||||
|
let summary = `# Community Plugin Validation Report\n\n`;
|
||||||
|
summary += `**${passed}/${total} passed** | ${failed} failed\n\n`;
|
||||||
|
summary += `| Plugin | Platform | Status |\n|--------|----------|--------|\n`;
|
||||||
|
|
||||||
|
for (const job of validateJobs) {
|
||||||
|
const icon = job.conclusion === 'success' ? '✅' : '❌';
|
||||||
|
summary += `| ${job.name} | | ${icon} ${job.conclusion} |\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
await core.summary.addRaw(summary).write();
|
||||||
|
|
||||||
|
// Create or update issue if there are failures
|
||||||
|
if (failed > 0) {
|
||||||
|
const title = `Community Plugin Validation: ${failed} failure(s) — ${new Date().toISOString().split('T')[0]}`;
|
||||||
|
const body = summary + `\n\n[Workflow Run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})`;
|
||||||
|
|
||||||
|
const { data: issues } = await github.rest.issues.listForRepo({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
state: 'open',
|
||||||
|
labels: 'community-plugin-validation'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (issues.length > 0) {
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: issues[0].number,
|
||||||
|
body: body
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await github.rest.issues.create({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
title: title,
|
||||||
|
body: body,
|
||||||
|
labels: ['community-plugin-validation']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
# Unity-Builder
|
|
||||||
|
|
||||||
GitHub Action and CLI that builds Unity projects for multiple platforms. Part of the [GameCI](https://game.ci) project.
|
|
||||||
|
|
||||||
## Quick Reference
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn # install dependencies
|
|
||||||
yarn build # full build: tsc → ncc bundle (src/ → lib/ → dist/index.js)
|
|
||||||
yarn test # run all tests (jest)
|
|
||||||
yarn test:ci # run tests in CI mode (single-threaded, 2min timeout)
|
|
||||||
yarn lint # prettier + eslint check
|
|
||||||
yarn format # auto-format with prettier
|
|
||||||
```
|
|
||||||
|
|
||||||
## Architecture
|
|
||||||
|
|
||||||
**Entry point:** `src/index.ts` → decides between CLI mode and GitHub Action mode.
|
|
||||||
|
|
||||||
**Two execution paths:**
|
|
||||||
1. **Local builds** — Docker container or native macOS (`src/model/docker.ts`, `src/model/mac-builder.ts`)
|
|
||||||
2. **Orchestrator builds** — Remote execution on AWS ECS, Kubernetes, or other providers (`src/model/orchestrator/`)
|
|
||||||
|
|
||||||
**Key modules:**
|
|
||||||
|
|
||||||
| Path | Purpose |
|
|
||||||
|---|---|
|
|
||||||
| `src/model/build-parameters.ts` | Central config object — all build settings flow through here |
|
|
||||||
| `src/model/input.ts` | Input resolution with priority: Action inputs → CLI flags → env override → env vars |
|
|
||||||
| `src/model/orchestrator/orchestrator.ts` | Remote build orchestration — provider selection, workflow execution |
|
|
||||||
| `src/model/orchestrator/providers/` | Provider plugin system (AWS, K8s, Docker, Local, Test) |
|
|
||||||
| `src/model/orchestrator/remote-client/` | Code that runs inside remote containers (caching, hooks, artifacts) |
|
|
||||||
| `src/model/orchestrator/workflows/` | Build workflow types (standard, custom, async) |
|
|
||||||
| `src/model/orchestrator/services/` | Logging, locking, resource tracking |
|
|
||||||
| `src/model/cli/` | CLI mode using commander — dispatches to `@CliFunction`-decorated methods |
|
|
||||||
| `action.yml` | GitHub Action manifest — all inputs/outputs defined here |
|
|
||||||
| `dist/index.js` | Bundled output (committed to repo, used by action.yml at runtime) |
|
|
||||||
|
|
||||||
**Provider interface:** All providers implement `ProviderInterface` (`providers/provider-interface.ts`) with methods: `setupWorkflow`, `runTaskInWorkflow`, `cleanupWorkflow`, `garbageCollect`, `listResources`, `listWorkflow`, `watchWorkflow`.
|
|
||||||
|
|
||||||
**Provider loading:** Providers can be built-in, loaded from npm, cloned from GitHub repos, or loaded from local paths (`provider-loader.ts`).
|
|
||||||
|
|
||||||
## Build System
|
|
||||||
|
|
||||||
The build pipeline is: `yarn` → `tsc` (src/ → lib/) → `ncc build lib` (lib/ → dist/index.js).
|
|
||||||
|
|
||||||
- **dist/ is committed** — GitHub Actions loads `dist/index.js` directly, no install step on runners
|
|
||||||
- **Pre-commit hooks** (lefthook) auto-run formatting, linting, related tests, and `yarn build` to keep dist/ in sync
|
|
||||||
- Runtime: Node 20 (configured via Volta and action.yml `runs.using: node20`)
|
|
||||||
|
|
||||||
## Code Conventions
|
|
||||||
|
|
||||||
- **Files:** kebab-case (enforced by eslint `unicorn/filename-case`)
|
|
||||||
- **Code:** camelCase variables/functions, PascalCase classes/types
|
|
||||||
- **Formatting:** Prettier — 120 char width, single quotes, trailing commas, semicolons
|
|
||||||
- **Linting:** ESLint with unicorn, github, prettier, jest plugins
|
|
||||||
- **TypeScript:** strict mode, ES2020 target, CommonJS modules, experimental decorators enabled
|
|
||||||
- **Blank line before return statements** (enforced)
|
|
||||||
- **Blank line before block/line comments** (enforced)
|
|
||||||
- **No `for...in` loops** — use `for...of`
|
|
||||||
|
|
||||||
## Testing
|
|
||||||
|
|
||||||
- **Framework:** Jest 27 with ts-jest
|
|
||||||
- **Pattern:** `**/*.test.ts` files colocated with source
|
|
||||||
- **Orchestrator tests:** Concentrated in `src/model/orchestrator/tests/`
|
|
||||||
- **Run specific tests:** `yarn test -t "pattern"` or `yarn jest path/to/file.test.ts`
|
|
||||||
- **Orchestrator integration tests** require `orchestratorTests=true` env var: `cross-env orchestratorTests=true yarn test -i -t "orchestrator"`
|
|
||||||
|
|
||||||
## Security
|
|
||||||
|
|
||||||
- **Never log, output, or hardcode credentials** — cloud provider secrets (AWS, GCP, K8s), Unity serial keys, keystores, and private tokens must stay in secret inputs
|
|
||||||
- **Input validation matters** — user-supplied hook commands and custom parameters can be injection vectors; use `shell-quote` for shell escaping
|
|
||||||
- **Keystore/license data** is base64-encoded in inputs and written to temp files at build time
|
|
||||||
|
|
||||||
## CI Workflows
|
|
||||||
|
|
||||||
- `integrity-check.yml` — lint, test, build on every push/PR
|
|
||||||
- `build-tests-{ubuntu,windows,mac}.yml` — matrix builds across Unity versions and platforms
|
|
||||||
- `orchestrator-integrity.yml` / `orchestrator-async-checks.yml` — orchestrator-specific validation
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# Community Plugin Validation Registry
|
||||||
|
# Packages listed here are automatically tested on a schedule
|
||||||
|
# to ensure compatibility with unity-builder.
|
||||||
|
#
|
||||||
|
# Format:
|
||||||
|
# - name: Human-readable name
|
||||||
|
# package: UPM package name or git URL
|
||||||
|
# source: upm | git | asset-store
|
||||||
|
# unity: Minimum Unity version (optional, defaults to 2021.3)
|
||||||
|
# platforms: List of platforms to test (optional, defaults to [StandaloneLinux64])
|
||||||
|
# timeout: Build timeout in minutes (optional, defaults to 30)
|
||||||
|
|
||||||
|
plugins:
|
||||||
|
# Example entries — community members can submit PRs to add their packages
|
||||||
|
- name: UniTask
|
||||||
|
package: https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask
|
||||||
|
source: git
|
||||||
|
platforms: [StandaloneLinux64, StandaloneWindows64]
|
||||||
|
|
||||||
|
- name: NaughtyAttributes
|
||||||
|
package: https://github.com/dbrizov/NaughtyAttributes.git?path=Assets/NaughtyAttributes
|
||||||
|
source: git
|
||||||
|
|
||||||
|
- name: Unity Atoms
|
||||||
|
package: https://github.com/unity-atoms/unity-atoms.git
|
||||||
|
source: git
|
||||||
|
platforms: [StandaloneLinux64]
|
||||||
Reference in New Issue
Block a user