mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-06-02 06:46:15 -07:00
Compare commits
104 Commits
feature/us
...
temp/push-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e5b91558a | ||
|
|
b351f4d738 | ||
|
|
b78785eba1 | ||
|
|
afcb405e96 | ||
|
|
8e79c867bd | ||
|
|
c91f9d16ee | ||
|
|
25f0a9c9f2 | ||
|
|
e604053195 | ||
|
|
7cbdefc00a | ||
|
|
d6fcc2bb1e | ||
|
|
c4896aae2b | ||
|
|
e34f4e46b6 | ||
|
|
ee53114d77 | ||
|
|
72fdbd86df | ||
|
|
ad1a1e8cb2 | ||
|
|
0557688d0a | ||
|
|
02f9cee483 | ||
|
|
c69c09579b | ||
|
|
7b2bd2638e | ||
|
|
52bed195b5 | ||
|
|
01c718a405 | ||
|
|
d34f77c043 | ||
|
|
20b01e1325 | ||
|
|
25dbf37f6b | ||
|
|
39f885dcaf | ||
|
|
0cb3cb35a1 | ||
|
|
e2a778dc80 | ||
|
|
222665a9ec | ||
|
|
b19ced70e4 | ||
|
|
cefebcabc9 | ||
|
|
488c259481 | ||
|
|
7b8f109334 | ||
|
|
db42c76d41 | ||
|
|
d82481b922 | ||
|
|
f2e7568d47 | ||
|
|
4979a39d13 | ||
|
|
2eb5bd3423 | ||
|
|
90d7b26980 | ||
|
|
1f5f6b76c3 | ||
|
|
c5043df431 | ||
|
|
a864249881 | ||
|
|
415d9e234c | ||
|
|
c7422c0943 | ||
|
|
750c10b31b | ||
|
|
e34af96271 | ||
|
|
ae296a7792 | ||
|
|
d53cd983d6 | ||
|
|
011e341794 | ||
|
|
a16f663cf2 | ||
|
|
4724eea88f | ||
|
|
bcf32b407d | ||
|
|
b4ffa3e070 | ||
|
|
280a10d107 | ||
|
|
79d12aa588 | ||
|
|
5bdcf12059 | ||
|
|
5a42214cda | ||
|
|
81ba9c38af | ||
|
|
79ae55802d | ||
|
|
1e2bb889bf | ||
|
|
e9c247f04f | ||
|
|
3976b7cedd | ||
|
|
9789eb5c3b | ||
|
|
b3bd405399 | ||
|
|
4d7e8717e9 | ||
|
|
120c3c5b24 | ||
|
|
7c0c4c2072 | ||
|
|
40dd436000 | ||
|
|
cff759721a | ||
|
|
7615bbd9dd | ||
|
|
f06f99b3e5 | ||
|
|
1f3affe097 | ||
|
|
fe63d7b32d | ||
|
|
5e54bcd4dd | ||
|
|
007852a800 | ||
|
|
4870fb5a5c | ||
|
|
118671778f | ||
|
|
aa2e05d468 | ||
|
|
1bb31f3e98 | ||
|
|
ff56194b30 | ||
|
|
47670cf3ce | ||
|
|
4f07508484 | ||
|
|
7db70a712f | ||
|
|
12f287168d | ||
|
|
ccbe1bcfbf | ||
|
|
3033ee0067 | ||
|
|
b3e1639029 | ||
|
|
49b37f7831 | ||
|
|
8d81236939 | ||
|
|
26903e96dd | ||
|
|
cf3478c8ec | ||
|
|
7f895304f4 | ||
|
|
e4c156e7b0 | ||
|
|
8a41533779 | ||
|
|
a0c79bd657 | ||
|
|
f4451060a7 | ||
|
|
17a0ea3776 | ||
|
|
7e9d0bf53e | ||
|
|
cfac5f138d | ||
|
|
d17b099593 | ||
|
|
8194790728 | ||
|
|
786ee3799c | ||
|
|
f4bc5d20c4 | ||
|
|
d8563369e1 | ||
|
|
5268630ef0 |
6
.github/workflows/build-tests-mac.yml
vendored
6
.github/workflows/build-tests-mac.yml
vendored
@@ -18,9 +18,9 @@ jobs:
|
||||
projectPath:
|
||||
- test-project
|
||||
unityVersion:
|
||||
- 2021.3.45f2
|
||||
- 2022.3.62f3
|
||||
- 2023.2.22f1
|
||||
- 2021.3.45f1
|
||||
- 2022.3.13f1
|
||||
- 2023.2.2f1
|
||||
targetPlatform:
|
||||
- StandaloneOSX # Build a MacOS executable
|
||||
- iOS # Build an iOS executable
|
||||
|
||||
6
.github/workflows/build-tests-ubuntu.yml
vendored
6
.github/workflows/build-tests-ubuntu.yml
vendored
@@ -48,9 +48,9 @@ jobs:
|
||||
projectPath:
|
||||
- test-project
|
||||
unityVersion:
|
||||
- 2021.3.45f2
|
||||
- 2022.3.62f3
|
||||
- 2023.2.22f1
|
||||
- 2021.3.32f1
|
||||
- 2022.3.13f1
|
||||
- 2023.2.2f1
|
||||
targetPlatform:
|
||||
- StandaloneOSX # Build a macOS standalone (Intel 64-bit) with mono backend.
|
||||
- StandaloneWindows64 # Build a Windows 64-bit standalone with mono backend.
|
||||
|
||||
40
.github/workflows/build-tests-windows.yml
vendored
40
.github/workflows/build-tests-windows.yml
vendored
@@ -18,9 +18,9 @@ jobs:
|
||||
projectPath:
|
||||
- test-project
|
||||
unityVersion:
|
||||
- 2021.3.45f2
|
||||
- 2022.3.62f3
|
||||
- 2023.2.22f1
|
||||
- 2021.3.32f1
|
||||
- 2022.3.13f1
|
||||
- 2023.2.2f1
|
||||
targetPlatform:
|
||||
- Android # Build an Android apk.
|
||||
- StandaloneWindows64 # Build a Windows 64-bit standalone.
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
- unityVersion: 6000.0.36f1
|
||||
targetPlatform: StandaloneWindows64
|
||||
buildProfile: 'Assets/Settings/Build Profiles/Sample Windows Build Profile.asset'
|
||||
|
||||
|
||||
steps:
|
||||
###########################
|
||||
# Checkout #
|
||||
@@ -66,34 +66,6 @@ jobs:
|
||||
run: |
|
||||
Move-Item -Path "./test-project/ProjectSettings/ProjectSettingsIl2cpp.asset" -Destination "./test-project/ProjectSettings/ProjectSettings.asset" -Force
|
||||
|
||||
###########################
|
||||
# Docker Readiness #
|
||||
###########################
|
||||
- name: Ensure Docker daemon is ready
|
||||
timeout-minutes: 2
|
||||
shell: powershell
|
||||
run: |
|
||||
$maxRetries = 10
|
||||
$retryDelay = 6
|
||||
for ($i = 0; $i -lt $maxRetries; $i++) {
|
||||
$svc = Get-Service docker -ErrorAction SilentlyContinue
|
||||
if ($svc -and $svc.Status -eq 'Running') {
|
||||
docker version 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "Docker is ready."
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
if ($svc -and $svc.Status -eq 'Stopped') {
|
||||
Write-Host "Docker service stopped, attempting to start..."
|
||||
Start-Service docker -ErrorAction SilentlyContinue
|
||||
}
|
||||
Write-Host "Waiting for Docker daemon (attempt $($i+1)/$maxRetries)..."
|
||||
Start-Sleep -Seconds $retryDelay
|
||||
}
|
||||
Write-Error "Docker daemon did not start within $($maxRetries * $retryDelay) seconds"
|
||||
exit 1
|
||||
|
||||
###########################
|
||||
# Build #
|
||||
###########################
|
||||
@@ -174,8 +146,6 @@ jobs:
|
||||
###########################
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name:
|
||||
Build ${{ matrix.targetPlatform }} on Windows (${{ matrix.unityVersion }})${{ matrix.enableGpu && ' With
|
||||
GPU' || '' }}${{ matrix.buildProfile && ' With Build Profile' || '' }}
|
||||
name: Build ${{ matrix.targetPlatform }} on Windows (${{ matrix.unityVersion }})${{ matrix.enableGpu && ' With GPU' || '' }}${{ matrix.buildProfile && ' With Build Profile' || '' }}
|
||||
path: build
|
||||
retention-days: 14
|
||||
|
||||
6
.github/workflows/integrity-check.yml
vendored
6
.github/workflows/integrity-check.yml
vendored
@@ -2,8 +2,7 @@ name: Integrity
|
||||
|
||||
on:
|
||||
push: { branches: [main] }
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, labeled]
|
||||
pull_request: {}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -35,7 +34,6 @@ jobs:
|
||||
|
||||
orchestrator-integration:
|
||||
name: Orchestrator Integration
|
||||
if: >-
|
||||
github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'run-integration')
|
||||
if: github.event_name == 'push'
|
||||
uses: ./.github/workflows/validate-orchestrator-integration.yml
|
||||
secrets: inherit
|
||||
|
||||
91
.github/workflows/sync-secrets.yml
vendored
91
.github/workflows/sync-secrets.yml
vendored
@@ -1,91 +0,0 @@
|
||||
name: Sync Secrets to Repositories
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
target_repo:
|
||||
description: 'Target repository (org/repo format)'
|
||||
required: true
|
||||
default: 'game-ci/orchestrator'
|
||||
type: choice
|
||||
options:
|
||||
- game-ci/orchestrator
|
||||
- game-ci/cli
|
||||
dry_run:
|
||||
description: 'Dry run (list secrets to sync without writing)'
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
sync-secrets:
|
||||
name: Sync secrets to ${{ inputs.target_repo }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Sync secrets
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
TARGET_REPO: ${{ inputs.target_repo }}
|
||||
DRY_RUN: ${{ inputs.dry_run }}
|
||||
# Secrets to sync — values come from repo + org secrets available here
|
||||
SECRET_UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
SECRET_UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
SECRET_UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
|
||||
SECRET_GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
SECRET_GOOGLE_SERVICE_ACCOUNT_EMAIL: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_EMAIL }}
|
||||
SECRET_GOOGLE_SERVICE_ACCOUNT_KEY: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }}
|
||||
SECRET_CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
SECRET_UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
SECRET_NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
SECRETS=(
|
||||
"UNITY_EMAIL:SECRET_UNITY_EMAIL"
|
||||
"UNITY_PASSWORD:SECRET_UNITY_PASSWORD"
|
||||
"UNITY_SERIAL:SECRET_UNITY_SERIAL"
|
||||
"UNITY_LICENSE:SECRET_UNITY_LICENSE"
|
||||
"GIT_PRIVATE_TOKEN:SECRET_GIT_PRIVATE_TOKEN"
|
||||
"GOOGLE_SERVICE_ACCOUNT_EMAIL:SECRET_GOOGLE_SERVICE_ACCOUNT_EMAIL"
|
||||
"GOOGLE_SERVICE_ACCOUNT_KEY:SECRET_GOOGLE_SERVICE_ACCOUNT_KEY"
|
||||
"CODECOV_TOKEN:SECRET_CODECOV_TOKEN"
|
||||
"NPM_TOKEN:SECRET_NPM_TOKEN"
|
||||
)
|
||||
|
||||
synced=0
|
||||
skipped=0
|
||||
|
||||
for entry in "${SECRETS[@]}"; do
|
||||
name="${entry%%:*}"
|
||||
env_var="${entry##*:}"
|
||||
value="${!env_var}"
|
||||
|
||||
if [ -z "$value" ]; then
|
||||
echo "⏭ SKIP: $name (not available in this repo's context)"
|
||||
skipped=$((skipped + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$DRY_RUN" = "true" ]; then
|
||||
echo "🔍 DRY RUN: would sync $name → $TARGET_REPO"
|
||||
else
|
||||
if echo "$value" | gh secret set "$name" -R "$TARGET_REPO" --body - 2>/dev/null; then
|
||||
echo "✅ SYNCED: $name → $TARGET_REPO"
|
||||
else
|
||||
echo "⚠️ FAILED: $name → $TARGET_REPO (continuing)"
|
||||
skipped=$((skipped + 1))
|
||||
synced=$((synced - 1))
|
||||
fi
|
||||
fi
|
||||
synced=$((synced + 1))
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "=== Summary ==="
|
||||
echo "Synced: $synced"
|
||||
echo "Skipped (not available): $skipped"
|
||||
echo "Target: $TARGET_REPO"
|
||||
if [ "$DRY_RUN" = "true" ]; then
|
||||
echo "Mode: DRY RUN (no secrets were written)"
|
||||
fi
|
||||
41
.github/workflows/temp-push-secrets.yml
vendored
Normal file
41
.github/workflows/temp-push-secrets.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
name: "TEMP: Push secrets to orchestrator repo"
|
||||
|
||||
# One-shot workflow — run manually, then delete this file and branch.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
push-secrets:
|
||||
name: Push secrets to game-ci/orchestrator
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Push UNITY_EMAIL
|
||||
run: gh secret set UNITY_EMAIL --repo game-ci/orchestrator --body "$SECRET_VALUE"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
SECRET_VALUE: ${{ secrets.UNITY_EMAIL }}
|
||||
|
||||
- name: Push UNITY_PASSWORD
|
||||
run: gh secret set UNITY_PASSWORD --repo game-ci/orchestrator --body "$SECRET_VALUE"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
SECRET_VALUE: ${{ secrets.UNITY_PASSWORD }}
|
||||
|
||||
- name: Push UNITY_SERIAL
|
||||
run: gh secret set UNITY_SERIAL --repo game-ci/orchestrator --body "$SECRET_VALUE"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
SECRET_VALUE: ${{ secrets.UNITY_SERIAL }}
|
||||
|
||||
- name: Push GIT_PRIVATE_TOKEN
|
||||
run: gh secret set GIT_PRIVATE_TOKEN --repo game-ci/orchestrator --body "$SECRET_VALUE"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
SECRET_VALUE: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
|
||||
- name: Confirm
|
||||
run: |
|
||||
echo "Secrets pushed to game-ci/orchestrator:"
|
||||
gh secret list --repo game-ci/orchestrator
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
@@ -2,7 +2,7 @@ name: Orchestrator Integration Tests
|
||||
|
||||
# ==============================================================================
|
||||
# Exhaustive integration tests — runs on a daily cron and manual dispatch.
|
||||
# Slow (~1-2h wall-clock): k8s, AWS, local-docker, rclone via MiniStack + k3d.
|
||||
# Slow (~1-2h wall-clock): k8s, AWS, local-docker, rclone via LocalStack + k3d.
|
||||
#
|
||||
# Mirrors the full orchestrator-integrity.yml test suite from the orchestrator
|
||||
# repo, run from unity-builder's perspective to catch cross-repo regressions.
|
||||
@@ -21,9 +21,9 @@ permissions:
|
||||
checks: write
|
||||
statuses: write
|
||||
|
||||
# Note: no concurrency block here — when invoked via workflow_call, the caller
|
||||
# (integrity-check.yml) manages concurrency. For direct dispatch/cron, runs are
|
||||
# naturally serialized by GitHub's single-concurrency-per-ref default.
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
AWS_STACK_NAME: game-ci-team-pipelines
|
||||
@@ -47,17 +47,7 @@ jobs:
|
||||
- name: Checkout unity-builder
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Checkout orchestrator (matching branch)
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: game-ci/orchestrator
|
||||
ref: ${{ github.head_ref || github.ref_name }}
|
||||
path: orchestrator-standalone
|
||||
continue-on-error: true
|
||||
id: orchestrator-branch
|
||||
|
||||
- name: Fallback to orchestrator main branch
|
||||
if: steps.orchestrator-branch.outcome == 'failure'
|
||||
- name: Checkout orchestrator
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: game-ci/orchestrator
|
||||
@@ -98,27 +88,32 @@ jobs:
|
||||
echo "Installing orchestrator into unity-builder workspace..."
|
||||
npm install ./orchestrator-standalone/game-ci-orchestrator-*.tgz --no-save --legacy-peer-deps
|
||||
|
||||
- name: Verify plugin loader returns exports with orchestrator installed
|
||||
- name: Verify all services and lazy loaders
|
||||
run: |
|
||||
node -e "
|
||||
const { loadOrchestratorPlugin } = require('./lib/model/orchestrator-plugin');
|
||||
const { loadOrchestrator, loadPluginServices } = require('./lib/model/orchestrator-plugin');
|
||||
(async () => {
|
||||
const plugin = await loadOrchestratorPlugin();
|
||||
if (plugin === undefined) {
|
||||
console.error('ERROR: loadOrchestratorPlugin should return defined plugin when package is installed');
|
||||
const orch = await loadOrchestrator();
|
||||
if (!orch || typeof orch.run !== 'function') {
|
||||
console.error('ERROR: loadOrchestrator failed');
|
||||
process.exit(1);
|
||||
}
|
||||
const lifecycleMethods = [
|
||||
'initialize', 'canHandleBuild', 'handleBuild',
|
||||
'beforeLocalBuild', 'afterLocalBuild', 'handlePostBuild',
|
||||
];
|
||||
for (const method of lifecycleMethods) {
|
||||
if (typeof plugin[method] !== 'function') {
|
||||
console.error('ERROR: plugin.' + method + ' should be a function, got ' + typeof plugin[method]);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('✓ loadOrchestrator().run is a function');
|
||||
|
||||
const services = await loadPluginServices();
|
||||
if (!services) { console.error('ERROR: loadPluginServices failed'); process.exit(1); }
|
||||
|
||||
const eager = ['BuildReliabilityService','TestWorkflowService','HotRunnerService','OutputService','OutputTypeRegistry','ArtifactUploadHandler','IncrementalSyncService'];
|
||||
for (const s of eager) { if (!services[s]) { console.error('Missing: ' + s); process.exit(1); } }
|
||||
console.log('✓ All ' + eager.length + ' eager services loaded');
|
||||
|
||||
const lazy = ['loadChildWorkspaceService','loadLocalCacheService','loadSubmoduleProfileService','loadLfsAgentService','loadGitHooksService'];
|
||||
for (const l of lazy) {
|
||||
if (typeof services[l] !== 'function') { console.error('Missing loader: ' + l); process.exit(1); }
|
||||
const svc = await services[l]();
|
||||
if (!svc) { console.error(l + '() returned undefined'); process.exit(1); }
|
||||
}
|
||||
console.log('✓ loadOrchestratorPlugin() returns plugin with all ' + lifecycleMethods.length + ' lifecycle methods');
|
||||
console.log('✓ All ' + lazy.length + ' lazy loaders return defined services');
|
||||
})();
|
||||
"
|
||||
|
||||
@@ -133,7 +128,7 @@ jobs:
|
||||
"
|
||||
|
||||
# ============================================================================
|
||||
# K8S INTEGRATION TESTS (k3d + MiniStack)
|
||||
# K8S INTEGRATION TESTS (k3d + LocalStack)
|
||||
# ============================================================================
|
||||
k8s-integration:
|
||||
name: K8s Integration Tests
|
||||
@@ -144,17 +139,7 @@ jobs:
|
||||
RESOURCE_TRACKING: 'true'
|
||||
K8S_LOCALSTACK_HOST: localstack-main
|
||||
steps:
|
||||
- name: Checkout orchestrator (matching branch)
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: game-ci/orchestrator
|
||||
ref: ${{ github.head_ref || github.ref_name }}
|
||||
lfs: false
|
||||
continue-on-error: true
|
||||
id: orch-branch
|
||||
|
||||
- name: Fallback to orchestrator main branch
|
||||
if: steps.orch-branch.outcome == 'failure'
|
||||
- name: Checkout orchestrator
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: game-ci/orchestrator
|
||||
@@ -231,16 +216,19 @@ jobs:
|
||||
echo "Disk usage after cleanup:"
|
||||
df -h
|
||||
|
||||
- name: Start MiniStack
|
||||
- name: Start LocalStack
|
||||
run: |
|
||||
echo "Starting MiniStack..."
|
||||
echo "Starting LocalStack..."
|
||||
docker run -d \
|
||||
--name localstack-main \
|
||||
--network orchestrator-net \
|
||||
--add-host=host.docker.internal:host-gateway \
|
||||
-p 4566:4566 \
|
||||
ministackorg/ministack:latest || true
|
||||
echo "Waiting for MiniStack to be ready..."
|
||||
-e SERVICES=s3,cloudformation,ecs,kinesis,cloudwatch,logs,efs,ec2,iam,elasticfilesystem,secretsmanager,lambda,events,sts \
|
||||
-e DEBUG=0 \
|
||||
-e HOSTNAME_EXTERNAL=localstack-main \
|
||||
localstack/localstack:latest || true
|
||||
echo "Waiting for LocalStack to be ready..."
|
||||
MAX_ATTEMPTS=60
|
||||
READY=false
|
||||
for i in $(seq 1 $MAX_ATTEMPTS); do
|
||||
@@ -248,14 +236,14 @@ jobs:
|
||||
HEALTH=$(curl -s http://localhost:4566/_localstack/health 2>/dev/null || echo "")
|
||||
if [ -z "$HEALTH" ] || ! echo "$HEALTH" | grep -q "services"; then sleep 2; continue; fi
|
||||
if echo "$HEALTH" | grep -q '"s3"'; then
|
||||
echo "MiniStack is ready (attempt $i/$MAX_ATTEMPTS)"
|
||||
echo "LocalStack is ready (attempt $i/$MAX_ATTEMPTS)"
|
||||
READY=true
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
if [ "$READY" != "true" ]; then
|
||||
echo "ERROR: MiniStack did not become ready"
|
||||
echo "ERROR: LocalStack did not become ready"
|
||||
docker logs localstack-main --tail 100 || true
|
||||
exit 1
|
||||
fi
|
||||
@@ -308,7 +296,7 @@ jobs:
|
||||
timeout-minutes: 5
|
||||
run: |
|
||||
LOCALSTACK_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' localstack-main 2>/dev/null || echo "")
|
||||
echo "MiniStack container IP: $LOCALSTACK_IP"
|
||||
echo "LocalStack container IP: $LOCALSTACK_IP"
|
||||
k3d cluster create unity-builder \
|
||||
--agents 1 \
|
||||
--network orchestrator-net \
|
||||
@@ -316,7 +304,7 @@ jobs:
|
||||
kubectl config current-context | cat
|
||||
echo "LOCALSTACK_IP=$LOCALSTACK_IP" >> $GITHUB_ENV
|
||||
|
||||
- name: Verify cluster readiness and MiniStack connectivity
|
||||
- name: Verify cluster readiness and LocalStack connectivity
|
||||
timeout-minutes: 2
|
||||
run: |
|
||||
for i in {1..60}; do
|
||||
@@ -328,7 +316,7 @@ jobs:
|
||||
LOCALSTACK_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' localstack-main 2>/dev/null || echo "")
|
||||
kubectl run test-localstack --image=curlimages/curl --rm -i --restart=Never --timeout=30s -- \
|
||||
curl -v --max-time 10 http://${LOCALSTACK_IP}:4566/_localstack/health 2>&1 | head -30 || \
|
||||
echo "Cluster connectivity test - MiniStack may not be accessible from k3d"
|
||||
echo "Cluster connectivity test - LocalStack may not be accessible from k3d"
|
||||
|
||||
- name: Clean up K8s resources before tests
|
||||
run: |
|
||||
@@ -523,17 +511,7 @@ jobs:
|
||||
AWS_ENDPOINT: http://localhost:4566
|
||||
AWS_ENDPOINT_URL: http://localhost:4566
|
||||
steps:
|
||||
- name: Checkout orchestrator (matching branch)
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: game-ci/orchestrator
|
||||
ref: ${{ github.head_ref || github.ref_name }}
|
||||
lfs: false
|
||||
continue-on-error: true
|
||||
id: orch-branch
|
||||
|
||||
- name: Fallback to orchestrator main branch
|
||||
if: steps.orch-branch.outcome == 'failure'
|
||||
- name: Checkout orchestrator
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: game-ci/orchestrator
|
||||
@@ -568,16 +546,18 @@ jobs:
|
||||
docker system prune -af --volumes || true
|
||||
df -h
|
||||
|
||||
- name: Start MiniStack
|
||||
- name: Start LocalStack
|
||||
run: |
|
||||
docker run -d \
|
||||
--name localstack-main \
|
||||
-p 4566:4566 \
|
||||
ministackorg/ministack:latest || true
|
||||
-e SERVICES=s3,cloudformation,ecs,kinesis,cloudwatch,logs,efs,ec2,iam,elasticfilesystem,secretsmanager,lambda,events,sts \
|
||||
-e DEBUG=0 \
|
||||
localstack/localstack:latest || true
|
||||
MAX_ATTEMPTS=60
|
||||
for i in $(seq 1 $MAX_ATTEMPTS); do
|
||||
HEALTH=$(curl -s http://localhost:4566/_localstack/health 2>/dev/null || echo "")
|
||||
if echo "$HEALTH" | grep -q '"s3"'; then echo "MiniStack ready ($i/$MAX_ATTEMPTS)"; break; fi
|
||||
if echo "$HEALTH" | grep -q '"s3"'; then echo "LocalStack ready ($i/$MAX_ATTEMPTS)"; break; fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
@@ -677,66 +657,7 @@ jobs:
|
||||
if: always()
|
||||
run: source /tmp/cleanup-functions.sh && light_cleanup
|
||||
|
||||
# --- AWS Test 5: orchestrator-caching ---
|
||||
- name: Run orchestrator-caching test (AWS)
|
||||
timeout-minutes: 60
|
||||
run: yarn run test "orchestrator-caching" --detectOpenHandles --forceExit --runInBand
|
||||
env:
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
|
||||
TARGET_PLATFORM: StandaloneWindows64
|
||||
orchestratorTests: true
|
||||
versioning: None
|
||||
PROVIDER_STRATEGY: aws
|
||||
GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
- name: Cleanup after orchestrator-caching (AWS)
|
||||
if: always()
|
||||
run: source /tmp/cleanup-functions.sh && heavy_cleanup
|
||||
|
||||
# --- AWS Test 6: orchestrator-locking-core ---
|
||||
- name: Run orchestrator-locking-core test (AWS)
|
||||
timeout-minutes: 60
|
||||
run: yarn run test "orchestrator-locking-core" --detectOpenHandles --forceExit --runInBand
|
||||
env:
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
|
||||
TARGET_PLATFORM: StandaloneWindows64
|
||||
orchestratorTests: true
|
||||
versioning: None
|
||||
PROVIDER_STRATEGY: aws
|
||||
GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
- name: Cleanup after orchestrator-locking-core (AWS)
|
||||
if: always()
|
||||
run: source /tmp/cleanup-functions.sh && light_cleanup
|
||||
|
||||
# --- AWS Test 7: orchestrator-locking-get-locked ---
|
||||
- name: Run orchestrator-locking-get-locked test (AWS)
|
||||
timeout-minutes: 60
|
||||
run: yarn run test "orchestrator-locking-get-locked" --detectOpenHandles --forceExit --runInBand
|
||||
env:
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
|
||||
TARGET_PLATFORM: StandaloneWindows64
|
||||
orchestratorTests: true
|
||||
versioning: None
|
||||
PROVIDER_STRATEGY: aws
|
||||
GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
- name: Cleanup after orchestrator-locking-get-locked (AWS)
|
||||
if: always()
|
||||
run: source /tmp/cleanup-functions.sh && light_cleanup
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# End-to-end tests (continue-on-error) — run LAST to prevent
|
||||
# workspace corruption from affecting mandatory tests above.
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# --- AWS Test 8: orchestrator-end2end-caching ---
|
||||
# --- AWS Test 5: orchestrator-end2end-caching ---
|
||||
- name: Run orchestrator-end2end-caching test (AWS)
|
||||
timeout-minutes: 60
|
||||
continue-on-error: true
|
||||
@@ -755,7 +676,7 @@ jobs:
|
||||
if: always()
|
||||
run: source /tmp/cleanup-functions.sh && heavy_cleanup
|
||||
|
||||
# --- AWS Test 9: orchestrator-end2end-retaining ---
|
||||
# --- AWS Test 6: orchestrator-end2end-retaining ---
|
||||
- name: Run orchestrator-end2end-retaining test (AWS)
|
||||
timeout-minutes: 60
|
||||
continue-on-error: true
|
||||
@@ -774,6 +695,60 @@ jobs:
|
||||
if: always()
|
||||
run: source /tmp/cleanup-functions.sh && heavy_cleanup
|
||||
|
||||
# --- AWS Test 7: orchestrator-caching ---
|
||||
- name: Run orchestrator-caching test (AWS)
|
||||
timeout-minutes: 60
|
||||
run: yarn run test "orchestrator-caching" --detectOpenHandles --forceExit --runInBand
|
||||
env:
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
|
||||
TARGET_PLATFORM: StandaloneWindows64
|
||||
orchestratorTests: true
|
||||
versioning: None
|
||||
PROVIDER_STRATEGY: aws
|
||||
GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
- name: Cleanup after orchestrator-caching (AWS)
|
||||
if: always()
|
||||
run: source /tmp/cleanup-functions.sh && heavy_cleanup
|
||||
|
||||
# --- AWS Test 8: orchestrator-locking-core ---
|
||||
- name: Run orchestrator-locking-core test (AWS)
|
||||
timeout-minutes: 60
|
||||
run: yarn run test "orchestrator-locking-core" --detectOpenHandles --forceExit --runInBand
|
||||
env:
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
|
||||
TARGET_PLATFORM: StandaloneWindows64
|
||||
orchestratorTests: true
|
||||
versioning: None
|
||||
PROVIDER_STRATEGY: aws
|
||||
GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
- name: Cleanup after orchestrator-locking-core (AWS)
|
||||
if: always()
|
||||
run: source /tmp/cleanup-functions.sh && light_cleanup
|
||||
|
||||
# --- AWS Test 9: orchestrator-locking-get-locked ---
|
||||
- name: Run orchestrator-locking-get-locked test (AWS)
|
||||
timeout-minutes: 60
|
||||
run: yarn run test "orchestrator-locking-get-locked" --detectOpenHandles --forceExit --runInBand
|
||||
env:
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
|
||||
TARGET_PLATFORM: StandaloneWindows64
|
||||
orchestratorTests: true
|
||||
versioning: None
|
||||
PROVIDER_STRATEGY: aws
|
||||
GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
|
||||
- name: Cleanup after orchestrator-locking-get-locked (AWS)
|
||||
if: always()
|
||||
run: source /tmp/cleanup-functions.sh && light_cleanup
|
||||
|
||||
# --- AWS Test 10: orchestrator-end2end-locking ---
|
||||
- name: Run orchestrator-end2end-locking test (AWS)
|
||||
timeout-minutes: 60
|
||||
@@ -814,17 +789,7 @@ jobs:
|
||||
AWS_ENDPOINT: http://localhost:4566
|
||||
AWS_ENDPOINT_URL: http://localhost:4566
|
||||
steps:
|
||||
- name: Checkout orchestrator (matching branch)
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: game-ci/orchestrator
|
||||
ref: ${{ github.head_ref || github.ref_name }}
|
||||
lfs: false
|
||||
continue-on-error: true
|
||||
id: orch-branch
|
||||
|
||||
- name: Fallback to orchestrator main branch
|
||||
if: steps.orch-branch.outcome == 'failure'
|
||||
- name: Checkout orchestrator
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: game-ci/orchestrator
|
||||
@@ -859,16 +824,18 @@ jobs:
|
||||
docker system prune -af --volumes || true
|
||||
df -h
|
||||
|
||||
- name: Start MiniStack (for S3-dependent tests)
|
||||
- name: Start LocalStack (for S3-dependent tests)
|
||||
run: |
|
||||
docker run -d \
|
||||
--name localstack-main \
|
||||
-p 4566:4566 \
|
||||
ministackorg/ministack:latest || true
|
||||
-e SERVICES=s3,cloudformation,ecs,kinesis,cloudwatch,logs \
|
||||
-e DEBUG=0 \
|
||||
localstack/localstack:latest || true
|
||||
MAX_ATTEMPTS=60
|
||||
for i in $(seq 1 $MAX_ATTEMPTS); do
|
||||
HEALTH=$(curl -s http://localhost:4566/_localstack/health 2>/dev/null || echo "")
|
||||
if echo "$HEALTH" | grep -q '"s3"'; then echo "MiniStack ready ($i/$MAX_ATTEMPTS)"; break; fi
|
||||
if echo "$HEALTH" | grep -q '"s3"'; then echo "LocalStack ready ($i/$MAX_ATTEMPTS)"; break; fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
@@ -1079,17 +1046,7 @@ jobs:
|
||||
AWS_ENDPOINT: http://localhost:4566
|
||||
AWS_ENDPOINT_URL: http://localhost:4566
|
||||
steps:
|
||||
- name: Checkout orchestrator (matching branch)
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: game-ci/orchestrator
|
||||
ref: ${{ github.head_ref || github.ref_name }}
|
||||
lfs: false
|
||||
continue-on-error: true
|
||||
id: orch-branch
|
||||
|
||||
- name: Fallback to orchestrator main branch
|
||||
if: steps.orch-branch.outcome == 'failure'
|
||||
- name: Checkout orchestrator
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: game-ci/orchestrator
|
||||
@@ -1106,16 +1063,18 @@ jobs:
|
||||
docker system prune -af --volumes || true
|
||||
df -h
|
||||
|
||||
- name: Start MiniStack
|
||||
- name: Start LocalStack
|
||||
run: |
|
||||
docker run -d \
|
||||
--name localstack-main \
|
||||
-p 4566:4566 \
|
||||
ministackorg/ministack:latest || true
|
||||
-e SERVICES=s3 \
|
||||
-e DEBUG=0 \
|
||||
localstack/localstack:latest || true
|
||||
MAX_ATTEMPTS=60
|
||||
for i in $(seq 1 $MAX_ATTEMPTS); do
|
||||
HEALTH=$(curl -s http://localhost:4566/_localstack/health 2>/dev/null || echo "")
|
||||
if echo "$HEALTH" | grep -q '"s3"'; then echo "MiniStack ready ($i/$MAX_ATTEMPTS)"; break; fi
|
||||
if echo "$HEALTH" | grep -q '"s3"'; then echo "LocalStack ready ($i/$MAX_ATTEMPTS)"; break; fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
|
||||
149
.github/workflows/validate-orchestrator.yml
vendored
149
.github/workflows/validate-orchestrator.yml
vendored
@@ -68,16 +68,6 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Checkout orchestrator
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: game-ci/orchestrator
|
||||
ref: ${{ github.head_ref || github.ref_name }}
|
||||
path: orchestrator-standalone
|
||||
continue-on-error: true
|
||||
id: orchestrator-branch
|
||||
|
||||
- name: Fallback to orchestrator main branch
|
||||
if: steps.orchestrator-branch.outcome == 'failure'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: game-ci/orchestrator
|
||||
@@ -109,14 +99,21 @@ jobs:
|
||||
run: |
|
||||
echo "Checking plugin loader handles missing @game-ci/orchestrator..."
|
||||
node -e "
|
||||
const { loadOrchestratorPlugin } = require('./lib/model/orchestrator-plugin');
|
||||
const { loadOrchestrator, loadPluginServices } = require('./lib/model/orchestrator-plugin');
|
||||
(async () => {
|
||||
const plugin = await loadOrchestratorPlugin();
|
||||
if (plugin !== undefined) {
|
||||
console.error('ERROR: loadOrchestratorPlugin should return undefined when package not installed');
|
||||
const orch = await loadOrchestrator();
|
||||
if (orch !== undefined) {
|
||||
console.error('ERROR: loadOrchestrator should return undefined when package not installed');
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('✓ loadOrchestratorPlugin() returns undefined when package not installed');
|
||||
console.log('✓ loadOrchestrator() returns undefined when package not installed');
|
||||
|
||||
const services = await loadPluginServices();
|
||||
if (services !== undefined) {
|
||||
console.error('ERROR: loadPluginServices should return undefined when package not installed');
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('✓ loadPluginServices() returns undefined when package not installed');
|
||||
})();
|
||||
"
|
||||
|
||||
@@ -156,24 +153,53 @@ jobs:
|
||||
run: |
|
||||
echo "Checking plugin loader returns defined exports..."
|
||||
node -e "
|
||||
const { loadOrchestratorPlugin } = require('./lib/model/orchestrator-plugin');
|
||||
const { loadOrchestrator, loadPluginServices } = require('./lib/model/orchestrator-plugin');
|
||||
(async () => {
|
||||
const plugin = await loadOrchestratorPlugin();
|
||||
if (plugin === undefined) {
|
||||
console.error('ERROR: loadOrchestratorPlugin should return defined plugin when package is installed');
|
||||
const orch = await loadOrchestrator();
|
||||
if (orch === undefined) {
|
||||
console.error('ERROR: loadOrchestrator should return defined exports when package is installed');
|
||||
process.exit(1);
|
||||
}
|
||||
const lifecycleMethods = [
|
||||
'initialize', 'canHandleBuild', 'handleBuild',
|
||||
'beforeLocalBuild', 'afterLocalBuild', 'handlePostBuild',
|
||||
if (typeof orch.run !== 'function') {
|
||||
console.error('ERROR: loadOrchestrator().run should be a function');
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('✓ loadOrchestrator() returns defined exports with orchestrator installed');
|
||||
|
||||
const services = await loadPluginServices();
|
||||
if (services === undefined) {
|
||||
console.error('ERROR: loadPluginServices should return defined exports when package is installed');
|
||||
process.exit(1);
|
||||
}
|
||||
const expectedServices = [
|
||||
'BuildReliabilityService', 'TestWorkflowService', 'HotRunnerService',
|
||||
'OutputService', 'OutputTypeRegistry', 'ArtifactUploadHandler',
|
||||
'IncrementalSyncService',
|
||||
];
|
||||
for (const method of lifecycleMethods) {
|
||||
if (typeof plugin[method] !== 'function') {
|
||||
console.error('ERROR: plugin.' + method + ' should be a function, got ' + typeof plugin[method]);
|
||||
for (const svc of expectedServices) {
|
||||
if (services[svc] === undefined) {
|
||||
console.error('ERROR: ' + svc + ' should be defined');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
console.log('✓ loadOrchestratorPlugin() returns plugin with all ' + lifecycleMethods.length + ' lifecycle methods');
|
||||
console.log('✓ loadPluginServices() returns all ' + expectedServices.length + ' services');
|
||||
|
||||
const lazyLoaders = [
|
||||
'loadChildWorkspaceService', 'loadLocalCacheService',
|
||||
'loadSubmoduleProfileService', 'loadLfsAgentService', 'loadGitHooksService',
|
||||
];
|
||||
for (const loader of lazyLoaders) {
|
||||
if (typeof services[loader] !== 'function') {
|
||||
console.error('ERROR: ' + loader + ' should be a function');
|
||||
process.exit(1);
|
||||
}
|
||||
const loaded = await services[loader]();
|
||||
if (loaded === undefined) {
|
||||
console.error('ERROR: ' + loader + '() should return defined service');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
console.log('✓ All ' + lazyLoaders.length + ' lazy loaders return defined services');
|
||||
})();
|
||||
"
|
||||
|
||||
@@ -201,37 +227,62 @@ jobs:
|
||||
run: |
|
||||
echo "Verifying orchestrator build wiring end-to-end..."
|
||||
node -e "
|
||||
const { loadOrchestratorPlugin } = require('./lib/model/orchestrator-plugin');
|
||||
const { loadOrchestrator, loadPluginServices } = require('./lib/model/orchestrator-plugin');
|
||||
const { Orchestrator, BuildParameters } = require('@game-ci/orchestrator');
|
||||
|
||||
(async () => {
|
||||
// Verify plugin loads successfully with orchestrator installed
|
||||
const plugin = await loadOrchestratorPlugin();
|
||||
if (plugin === undefined) {
|
||||
console.error('ERROR: plugin should be defined when orchestrator is installed');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Verify all lifecycle methods are callable
|
||||
const lifecycleMethods = [
|
||||
'initialize', 'canHandleBuild', 'handleBuild',
|
||||
'beforeLocalBuild', 'afterLocalBuild', 'handlePostBuild',
|
||||
];
|
||||
for (const m of lifecycleMethods) {
|
||||
if (typeof plugin[m] !== 'function') {
|
||||
console.error('ERROR: plugin.' + m + ' should be a function, got ' + typeof plugin[m]);
|
||||
// Verify Orchestrator has the expected static API
|
||||
const requiredMethods = ['setup', 'run'];
|
||||
for (const m of requiredMethods) {
|
||||
if (typeof Orchestrator[m] !== 'function') {
|
||||
console.error('ERROR: Orchestrator.' + m + ' should be a function, got ' + typeof Orchestrator[m]);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
console.log('✓ Plugin has all ' + lifecycleMethods.length + ' lifecycle methods');
|
||||
console.log('✓ Orchestrator has setup() and run() methods');
|
||||
|
||||
// Verify canHandleBuild returns a boolean
|
||||
const canHandle = plugin.canHandleBuild();
|
||||
if (typeof canHandle !== 'boolean') {
|
||||
console.error('ERROR: canHandleBuild() should return a boolean, got ' + typeof canHandle);
|
||||
// Verify BuildParameters.create() produces a valid config object
|
||||
const params = await BuildParameters.create();
|
||||
const requiredFields = [
|
||||
'targetPlatform', 'projectPath', 'providerStrategy',
|
||||
'editorVersion', 'buildPath', 'buildName',
|
||||
];
|
||||
for (const f of requiredFields) {
|
||||
if (params[f] === undefined) {
|
||||
console.error('ERROR: BuildParameters.' + f + ' is undefined');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
console.log('✓ BuildParameters.create() produces valid config with ' + requiredFields.length + ' required fields');
|
||||
|
||||
// Verify loadOrchestrator().run is wired to Orchestrator.run
|
||||
const orch = await loadOrchestrator();
|
||||
if (typeof orch.run !== 'function') {
|
||||
console.error('ERROR: loadOrchestrator().run is not a function');
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('✓ canHandleBuild() returns boolean');
|
||||
|
||||
console.log('✓ Plugin architecture wiring verified');
|
||||
// Call run with a bad baseImage to confirm it reaches Orchestrator.run
|
||||
// (Orchestrator.run throws 'baseImage is undefined' for images containing 'undefined')
|
||||
try {
|
||||
await orch.run(params, 'undefined-image');
|
||||
console.error('ERROR: Expected Orchestrator.run to throw for undefined baseImage');
|
||||
process.exit(1);
|
||||
} catch (e) {
|
||||
if (e.message.includes('baseImage is undefined')) {
|
||||
console.log('✓ loadOrchestrator().run() correctly wired to Orchestrator.run()');
|
||||
} else {
|
||||
console.error('ERROR: Unexpected error from Orchestrator.run:', e.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Verify plugin services wire through to real service instances
|
||||
const services = await loadPluginServices();
|
||||
if (typeof services.BuildReliabilityService.configureGitEnvironment !== 'function') {
|
||||
console.error('ERROR: BuildReliabilityService.configureGitEnvironment should be a function');
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('✓ Plugin services wire through to real orchestrator implementations');
|
||||
})();
|
||||
"
|
||||
|
||||
564
action.yml
564
action.yml
@@ -47,10 +47,6 @@ inputs:
|
||||
required: false
|
||||
default: ''
|
||||
description: 'Custom parameters to configure the build.'
|
||||
useHostNetwork:
|
||||
required: false
|
||||
default: false
|
||||
description: 'Initialises Docker using the host network. (Linux only)'
|
||||
versioning:
|
||||
required: false
|
||||
default: 'Semantic'
|
||||
@@ -108,13 +104,17 @@ inputs:
|
||||
gitPrivateToken:
|
||||
required: false
|
||||
default: ''
|
||||
description: 'Github private token to pull from github'
|
||||
providerStrategy:
|
||||
default: 'local'
|
||||
description: '[Orchestrator] Github private token to pull from github'
|
||||
gitAuthMode:
|
||||
required: false
|
||||
default: 'header'
|
||||
description:
|
||||
'Build execution strategy. Use "local" for local Docker/Mac builds. For remote builds (aws, k8s, etc.), install
|
||||
@game-ci/orchestrator and use the game-ci/orchestrator action which declares its own inputs.'
|
||||
'[Orchestrator] How git authentication is configured. "header" (default) uses http.extraHeader so the token
|
||||
never appears in clone URLs or git config. "url" embeds the token in clone URLs (legacy behavior).'
|
||||
githubOwner:
|
||||
required: false
|
||||
default: ''
|
||||
description: '[Orchestrator] GitHub owner name or organization/team name'
|
||||
runAsHostUser:
|
||||
required: false
|
||||
default: 'false'
|
||||
@@ -155,7 +155,147 @@ inputs:
|
||||
allowDirtyBuild:
|
||||
required: false
|
||||
default: ''
|
||||
description: 'Allows the branch of the build to be dirty, and still generate the build.'
|
||||
description: '[Orchestrator] Allows the branch of the build to be dirty, and still generate the build.'
|
||||
postBuildSteps:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'[Orchestrator] run a post build job in yaml format with the keys image, secrets (name, value object array),
|
||||
command string'
|
||||
preBuildSteps:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'[Orchestrator] Run a pre build job after the repository setup but before the build job (in yaml format with the
|
||||
keys image, secrets (name, value object array), command line string)'
|
||||
containerHookFiles:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'[Orchestrator] Specify the names (by file name) of custom steps to run before or after orchestrator jobs, must
|
||||
match a yaml step file inside your repo in the folder .game-ci/steps/'
|
||||
customHookFiles:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'[Orchestrator] Specify the names (by file name) of custom hooks to run before or after orchestrator jobs, must
|
||||
match a yaml step file inside your repo in the folder .game-ci/hooks/'
|
||||
customCommandHooks:
|
||||
required: false
|
||||
default: ''
|
||||
description: '[Orchestrator] Specify custom commands and trigger hooks (injects commands into jobs)'
|
||||
customJob:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'[Orchestrator] Run a custom job instead of the standard build automation for orchestrator (in yaml format with
|
||||
the keys image, secrets (name, value object array), command line string)'
|
||||
awsStackName:
|
||||
default: 'game-ci'
|
||||
required: false
|
||||
description: '[Orchestrator] The Cloud Formation stack name that must be setup before using this option.'
|
||||
providerStrategy:
|
||||
default: 'local'
|
||||
required: false
|
||||
description:
|
||||
'[Orchestrator] Either local, k8s or aws can be used to run builds on a remote cluster. Additional parameters must
|
||||
be configured.'
|
||||
fallbackProviderStrategy:
|
||||
default: ''
|
||||
required: false
|
||||
description:
|
||||
'[Orchestrator] Fallback provider when the primary is unavailable. Used with runnerCheckEnabled for automatic
|
||||
failover, or as a catch-all if the primary provider fails to initialize.'
|
||||
runnerCheckEnabled:
|
||||
default: 'false'
|
||||
required: false
|
||||
description:
|
||||
'[Orchestrator] Check GitHub Actions runner availability before starting a build. When no suitable runners are
|
||||
available and fallbackProviderStrategy is set, automatically routes to the fallback provider.'
|
||||
runnerCheckLabels:
|
||||
default: ''
|
||||
required: false
|
||||
description:
|
||||
'[Orchestrator] Comma-separated runner labels to filter when checking availability (e.g. self-hosted,linux).
|
||||
When empty, checks all runners in the repository.'
|
||||
runnerCheckMinAvailable:
|
||||
default: '1'
|
||||
required: false
|
||||
description:
|
||||
'[Orchestrator] Minimum number of idle runners required for the primary provider. If fewer are available,
|
||||
routes to fallbackProviderStrategy.'
|
||||
retryOnFallback:
|
||||
default: 'false'
|
||||
required: false
|
||||
description:
|
||||
'[Orchestrator] When true and fallbackProviderStrategy is set, automatically retry the build on the fallback
|
||||
provider if the primary provider fails. Useful for long builds where transient cloud failures are common.'
|
||||
providerInitTimeout:
|
||||
default: '0'
|
||||
required: false
|
||||
description:
|
||||
'[Orchestrator] Maximum seconds to wait for the primary provider to initialize (setupWorkflow). If exceeded
|
||||
and fallbackProviderStrategy is set, switches to the fallback. Set to 0 to disable (default).'
|
||||
secretSource:
|
||||
default: ''
|
||||
required: false
|
||||
description:
|
||||
'[Orchestrator] Premade secret source for pulling build secrets. Supported values: aws-secrets-manager,
|
||||
aws-parameter-store, gcp-secret-manager, azure-key-vault, hashicorp-vault, hashicorp-vault-kv1,
|
||||
vault (alias for hashicorp-vault), env. Can also be a custom shell command with {0} placeholder
|
||||
for the key, or a path to a YAML file defining custom sources. Takes precedence over
|
||||
inputPullCommand when set.'
|
||||
resourceTracking:
|
||||
default: 'false'
|
||||
required: false
|
||||
description: '[Orchestrator] Enable resource tracking logs for disk usage and allocation summaries.'
|
||||
containerCpu:
|
||||
default: ''
|
||||
required: false
|
||||
description: '[Orchestrator] Amount of CPU time to assign the remote build container'
|
||||
containerMemory:
|
||||
default: ''
|
||||
required: false
|
||||
description: '[Orchestrator] Amount of memory to assign the remote build container'
|
||||
readInputFromOverrideList:
|
||||
default: ''
|
||||
required: false
|
||||
description: '[Orchestrator] Comma separated list of input value names to read from "input override command"'
|
||||
readInputOverrideCommand:
|
||||
default: ''
|
||||
required: false
|
||||
description:
|
||||
'[Orchestrator] Extend game ci by specifying a command to execute to pull input from external source e.g cloud
|
||||
provider secret managers'
|
||||
kubeConfig:
|
||||
default: ''
|
||||
required: false
|
||||
description:
|
||||
'[Orchestrator] Supply a base64 encoded kubernetes config to run builds on kubernetes and stream logs until
|
||||
completion.'
|
||||
kubeVolume:
|
||||
default: ''
|
||||
required: false
|
||||
description: '[Orchestrator] Supply a Persistent Volume Claim name to use for the Unity build.'
|
||||
kubeStorageClass:
|
||||
default: ''
|
||||
required: false
|
||||
description:
|
||||
'[Orchestrator] Kubernetes storage class to use for orchestrator jobs, leave empty to install rook cluster.'
|
||||
kubeVolumeSize:
|
||||
default: '5Gi'
|
||||
required: false
|
||||
description: '[Orchestrator] Amount of disc space to assign the Kubernetes Persistent Volume'
|
||||
cacheKey:
|
||||
default: ''
|
||||
required: false
|
||||
description: '[Orchestrator] Cache key to indicate bucket for cache'
|
||||
watchToEnd:
|
||||
default: 'true'
|
||||
required: false
|
||||
description:
|
||||
'[Orchestrator] Whether or not to watch the build to the end. Can be used for especially long running jobs e.g
|
||||
imports or self-hosted ephemeral runners.'
|
||||
cacheUnityInstallationOnMac:
|
||||
default: 'false'
|
||||
required: false
|
||||
@@ -180,6 +320,408 @@ inputs:
|
||||
default: 'false'
|
||||
required: false
|
||||
description: 'Skip the activation/deactivation of Unity. This assumes Unity is already activated.'
|
||||
artifactOutputTypes:
|
||||
description: 'Comma-separated list of output types to collect (build, logs, test-results, coverage, images, metrics, data-export, server-build, custom)'
|
||||
required: false
|
||||
default: 'build,logs,test-results'
|
||||
artifactUploadTarget:
|
||||
description: 'Where to upload artifacts: github-artifacts, storage, local, none'
|
||||
required: false
|
||||
default: 'github-artifacts'
|
||||
artifactUploadPath:
|
||||
description: 'Destination path for artifact upload (storage URI or local path)'
|
||||
required: false
|
||||
artifactCompression:
|
||||
description: 'Compression for artifacts: none, gzip, lz4'
|
||||
required: false
|
||||
default: 'gzip'
|
||||
artifactRetentionDays:
|
||||
description: 'Retention period for uploaded artifacts in days'
|
||||
required: false
|
||||
default: '30'
|
||||
artifactCustomTypes:
|
||||
description: 'JSON string defining custom output types [{name, defaultPath, description}]'
|
||||
required: false
|
||||
cloneDepth:
|
||||
default: '50'
|
||||
required: false
|
||||
description: '[Orchestrator] Specifies the depth of the git clone for the repository. Use 0 for full clone.'
|
||||
orchestratorRepoName:
|
||||
default: 'game-ci/unity-builder'
|
||||
required: false
|
||||
description:
|
||||
'[Orchestrator] Specifies the repo for the unity builder. Useful if you forked the repo for testing, features, or
|
||||
fixes.'
|
||||
submoduleProfilePath:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'Path to a YAML submodule profile file (relative to repo root). Defines which submodules to initialize (branch:
|
||||
main) or skip (branch: empty). See docs for format.'
|
||||
submoduleVariantPath:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'Path to a YAML variant overlay file that modifies the base submodule profile. Used for server or debug build
|
||||
variants.'
|
||||
submoduleToken:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'Git token for authenticating submodule clones. Falls back to gitPrivateToken or GITHUB_TOKEN if empty.'
|
||||
localCacheEnabled:
|
||||
required: false
|
||||
default: 'false'
|
||||
description:
|
||||
'Enable filesystem-based caching for local builds. Caches the Unity Library folder and optionally LFS objects
|
||||
between builds without requiring actions/cache.'
|
||||
localCacheRoot:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'Root directory for local build cache. Defaults to $RUNNER_TEMP/game-ci-cache or .game-ci/cache if RUNNER_TEMP is
|
||||
not set.'
|
||||
localCacheLibrary:
|
||||
required: false
|
||||
default: 'true'
|
||||
description: 'Cache the Unity Library folder for local builds. Only effective when localCacheEnabled is true.'
|
||||
localCacheLfs:
|
||||
required: false
|
||||
default: 'false'
|
||||
description: 'Cache Git LFS objects for local builds. Only effective when localCacheEnabled is true.'
|
||||
childWorkspacesEnabled:
|
||||
required: false
|
||||
default: 'false'
|
||||
description:
|
||||
'Enable child workspace isolation for multi-product builds. Uses atomic filesystem moves for O(1) workspace
|
||||
restore instead of tar/download/extract. Ideal for 50GB+ workspaces on self-hosted runners.'
|
||||
childWorkspaceName:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'Name for this child workspace (e.g., product name like "TurnOfWar"). Used as the cache key for workspace
|
||||
isolation. Required when childWorkspacesEnabled is true.'
|
||||
childWorkspaceCacheRoot:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'Parent directory for cached child workspaces. Should be on the same NTFS volume as the build directory for O(1)
|
||||
atomic restore via filesystem rename. Defaults to $RUNNER_TEMP/game-ci-workspaces.'
|
||||
childWorkspacePreserveGit:
|
||||
required: false
|
||||
default: 'true'
|
||||
description:
|
||||
'Preserve .git directory in cached child workspace. Enables delta operations on restore but increases cache size.
|
||||
Set to false to save disk space at the cost of full re-clone on restore.'
|
||||
childWorkspaceSeparateLibrary:
|
||||
required: false
|
||||
default: 'true'
|
||||
description:
|
||||
'Cache Unity Library folder separately from the child workspace. Allows independent Library restore even when
|
||||
workspace cache is invalidated. Recommended for large projects.'
|
||||
lfsTransferAgent:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'Custom Git LFS transfer agent. Set to "elastic-git-storage" for built-in support (auto-installs from GitHub
|
||||
releases). Append @version for a specific release (e.g. "elastic-git-storage@v1.0.0"). Or provide a path to any
|
||||
custom transfer agent executable. When set, the agent is registered via git config before LFS operations.'
|
||||
lfsTransferAgentArgs:
|
||||
required: false
|
||||
default: ''
|
||||
description: 'Additional arguments to pass to the custom LFS transfer agent.'
|
||||
lfsStoragePaths:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'Semicolon-separated list of storage paths for the custom LFS transfer agent. Interpretation depends on the agent
|
||||
(e.g. local paths, WebDAV URLs, rclone remotes).'
|
||||
gitHooksEnabled:
|
||||
required: false
|
||||
default: 'false'
|
||||
description:
|
||||
'Install and run git hooks (lefthook, husky, or native) during builds. When false (default), hooks are disabled
|
||||
for build performance.'
|
||||
gitHooksSkipList:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'Comma-separated list of hook names to skip even when gitHooksEnabled is true. Example: pre-push,post-merge'
|
||||
gitHooksRunBeforeBuild:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'Comma-separated list of lefthook hook groups to run before the Unity build. Allows CI to trigger checks that
|
||||
normally only run on git events. Example: pre-commit,pre-push. Requires lefthook. Works with Unity Git Hooks
|
||||
(com.frostebite.unitygithooks) when installed as a UPM package — the init script runs automatically.'
|
||||
providerExecutable:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'Path to an external CLI executable that implements the provider protocol. Enables providers written in any
|
||||
language (Go, Python, Rust, shell). Uses JSON-over-stdin/stdout communication.'
|
||||
gcpProject:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'[Orchestrator] [Experimental] Google Cloud project ID for Cloud Run Jobs provider. Falls back to
|
||||
GOOGLE_CLOUD_PROJECT env var.'
|
||||
gcpRegion:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'[Orchestrator] [Experimental] Google Cloud region for Cloud Run Jobs (e.g. us-central1). Defaults to the region
|
||||
input if empty.'
|
||||
gcpStorageType:
|
||||
required: false
|
||||
default: 'gcs-fuse'
|
||||
description:
|
||||
'[Orchestrator] [Experimental] Storage type for Cloud Run Jobs. Options: gcs-fuse (mount GCS bucket as filesystem,
|
||||
unlimited size, best for large sequential I/O), gcs-copy (copy artifacts in/out via gsutil, simpler, no FUSE
|
||||
overhead), nfs (Filestore NFS mount, true POSIX, good random I/O, up to 100 TiB), in-memory (tmpfs, fastest but
|
||||
volatile, up to 32 GiB).'
|
||||
gcpBucket:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'[Orchestrator] [Experimental] GCS bucket name for build artifact storage. Used by gcs-fuse and gcs-copy storage
|
||||
types.'
|
||||
gcpFilestoreIp:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'[Orchestrator] [Experimental] Filestore instance IP address for NFS storage type. Required when gcpStorageType is
|
||||
nfs.'
|
||||
gcpFilestoreShare:
|
||||
required: false
|
||||
default: '/share1'
|
||||
description:
|
||||
'[Orchestrator] [Experimental] Filestore share name for NFS storage type. Defaults to /share1 (the Filestore
|
||||
default).'
|
||||
gcpMachineType:
|
||||
required: false
|
||||
default: 'e2-standard-4'
|
||||
description: '[Orchestrator] [Experimental] Machine type for Cloud Run Jobs (e.g. e2-standard-4, e2-highmem-8).'
|
||||
gcpDiskSizeGb:
|
||||
required: false
|
||||
default: '100'
|
||||
description:
|
||||
'[Orchestrator] [Experimental] Disk size in GB for Cloud Run Jobs in-memory volumes. Only applies to in-memory
|
||||
storage type (max 32).'
|
||||
gcpServiceAccount:
|
||||
required: false
|
||||
default: ''
|
||||
description: '[Orchestrator] [Experimental] Google Cloud service account email for Cloud Run Jobs execution.'
|
||||
gcpVpcConnector:
|
||||
required: false
|
||||
default: ''
|
||||
description: '[Orchestrator] [Experimental] VPC connector name for Cloud Run Jobs private networking.'
|
||||
azureResourceGroup:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'[Orchestrator] [Experimental] Azure resource group for Container Instances provider. Falls back to
|
||||
AZURE_RESOURCE_GROUP env var.'
|
||||
azureLocation:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'[Orchestrator] [Experimental] Azure region for Container Instances (e.g. eastus, westeurope). Defaults to the
|
||||
region input if empty.'
|
||||
azureStorageType:
|
||||
required: false
|
||||
default: 'azure-files'
|
||||
description:
|
||||
'[Orchestrator] [Experimental] Storage type for Azure Container Instances. Options: azure-files (SMB file share
|
||||
mount, up to 100 TiB, premium throughput), blob-copy (copy artifacts in/out via az storage blob, no mount
|
||||
overhead), azure-files-nfs (NFS 4.1 file share mount, true POSIX, no SMB lock overhead), in-memory (emptyDir
|
||||
tmpfs, fastest but volatile, size limited by container memory).'
|
||||
azureStorageAccount:
|
||||
required: false
|
||||
default: ''
|
||||
description:
|
||||
'[Orchestrator] [Experimental] Azure Storage Account name. Used by azure-files, azure-files-nfs, and blob-copy
|
||||
storage types.'
|
||||
azureFileShareName:
|
||||
required: false
|
||||
default: 'unity-builds'
|
||||
description:
|
||||
'[Orchestrator] [Experimental] Azure File Share name within the storage account. Used by azure-files and
|
||||
azure-files-nfs storage types. Supports up to 100 TiB per share.'
|
||||
azureBlobContainer:
|
||||
required: false
|
||||
default: 'unity-builds'
|
||||
description: '[Orchestrator] [Experimental] Azure Blob container name for blob-copy storage type.'
|
||||
azureSubscriptionId:
|
||||
required: false
|
||||
default: ''
|
||||
description: '[Orchestrator] [Experimental] Azure subscription ID. Falls back to AZURE_SUBSCRIPTION_ID env var.'
|
||||
azureCpu:
|
||||
required: false
|
||||
default: '4'
|
||||
description: '[Orchestrator] [Experimental] CPU cores for Azure Container Instances (1-16).'
|
||||
azureMemoryGb:
|
||||
required: false
|
||||
default: '16'
|
||||
description: '[Orchestrator] [Experimental] Memory in GB for Azure Container Instances (1-16).'
|
||||
azureDiskSizeGb:
|
||||
required: false
|
||||
default: '100'
|
||||
description:
|
||||
'[Orchestrator] [Experimental] File share quota in GB for Azure Container Instances. Premium shares support up to
|
||||
102400 GB (100 TiB).'
|
||||
azureSubnetId:
|
||||
required: false
|
||||
default: ''
|
||||
description: '[Orchestrator] [Experimental] Azure subnet resource ID for VNet-integrated Container Instances.'
|
||||
remotePowershellHost:
|
||||
default: ''
|
||||
required: false
|
||||
description: '[Orchestrator] Remote PowerShell host (hostname or IP) for the remote-powershell provider'
|
||||
remotePowershellCredential:
|
||||
default: ''
|
||||
required: false
|
||||
description: '[Orchestrator] Remote PowerShell credential (username:password or certificate path)'
|
||||
remotePowershellTransport:
|
||||
default: 'wsman'
|
||||
required: false
|
||||
description: '[Orchestrator] Remote PowerShell transport protocol (wsman or ssh)'
|
||||
githubActionsRepo:
|
||||
default: ''
|
||||
required: false
|
||||
description: '[Orchestrator] Target repository (owner/repo) for the github-actions provider'
|
||||
githubActionsWorkflow:
|
||||
default: ''
|
||||
required: false
|
||||
description: '[Orchestrator] Workflow filename or ID to dispatch for the github-actions provider'
|
||||
githubActionsToken:
|
||||
default: ''
|
||||
required: false
|
||||
description: '[Orchestrator] PAT with actions:write scope for the github-actions provider'
|
||||
githubActionsRef:
|
||||
default: 'main'
|
||||
required: false
|
||||
description: '[Orchestrator] Branch/ref to run the workflow on for the github-actions provider'
|
||||
gitlabProjectId:
|
||||
default: ''
|
||||
required: false
|
||||
description: '[Orchestrator] GitLab project ID or URL-encoded path for the gitlab-ci provider'
|
||||
gitlabTriggerToken:
|
||||
default: ''
|
||||
required: false
|
||||
description: '[Orchestrator] Pipeline trigger token for the gitlab-ci provider'
|
||||
gitlabApiUrl:
|
||||
default: 'https://gitlab.com'
|
||||
required: false
|
||||
description: '[Orchestrator] GitLab API URL (for self-hosted instances) for the gitlab-ci provider'
|
||||
gitlabRef:
|
||||
default: 'main'
|
||||
required: false
|
||||
description: '[Orchestrator] Branch/ref to trigger the pipeline on for the gitlab-ci provider'
|
||||
ansibleInventory:
|
||||
default: ''
|
||||
required: false
|
||||
description: '[Orchestrator] Path to Ansible inventory file or dynamic inventory script'
|
||||
ansiblePlaybook:
|
||||
default: ''
|
||||
required: false
|
||||
description: '[Orchestrator] Path to Ansible playbook for Unity builds'
|
||||
ansibleExtraVars:
|
||||
default: ''
|
||||
required: false
|
||||
description: '[Orchestrator] Additional Ansible variables as JSON'
|
||||
ansibleVaultPassword:
|
||||
default: ''
|
||||
required: false
|
||||
description: '[Orchestrator] Path to Ansible vault password file'
|
||||
gitIntegrityCheck:
|
||||
description: 'Run git integrity checks before build (fsck, lock cleanup, submodule validation)'
|
||||
required: false
|
||||
default: 'false'
|
||||
gitAutoRecover:
|
||||
description: 'Attempt automatic recovery if git corruption is detected'
|
||||
required: false
|
||||
default: 'false'
|
||||
cleanReservedFilenames:
|
||||
description: 'Remove Windows reserved filenames that cause Unity import loops'
|
||||
required: false
|
||||
default: 'false'
|
||||
buildArchiveEnabled:
|
||||
description: 'Archive build output after successful build'
|
||||
required: false
|
||||
default: 'false'
|
||||
buildArchivePath:
|
||||
description: 'Path to store build archives'
|
||||
required: false
|
||||
default: './build-archives'
|
||||
buildArchiveRetention:
|
||||
description: 'Days to retain build archives before cleanup'
|
||||
required: false
|
||||
default: '30'
|
||||
testSuitePath:
|
||||
description: 'Path to YAML test suite definition file'
|
||||
required: false
|
||||
testSuiteEvent:
|
||||
description: 'CI event name for suite selection (pr, push, release)'
|
||||
required: false
|
||||
testTaxonomyPath:
|
||||
description: 'Path to custom taxonomy definition YAML'
|
||||
required: false
|
||||
testResultFormat:
|
||||
description: 'Test result output format: junit, json, or both'
|
||||
required: false
|
||||
default: 'junit'
|
||||
testResultPath:
|
||||
description: 'Directory for structured test result output'
|
||||
required: false
|
||||
default: './test-results'
|
||||
|
||||
hotRunnerEnabled:
|
||||
description: '[HotRunner] Use persistent hot runner for builds (requires pre-registered runners)'
|
||||
required: false
|
||||
default: 'false'
|
||||
hotRunnerTransport:
|
||||
description: '[HotRunner] Transport protocol for hot runner communication: websocket, grpc, named-pipe'
|
||||
required: false
|
||||
default: 'websocket'
|
||||
hotRunnerHost:
|
||||
description: '[HotRunner] Hot runner host address'
|
||||
required: false
|
||||
default: 'localhost'
|
||||
hotRunnerPort:
|
||||
description: '[HotRunner] Hot runner port number'
|
||||
required: false
|
||||
default: '9090'
|
||||
hotRunnerHealthInterval:
|
||||
description: '[HotRunner] Health check interval in seconds'
|
||||
required: false
|
||||
default: '30'
|
||||
hotRunnerMaxIdle:
|
||||
description: '[HotRunner] Maximum idle time in seconds before recycling runner'
|
||||
required: false
|
||||
default: '3600'
|
||||
hotRunnerFallbackToCold:
|
||||
description: '[HotRunner] Fall back to cold build if no hot runner available'
|
||||
required: false
|
||||
default: 'true'
|
||||
syncStrategy:
|
||||
description: 'Workspace sync strategy: full, git-delta, direct-input, storage-pull'
|
||||
required: false
|
||||
default: 'full'
|
||||
syncInputRef:
|
||||
description: 'URI for direct-input or storage-pull content (storage://remote/path or file path)'
|
||||
required: false
|
||||
syncStorageRemote:
|
||||
description: 'rclone remote name for storage-backed inputs (defaults to rcloneRemote)'
|
||||
required: false
|
||||
syncRevertAfter:
|
||||
description: 'Revert overlaid changes after job completion'
|
||||
required: false
|
||||
default: 'true'
|
||||
syncStatePath:
|
||||
description: 'Path to sync state file for delta tracking'
|
||||
required: false
|
||||
default: '.game-ci/sync-state.json'
|
||||
|
||||
outputs:
|
||||
volume:
|
||||
@@ -193,6 +735,8 @@ outputs:
|
||||
'Returns the exit code from the build scripts. This code is 0 if the build was successful. If there was an error
|
||||
during activation, the code is from the activation step. If activation is successful, the code is from the project
|
||||
build step.'
|
||||
artifactManifestPath:
|
||||
description: 'Path to the generated artifact manifest JSON file'
|
||||
branding:
|
||||
icon: 'box'
|
||||
color: 'gray-dark'
|
||||
|
||||
838
dist/index.js
generated
vendored
838
dist/index.js
generated
vendored
@@ -34,6 +34,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const core = __importStar(__nccwpck_require__(42186));
|
||||
const node_path_1 = __importDefault(__nccwpck_require__(49411));
|
||||
const model_1 = __nccwpck_require__(41359);
|
||||
const cli_1 = __nccwpck_require__(55651);
|
||||
const mac_builder_1 = __importDefault(__nccwpck_require__(39364));
|
||||
@@ -47,33 +48,258 @@ async function runMain() {
|
||||
}
|
||||
model_1.Action.checkCompatibility();
|
||||
model_1.Cache.verify();
|
||||
const plugin = await (0, orchestrator_plugin_1.loadPluginServices)();
|
||||
// Always configure git environment for CI reliability
|
||||
plugin?.BuildReliabilityService.configureGitEnvironment();
|
||||
const { workspace, actionFolder } = model_1.Action;
|
||||
const buildParameters = await model_1.BuildParameters.create();
|
||||
// If a test suite path is provided, use the test workflow engine
|
||||
// instead of the standard build execution path
|
||||
if (buildParameters.testSuitePath) {
|
||||
core.info('[TestWorkflow] Test suite path detected, using test workflow engine');
|
||||
const results = await plugin?.TestWorkflowService.executeTestSuite(buildParameters.testSuitePath, buildParameters);
|
||||
let totalFailed = 0;
|
||||
for (const result of results || []) {
|
||||
totalFailed += result.failed;
|
||||
}
|
||||
if (totalFailed > 0) {
|
||||
core.setFailed(`Test workflow completed with ${totalFailed} failure(s)`);
|
||||
}
|
||||
else {
|
||||
core.info('[TestWorkflow] All test runs passed');
|
||||
}
|
||||
return;
|
||||
}
|
||||
const baseImage = new model_1.ImageTag(buildParameters);
|
||||
// Load orchestrator plugin (optional — only needed for remote builds and plugin features)
|
||||
const plugin = await (0, orchestrator_plugin_1.loadOrchestratorPlugin)();
|
||||
await plugin?.initialize(buildParameters, workspace);
|
||||
// Pre-build reliability checks
|
||||
if (buildParameters.gitIntegrityCheck) {
|
||||
core.info('Running git integrity checks...');
|
||||
const isHealthy = plugin?.BuildReliabilityService.checkGitIntegrity(workspace);
|
||||
plugin?.BuildReliabilityService.cleanStaleLockFiles(workspace);
|
||||
plugin?.BuildReliabilityService.validateSubmoduleBackingStores(workspace);
|
||||
if (buildParameters.cleanReservedFilenames) {
|
||||
plugin?.BuildReliabilityService.cleanReservedFilenames(buildParameters.projectPath);
|
||||
}
|
||||
if (!isHealthy && buildParameters.gitAutoRecover) {
|
||||
core.info('Git corruption detected, attempting automatic recovery...');
|
||||
const recovered = plugin?.BuildReliabilityService.recoverCorruptedRepo(workspace);
|
||||
if (!recovered) {
|
||||
core.warning('Automatic recovery failed. Build may encounter issues.');
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (buildParameters.cleanReservedFilenames) {
|
||||
// cleanReservedFilenames can run independently of gitIntegrityCheck
|
||||
plugin?.BuildReliabilityService.cleanReservedFilenames(buildParameters.projectPath);
|
||||
}
|
||||
let exitCode = -1;
|
||||
if (plugin?.canHandleBuild()) {
|
||||
// Plugin handles the build entirely (remote providers, hot runner, test workflows)
|
||||
const result = await plugin.handleBuild(baseImage.toString());
|
||||
exitCode = result.fallbackToLocal
|
||||
? await runLocalBuild(buildParameters, baseImage, workspace, actionFolder, plugin)
|
||||
: result.exitCode;
|
||||
// Hot runner path: attempt to use a persistent Unity editor instance
|
||||
if (buildParameters.hotRunnerEnabled) {
|
||||
core.info('[HotRunner] Hot runner mode enabled, attempting hot build...');
|
||||
const hotRunnerConfig = {
|
||||
enabled: true,
|
||||
transport: buildParameters.hotRunnerTransport,
|
||||
host: buildParameters.hotRunnerHost,
|
||||
port: buildParameters.hotRunnerPort,
|
||||
healthCheckInterval: buildParameters.hotRunnerHealthInterval,
|
||||
maxIdleTime: buildParameters.hotRunnerMaxIdle,
|
||||
maxJobsBeforeRecycle: 0, // no automatic recycle by job count
|
||||
};
|
||||
if (!plugin?.HotRunnerService) {
|
||||
throw new Error('[HotRunner] Orchestrator plugin required for hot runner mode');
|
||||
}
|
||||
const hotRunnerService = new plugin.HotRunnerService();
|
||||
try {
|
||||
await hotRunnerService.initialize(hotRunnerConfig);
|
||||
const result = await hotRunnerService.submitBuild(buildParameters, (output) => {
|
||||
core.info(output);
|
||||
});
|
||||
exitCode = result.exitCode;
|
||||
core.info(`[HotRunner] Build completed with exit code ${exitCode}`);
|
||||
await hotRunnerService.shutdown();
|
||||
}
|
||||
catch (hotRunnerError) {
|
||||
await hotRunnerService.shutdown();
|
||||
if (buildParameters.hotRunnerFallbackToCold) {
|
||||
core.warning(`[HotRunner] Hot runner failed: ${hotRunnerError.message}. Falling back to cold build.`);
|
||||
exitCode = await runColdBuild(buildParameters, baseImage, workspace, actionFolder);
|
||||
}
|
||||
else {
|
||||
throw hotRunnerError;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (buildParameters.providerStrategy === 'local') {
|
||||
exitCode = await runLocalBuild(buildParameters, baseImage, workspace, actionFolder, plugin);
|
||||
core.info('Building locally');
|
||||
// Child workspace isolation - restore cached workspace before any other setup
|
||||
let childWorkspaceConfig;
|
||||
if (buildParameters.childWorkspacesEnabled && buildParameters.childWorkspaceName) {
|
||||
const ChildWorkspaceService = await plugin?.loadChildWorkspaceService();
|
||||
const cacheRoot = buildParameters.childWorkspaceCacheRoot ||
|
||||
node_path_1.default.join(buildParameters.runnerTempPath || process.env.RUNNER_TEMP || '', 'game-ci-workspaces');
|
||||
childWorkspaceConfig = ChildWorkspaceService?.buildConfig({
|
||||
childWorkspacesEnabled: buildParameters.childWorkspacesEnabled,
|
||||
childWorkspaceName: buildParameters.childWorkspaceName,
|
||||
childWorkspaceCacheRoot: cacheRoot,
|
||||
childWorkspacePreserveGit: buildParameters.childWorkspacePreserveGit,
|
||||
childWorkspaceSeparateLibrary: buildParameters.childWorkspaceSeparateLibrary,
|
||||
});
|
||||
const projectFullPath = node_path_1.default.join(workspace, buildParameters.projectPath);
|
||||
const restored = ChildWorkspaceService?.initializeWorkspace(projectFullPath, childWorkspaceConfig);
|
||||
core.info(`Child workspace "${buildParameters.childWorkspaceName}": ${restored ? 'restored from cache' : 'starting fresh'}`);
|
||||
// Log workspace size for resource tracking
|
||||
const size = ChildWorkspaceService?.getWorkspaceSize(projectFullPath);
|
||||
core.info(`Child workspace size after restore: ${size}`);
|
||||
}
|
||||
// Submodule profile initialization
|
||||
if (buildParameters.submoduleProfilePath) {
|
||||
core.info('Initializing submodules from profile...');
|
||||
const SubmoduleProfileService = await plugin?.loadSubmoduleProfileService();
|
||||
const plan = await SubmoduleProfileService?.createInitPlan(buildParameters.submoduleProfilePath, buildParameters.submoduleVariantPath, workspace);
|
||||
if (plan) {
|
||||
await SubmoduleProfileService?.execute(plan, workspace, buildParameters.submoduleToken || buildParameters.gitPrivateToken);
|
||||
}
|
||||
}
|
||||
// Configure custom LFS transfer agent
|
||||
if (buildParameters.lfsTransferAgent) {
|
||||
core.info('Configuring custom LFS transfer agent...');
|
||||
const LfsAgentService = await plugin?.loadLfsAgentService();
|
||||
await LfsAgentService?.configure(buildParameters.lfsTransferAgent, buildParameters.lfsTransferAgentArgs, buildParameters.lfsStoragePaths ? buildParameters.lfsStoragePaths.split(';') : [], workspace);
|
||||
}
|
||||
// Local build caching - restore
|
||||
let cacheRoot = '';
|
||||
let cacheKey = '';
|
||||
// eslint-disable-next-line no-undef
|
||||
let LocalCacheService;
|
||||
if (buildParameters.localCacheEnabled) {
|
||||
LocalCacheService = await plugin?.loadLocalCacheService();
|
||||
cacheRoot = LocalCacheService?.resolveCacheRoot(buildParameters) || '';
|
||||
cacheKey =
|
||||
LocalCacheService?.generateCacheKey(buildParameters.targetPlatform, buildParameters.editorVersion, buildParameters.branch || '') || '';
|
||||
if (buildParameters.localCacheLfs) {
|
||||
await LocalCacheService?.restoreLfsCache(workspace, cacheRoot, cacheKey);
|
||||
}
|
||||
if (buildParameters.localCacheLibrary) {
|
||||
const projectFullPath = node_path_1.default.join(workspace, buildParameters.projectPath);
|
||||
await LocalCacheService?.restoreLibraryCache(projectFullPath, cacheRoot, cacheKey);
|
||||
}
|
||||
}
|
||||
// Git hooks — opt-in only. When disabled (default), do not touch hooks at all.
|
||||
if (buildParameters.gitHooksEnabled) {
|
||||
const GitHooksService = await plugin?.loadGitHooksService();
|
||||
await GitHooksService?.installHooks(workspace);
|
||||
if (buildParameters.gitHooksSkipList) {
|
||||
const environment = GitHooksService?.configureSkipList(buildParameters.gitHooksSkipList.split(','));
|
||||
if (environment) {
|
||||
Object.assign(process.env, environment);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Apply incremental sync strategy before build
|
||||
const syncStrategy = buildParameters.syncStrategy;
|
||||
if (syncStrategy !== 'full') {
|
||||
core.info(`[Sync] Applying sync strategy: ${syncStrategy}`);
|
||||
await applySyncStrategy(buildParameters, workspace, plugin);
|
||||
}
|
||||
await platform_setup_1.default.setup(buildParameters, actionFolder);
|
||||
exitCode =
|
||||
process.platform === 'darwin'
|
||||
? await mac_builder_1.default.run(actionFolder)
|
||||
: await model_1.Docker.run(baseImage.toString(), {
|
||||
workspace,
|
||||
actionFolder,
|
||||
...buildParameters,
|
||||
});
|
||||
// Local build caching - save
|
||||
if (buildParameters.localCacheEnabled && LocalCacheService) {
|
||||
if (buildParameters.localCacheLibrary) {
|
||||
const projectFullPath = node_path_1.default.join(workspace, buildParameters.projectPath);
|
||||
await LocalCacheService.saveLibraryCache(projectFullPath, cacheRoot, cacheKey);
|
||||
}
|
||||
if (buildParameters.localCacheLfs) {
|
||||
await LocalCacheService.saveLfsCache(workspace, cacheRoot, cacheKey);
|
||||
}
|
||||
}
|
||||
// Child workspace isolation - save workspace for next run
|
||||
if (childWorkspaceConfig && childWorkspaceConfig.enabled) {
|
||||
const ChildWorkspaceService = await plugin?.loadChildWorkspaceService();
|
||||
const projectFullPath = node_path_1.default.join(workspace, buildParameters.projectPath);
|
||||
const preSaveSize = ChildWorkspaceService?.getWorkspaceSize(projectFullPath);
|
||||
core.info(`Child workspace size before save: ${preSaveSize}`);
|
||||
ChildWorkspaceService?.saveWorkspace(projectFullPath, childWorkspaceConfig);
|
||||
core.info(`Child workspace "${buildParameters.childWorkspaceName}" saved to cache`);
|
||||
}
|
||||
// Revert overlays after job completion if configured
|
||||
if (buildParameters.syncRevertAfter && syncStrategy !== 'full') {
|
||||
core.info('[Sync] Reverting overlay changes after job completion');
|
||||
try {
|
||||
await plugin?.IncrementalSyncService.revertOverlays(workspace, buildParameters.syncStatePath);
|
||||
}
|
||||
catch (revertError) {
|
||||
core.warning(`[Sync] Overlay revert failed: ${revertError.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new Error(`Provider strategy "${buildParameters.providerStrategy}" requires @game-ci/orchestrator. ` +
|
||||
'Install it via the game-ci/orchestrator action, or use providerStrategy=local.');
|
||||
const orchestrator = await (0, orchestrator_plugin_1.loadOrchestrator)();
|
||||
if (!orchestrator) {
|
||||
throw new Error('Orchestrator package not available. Install @game-ci/orchestrator or use providerStrategy=local.');
|
||||
}
|
||||
await orchestrator.run(buildParameters, baseImage.toString());
|
||||
exitCode = 0;
|
||||
}
|
||||
// Set core outputs
|
||||
// Post-build: archive and enforce retention
|
||||
if (buildParameters.buildArchiveEnabled && exitCode === 0) {
|
||||
core.info('Archiving build output...');
|
||||
plugin?.BuildReliabilityService.archiveBuildOutput(buildParameters.buildPath, buildParameters.buildArchivePath);
|
||||
plugin?.BuildReliabilityService.enforceRetention(buildParameters.buildArchivePath, buildParameters.buildArchiveRetention);
|
||||
}
|
||||
// Set output
|
||||
await model_1.Output.setBuildVersion(buildParameters.buildVersion);
|
||||
await model_1.Output.setAndroidVersionCode(buildParameters.androidVersionCode);
|
||||
await model_1.Output.setEngineExitCode(exitCode);
|
||||
// Plugin handles post-build (artifacts, archiving, retention)
|
||||
await plugin?.handlePostBuild(exitCode);
|
||||
// Artifact collection and upload (runs on both success and failure)
|
||||
try {
|
||||
// Register custom output types if provided
|
||||
if (buildParameters.artifactCustomTypes) {
|
||||
try {
|
||||
const customTypes = JSON.parse(buildParameters.artifactCustomTypes);
|
||||
if (Array.isArray(customTypes)) {
|
||||
for (const ct of customTypes) {
|
||||
plugin?.OutputTypeRegistry.registerType({
|
||||
name: ct.name,
|
||||
defaultPath: ct.defaultPath || ct.pattern || `./${ct.name}/`,
|
||||
description: ct.description || `Custom output type: ${ct.name}`,
|
||||
builtIn: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (parseError) {
|
||||
core.warning(`Failed to parse artifactCustomTypes: ${parseError.message}`);
|
||||
}
|
||||
}
|
||||
// Collect outputs and generate manifest
|
||||
const manifestPath = node_path_1.default.join(buildParameters.projectPath, 'output-manifest.json');
|
||||
const manifest = await plugin?.OutputService.collectOutputs(buildParameters.projectPath, buildParameters.buildGuid, buildParameters.artifactOutputTypes, manifestPath);
|
||||
core.setOutput('artifactManifestPath', manifestPath);
|
||||
if (manifest) {
|
||||
// Upload artifacts
|
||||
const uploadConfig = plugin?.ArtifactUploadHandler.parseConfig(buildParameters.artifactUploadTarget, buildParameters.artifactUploadPath || undefined, buildParameters.artifactCompression, buildParameters.artifactRetentionDays);
|
||||
if (uploadConfig) {
|
||||
const uploadResult = await plugin?.ArtifactUploadHandler.uploadArtifacts(manifest, uploadConfig, buildParameters.projectPath);
|
||||
if (uploadResult && !uploadResult.success) {
|
||||
core.warning(`Artifact upload completed with errors: ${uploadResult.entries
|
||||
.filter((entry) => !entry.success)
|
||||
.map((entry) => `${entry.type}: ${entry.error}`)
|
||||
.join('; ')}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (artifactError) {
|
||||
core.warning(`Artifact collection/upload failed: ${artifactError.message}`);
|
||||
}
|
||||
if (exitCode !== 0) {
|
||||
core.setFailed(`Build failed with exit code ${exitCode}`);
|
||||
}
|
||||
@@ -82,18 +308,72 @@ async function runMain() {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
async function runLocalBuild(buildParameters, baseImage, workspace, actionFolder, plugin) {
|
||||
await plugin?.beforeLocalBuild(workspace);
|
||||
await platform_setup_1.default.setup(buildParameters, actionFolder);
|
||||
const exitCode = process.platform === 'darwin'
|
||||
? await mac_builder_1.default.run(actionFolder)
|
||||
: await model_1.Docker.run(baseImage.toString(), {
|
||||
workspace,
|
||||
actionFolder,
|
||||
...buildParameters,
|
||||
});
|
||||
await plugin?.afterLocalBuild(workspace, exitCode);
|
||||
return exitCode;
|
||||
async function runColdBuild(buildParameters, baseImage, workspace, actionFolder) {
|
||||
if (buildParameters.providerStrategy === 'local') {
|
||||
core.info('Building locally');
|
||||
await platform_setup_1.default.setup(buildParameters, actionFolder);
|
||||
return process.platform === 'darwin'
|
||||
? await mac_builder_1.default.run(actionFolder)
|
||||
: await model_1.Docker.run(baseImage.toString(), {
|
||||
workspace,
|
||||
actionFolder,
|
||||
...buildParameters,
|
||||
});
|
||||
}
|
||||
else {
|
||||
const orchestrator = await (0, orchestrator_plugin_1.loadOrchestrator)();
|
||||
if (!orchestrator) {
|
||||
throw new Error('Orchestrator package not available. Install @game-ci/orchestrator or use providerStrategy=local.');
|
||||
}
|
||||
await orchestrator.run(buildParameters, baseImage.toString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Apply the configured sync strategy to the workspace before build.
|
||||
*/
|
||||
async function applySyncStrategy(buildParameters, workspace, plugin) {
|
||||
if (!plugin?.IncrementalSyncService) {
|
||||
core.warning('[Sync] Orchestrator plugin not available, skipping sync strategy');
|
||||
return;
|
||||
}
|
||||
const { IncrementalSyncService } = plugin;
|
||||
const strategy = buildParameters.syncStrategy;
|
||||
const resolvedStrategy = IncrementalSyncService.resolveStrategy(strategy, workspace, buildParameters.syncStatePath);
|
||||
if (resolvedStrategy === 'full') {
|
||||
core.info('[Sync] Resolved to full sync (no incremental state available)');
|
||||
return;
|
||||
}
|
||||
switch (resolvedStrategy) {
|
||||
case 'git-delta': {
|
||||
const targetReference = buildParameters.gitSha || buildParameters.branch;
|
||||
const changedFiles = await IncrementalSyncService.syncGitDelta(workspace, targetReference, buildParameters.syncStatePath);
|
||||
core.info(`[Sync] Git delta sync applied: ${changedFiles} file(s) changed`);
|
||||
break;
|
||||
}
|
||||
case 'direct-input': {
|
||||
if (!buildParameters.syncInputRef) {
|
||||
throw new Error('[Sync] direct-input strategy requires syncInputRef to be set');
|
||||
}
|
||||
const overlays = await IncrementalSyncService.applyDirectInput(workspace, buildParameters.syncInputRef, buildParameters.syncStorageRemote || undefined, buildParameters.syncStatePath);
|
||||
core.info(`[Sync] Direct input applied: ${overlays.length} overlay(s)`);
|
||||
break;
|
||||
}
|
||||
case 'storage-pull': {
|
||||
if (!buildParameters.syncInputRef) {
|
||||
throw new Error('[Sync] storage-pull strategy requires syncInputRef to be set');
|
||||
}
|
||||
const pulledFiles = await IncrementalSyncService.syncStoragePull(workspace, buildParameters.syncInputRef, {
|
||||
rcloneRemote: buildParameters.syncStorageRemote || undefined,
|
||||
syncRevertAfter: buildParameters.syncRevertAfter,
|
||||
statePath: buildParameters.syncStatePath,
|
||||
});
|
||||
core.info(`[Sync] Storage pull complete: ${pulledFiles.length} file(s)`);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
core.warning(`[Sync] Unknown sync strategy: ${resolvedStrategy}`);
|
||||
}
|
||||
}
|
||||
runMain();
|
||||
|
||||
@@ -298,7 +578,6 @@ class BuildParameters {
|
||||
core.setSecret(unitySerial);
|
||||
core.setSecret(`${unitySerial.slice(0, -4)}XXXX`);
|
||||
}
|
||||
const providerStrategy = input_1.default.getInput('providerStrategy') || (cli_1.Cli.isCliMode ? 'aws' : 'local');
|
||||
return {
|
||||
editorVersion,
|
||||
customImage: input_1.default.customImage,
|
||||
@@ -327,7 +606,6 @@ class BuildParameters {
|
||||
androidExportType: input_1.default.androidExportType,
|
||||
androidSymbolType: androidSymbolExportType,
|
||||
customParameters: input_1.default.customParameters,
|
||||
useHostNetwork: input_1.default.useHostNetwork,
|
||||
sshAgent: input_1.default.sshAgent,
|
||||
sshPublicKeysDirectoryPath: input_1.default.sshPublicKeysDirectoryPath,
|
||||
gitPrivateToken: input_1.default.gitPrivateToken ?? (await github_cli_1.GithubCliReader.GetGitHubAuthToken()),
|
||||
@@ -338,18 +616,156 @@ class BuildParameters {
|
||||
dockerIsolationMode: input_1.default.dockerIsolationMode,
|
||||
containerRegistryRepository: input_1.default.containerRegistryRepository,
|
||||
containerRegistryImageVersion: input_1.default.containerRegistryImageVersion,
|
||||
providerStrategy,
|
||||
buildPlatform: providerStrategy !== 'local' ? 'linux' : process.platform,
|
||||
providerStrategy: input_1.default.getInput('providerStrategy') || (cli_1.Cli.isCliMode ? 'aws' : 'local'),
|
||||
fallbackProviderStrategy: input_1.default.getInput('fallbackProviderStrategy') || '',
|
||||
runnerCheckEnabled: input_1.default.getInput('runnerCheckEnabled') === 'true',
|
||||
runnerCheckLabels: (input_1.default.getInput('runnerCheckLabels') || '')
|
||||
.split(',')
|
||||
.map((l) => l.trim())
|
||||
.filter(Boolean),
|
||||
runnerCheckMinAvailable: Number(input_1.default.getInput('runnerCheckMinAvailable')) || 1,
|
||||
retryOnFallback: input_1.default.getInput('retryOnFallback') === 'true',
|
||||
providerInitTimeout: Number(input_1.default.getInput('providerInitTimeout')) || 0,
|
||||
gitAuthMode: input_1.default.getInput('gitAuthMode') || 'header',
|
||||
buildPlatform: input_1.default.getInput('buildPlatform') ||
|
||||
((input_1.default.getInput('providerStrategy') || 'local') !== 'local' ? 'linux' : process.platform),
|
||||
kubeConfig: input_1.default.getInput('kubeConfig') || '',
|
||||
containerMemory: input_1.default.getInput('containerMemory') || '3072',
|
||||
containerCpu: input_1.default.getInput('containerCpu') || '1024',
|
||||
containerNamespace: input_1.default.getInput('containerNamespace') || 'default',
|
||||
kubeVolumeSize: input_1.default.getInput('kubeVolumeSize') || '25Gi',
|
||||
kubeVolume: input_1.default.getInput('kubeVolume') || '',
|
||||
postBuildContainerHooks: input_1.default.getInput('postBuildContainerHooks') || '',
|
||||
preBuildContainerHooks: input_1.default.getInput('preBuildContainerHooks') || '',
|
||||
customJob: input_1.default.getInput('customJob') || '',
|
||||
runNumber: input_1.default.runNumber,
|
||||
branch: input_1.default.branch.replace('/head', '') || (await git_repo_1.GitRepoReader.GetBranch()),
|
||||
githubRepo: (input_1.default.githubRepo ?? (await git_repo_1.GitRepoReader.GetRemote())) || 'game-ci/unity-builder',
|
||||
orchestratorBranch: (input_1.default.getInput('orchestratorBranch') || 'main').split('/').reverse()[0],
|
||||
orchestratorDebug: input_1.default.getInput('orchestratorDebug') === 'true' || input_1.default.getInput('orchestratorTests') === 'true',
|
||||
githubRepo: (input_1.default.githubRepo ?? (await git_repo_1.GitRepoReader.GetRemote())) ||
|
||||
input_1.default.getInput('orchestratorRepoName') ||
|
||||
'game-ci/unity-builder',
|
||||
orchestratorRepoName: input_1.default.getInput('orchestratorRepoName') || 'game-ci/unity-builder',
|
||||
cloneDepth: Number.parseInt(input_1.default.getInput('cloneDepth') || '50'),
|
||||
isCliMode: cli_1.Cli.isCliMode,
|
||||
awsStackName: input_1.default.getInput('awsStackName') || 'game-ci',
|
||||
awsEndpoint: input_1.default.getInput('awsEndpoint'),
|
||||
awsCloudFormationEndpoint: input_1.default.getInput('awsCloudFormationEndpoint') || input_1.default.getInput('awsEndpoint'),
|
||||
awsEcsEndpoint: input_1.default.getInput('awsEcsEndpoint') || input_1.default.getInput('awsEndpoint'),
|
||||
awsKinesisEndpoint: input_1.default.getInput('awsKinesisEndpoint') || input_1.default.getInput('awsEndpoint'),
|
||||
awsCloudWatchLogsEndpoint: input_1.default.getInput('awsCloudWatchLogsEndpoint') || input_1.default.getInput('awsEndpoint'),
|
||||
awsS3Endpoint: input_1.default.getInput('awsS3Endpoint') || input_1.default.getInput('awsEndpoint'),
|
||||
storageProvider: input_1.default.getInput('storageProvider') || 's3',
|
||||
rcloneRemote: input_1.default.getInput('rcloneRemote') || '',
|
||||
gitSha: input_1.default.gitSha,
|
||||
logId: (0, nanoid_1.customAlphabet)('0123456789abcdefghijklmnopqrstuvwxyz', 9)(),
|
||||
buildGuid: `${input_1.default.runNumber}-${input_1.default.targetPlatform.toLowerCase().replace('standalone', '')}-${(0, nanoid_1.customAlphabet)('0123456789abcdefghijklmnopqrstuvwxyz', 4)()}`,
|
||||
isCliMode: cli_1.Cli.isCliMode,
|
||||
commandHooks: input_1.default.getInput('commandHooks') || '',
|
||||
inputPullCommand: input_1.default.getInput('inputPullCommand') || '',
|
||||
pullInputList: (input_1.default.getInput('pullInputList') || '').split(',').filter(Boolean),
|
||||
kubeStorageClass: input_1.default.getInput('kubeStorageClass') || '',
|
||||
gcpProject: input_1.default.gcpProject,
|
||||
gcpRegion: input_1.default.gcpRegion,
|
||||
gcpStorageType: input_1.default.gcpStorageType,
|
||||
gcpBucket: input_1.default.gcpBucket,
|
||||
gcpFilestoreIp: input_1.default.gcpFilestoreIp,
|
||||
gcpFilestoreShare: input_1.default.gcpFilestoreShare,
|
||||
gcpMachineType: input_1.default.gcpMachineType,
|
||||
gcpDiskSizeGb: input_1.default.gcpDiskSizeGb,
|
||||
gcpServiceAccount: input_1.default.gcpServiceAccount,
|
||||
gcpVpcConnector: input_1.default.gcpVpcConnector,
|
||||
azureResourceGroup: input_1.default.azureResourceGroup,
|
||||
azureLocation: input_1.default.azureLocation,
|
||||
azureStorageType: input_1.default.azureStorageType,
|
||||
azureStorageAccount: input_1.default.azureStorageAccount,
|
||||
azureBlobContainer: input_1.default.azureBlobContainer,
|
||||
azureFileShareName: input_1.default.azureFileShareName,
|
||||
azureSubscriptionId: input_1.default.azureSubscriptionId,
|
||||
azureCpu: input_1.default.azureCpu,
|
||||
azureMemoryGb: input_1.default.azureMemoryGb,
|
||||
azureDiskSizeGb: input_1.default.azureDiskSizeGb,
|
||||
azureSubnetId: input_1.default.azureSubnetId,
|
||||
cacheKey: input_1.default.getInput('cacheKey') || input_1.default.branch,
|
||||
maxRetainedWorkspaces: Number.parseInt(input_1.default.getInput('maxRetainedWorkspaces') || '0'),
|
||||
useLargePackages: input_1.default.getInput('useLargePackages') === 'true',
|
||||
useCompressionStrategy: input_1.default.getInput('useCompressionStrategy') === 'true',
|
||||
garbageMaxAge: Number(input_1.default.getInput('garbageMaxAge')) || 24,
|
||||
githubChecks: input_1.default.getInput('githubChecks') === 'true',
|
||||
asyncWorkflow: input_1.default.getInput('asyncOrchestrator') === 'true',
|
||||
githubCheckId: input_1.default.getInput('githubCheckId') || '',
|
||||
finalHooks: (input_1.default.getInput('finalHooks') || '').split(',').filter(Boolean),
|
||||
skipLfs: input_1.default.getInput('skipLfs') === 'true',
|
||||
skipCache: input_1.default.getInput('skipCache') === 'true',
|
||||
cacheUnityInstallationOnMac: input_1.default.cacheUnityInstallationOnMac,
|
||||
unityHubVersionOnMac: input_1.default.unityHubVersionOnMac,
|
||||
dockerWorkspacePath: input_1.default.dockerWorkspacePath,
|
||||
submoduleProfilePath: input_1.default.submoduleProfilePath,
|
||||
submoduleVariantPath: input_1.default.submoduleVariantPath,
|
||||
submoduleToken: input_1.default.submoduleToken,
|
||||
localCacheEnabled: input_1.default.localCacheEnabled,
|
||||
localCacheRoot: input_1.default.localCacheRoot,
|
||||
localCacheLibrary: input_1.default.localCacheLibrary,
|
||||
localCacheLfs: input_1.default.localCacheLfs,
|
||||
childWorkspacesEnabled: input_1.default.childWorkspacesEnabled,
|
||||
childWorkspaceName: input_1.default.childWorkspaceName,
|
||||
childWorkspaceCacheRoot: input_1.default.childWorkspaceCacheRoot,
|
||||
childWorkspacePreserveGit: input_1.default.childWorkspacePreserveGit,
|
||||
childWorkspaceSeparateLibrary: input_1.default.childWorkspaceSeparateLibrary,
|
||||
lfsTransferAgent: input_1.default.lfsTransferAgent,
|
||||
lfsTransferAgentArgs: input_1.default.lfsTransferAgentArgs,
|
||||
lfsStoragePaths: input_1.default.lfsStoragePaths,
|
||||
gitHooksEnabled: input_1.default.gitHooksEnabled,
|
||||
gitHooksSkipList: input_1.default.gitHooksSkipList,
|
||||
gitHooksRunBeforeBuild: input_1.default.gitHooksRunBeforeBuild,
|
||||
providerExecutable: input_1.default.providerExecutable,
|
||||
// Remote PowerShell provider
|
||||
remotePowershellHost: input_1.default.remotePowershellHost,
|
||||
remotePowershellCredential: input_1.default.remotePowershellCredential,
|
||||
remotePowershellTransport: input_1.default.remotePowershellTransport,
|
||||
// GitHub Actions provider
|
||||
githubActionsRepo: input_1.default.githubActionsRepo,
|
||||
githubActionsWorkflow: input_1.default.githubActionsWorkflow,
|
||||
githubActionsToken: input_1.default.githubActionsToken,
|
||||
githubActionsRef: input_1.default.githubActionsRef,
|
||||
// GitLab CI provider
|
||||
gitlabProjectId: input_1.default.gitlabProjectId,
|
||||
gitlabTriggerToken: input_1.default.gitlabTriggerToken,
|
||||
gitlabApiUrl: input_1.default.gitlabApiUrl,
|
||||
gitlabRef: input_1.default.gitlabRef,
|
||||
// Ansible provider
|
||||
ansibleInventory: input_1.default.ansibleInventory,
|
||||
ansiblePlaybook: input_1.default.ansiblePlaybook,
|
||||
ansibleExtraVars: input_1.default.ansibleExtraVars,
|
||||
ansibleVaultPassword: input_1.default.ansibleVaultPassword,
|
||||
gitIntegrityCheck: input_1.default.gitIntegrityCheck,
|
||||
gitAutoRecover: input_1.default.gitAutoRecover,
|
||||
cleanReservedFilenames: input_1.default.cleanReservedFilenames,
|
||||
buildArchiveEnabled: input_1.default.buildArchiveEnabled,
|
||||
buildArchivePath: input_1.default.buildArchivePath,
|
||||
buildArchiveRetention: input_1.default.buildArchiveRetention,
|
||||
testSuitePath: input_1.default.testSuitePath,
|
||||
testSuiteEvent: input_1.default.testSuiteEvent,
|
||||
testTaxonomyPath: input_1.default.testTaxonomyPath,
|
||||
testResultFormat: input_1.default.testResultFormat,
|
||||
testResultPath: input_1.default.testResultPath,
|
||||
hotRunnerEnabled: input_1.default.hotRunnerEnabled,
|
||||
hotRunnerTransport: input_1.default.hotRunnerTransport,
|
||||
hotRunnerHost: input_1.default.hotRunnerHost,
|
||||
hotRunnerPort: input_1.default.hotRunnerPort,
|
||||
hotRunnerHealthInterval: input_1.default.hotRunnerHealthInterval,
|
||||
hotRunnerMaxIdle: input_1.default.hotRunnerMaxIdle,
|
||||
hotRunnerFallbackToCold: input_1.default.hotRunnerFallbackToCold,
|
||||
artifactOutputTypes: input_1.default.artifactOutputTypes,
|
||||
artifactUploadTarget: input_1.default.artifactUploadTarget,
|
||||
artifactUploadPath: input_1.default.artifactUploadPath,
|
||||
artifactCompression: input_1.default.artifactCompression,
|
||||
artifactRetentionDays: input_1.default.artifactRetentionDays,
|
||||
artifactCustomTypes: input_1.default.artifactCustomTypes,
|
||||
syncStrategy: input_1.default.syncStrategy,
|
||||
syncInputRef: input_1.default.syncInputRef,
|
||||
syncStorageRemote: input_1.default.syncStorageRemote,
|
||||
syncRevertAfter: input_1.default.syncRevertAfter,
|
||||
syncStatePath: input_1.default.syncStatePath,
|
||||
};
|
||||
}
|
||||
static parseBuildFile(filename, platform, androidExportType) {
|
||||
@@ -638,7 +1054,7 @@ class Docker {
|
||||
return await (0, exec_1.exec)(runCommand, undefined, options);
|
||||
}
|
||||
static getLinuxCommand(image, parameters, overrideCommands = '', additionalVariables = [], entrypointBash = false) {
|
||||
const { workspace, actionFolder, useHostNetwork, runnerTempPath, sshAgent, sshPublicKeysDirectoryPath, gitPrivateToken, dockerWorkspacePath, dockerCpuLimit, dockerMemoryLimit, } = parameters;
|
||||
const { workspace, actionFolder, runnerTempPath, sshAgent, sshPublicKeysDirectoryPath, gitPrivateToken, dockerWorkspacePath, dockerCpuLimit, dockerMemoryLimit, } = parameters;
|
||||
const githubHome = node_path_1.default.join(runnerTempPath, '_github_home');
|
||||
if (!(0, node_fs_1.existsSync)(githubHome))
|
||||
(0, node_fs_1.mkdirSync)(githubHome);
|
||||
@@ -671,7 +1087,6 @@ class Docker {
|
||||
? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro'
|
||||
: ''} \
|
||||
${sshPublicKeysDirectoryPath ? `--volume ${sshPublicKeysDirectoryPath}:/root/.ssh:ro` : ''} \
|
||||
${useHostNetwork ? '--net=host' : ''} \
|
||||
${entrypointBash ? `--entrypoint ${commandPrefix}` : ``} \
|
||||
${image} \
|
||||
${entrypointBash ? `-c` : `${commandPrefix} -c`} \
|
||||
@@ -1282,8 +1697,7 @@ const core = __importStar(__nccwpck_require__(42186));
|
||||
*
|
||||
* Note that input is always passed as a string, even booleans.
|
||||
*
|
||||
* Only core build inputs belong here. Orchestrator/plugin inputs are read
|
||||
* directly by the @game-ci/orchestrator plugin via core.getInput() / env vars.
|
||||
* Todo: rename to UserInput and remove anything that is not direct input from the user / ci workflow
|
||||
*/
|
||||
class Input {
|
||||
static getInput(query) {
|
||||
@@ -1305,6 +1719,9 @@ class Input {
|
||||
return process.env[alternativeQuery];
|
||||
}
|
||||
}
|
||||
static get region() {
|
||||
return Input.getInput('region') ?? 'eu-west-2';
|
||||
}
|
||||
static get githubRepo() {
|
||||
return Input.getInput('GITHUB_REPOSITORY') ?? Input.getInput('GITHUB_REPO') ?? undefined;
|
||||
}
|
||||
@@ -1384,10 +1801,6 @@ class Input {
|
||||
static get customParameters() {
|
||||
return Input.getInput('customParameters') ?? '';
|
||||
}
|
||||
static get useHostNetwork() {
|
||||
const input = Input.getInput('useHostNetwork') ?? false;
|
||||
return input === 'true';
|
||||
}
|
||||
static get versioningStrategy() {
|
||||
return Input.getInput('versioning') ?? 'Semantic';
|
||||
}
|
||||
@@ -1457,6 +1870,22 @@ class Input {
|
||||
static get dockerWorkspacePath() {
|
||||
return Input.getInput('dockerWorkspacePath') ?? '/github/workspace';
|
||||
}
|
||||
static get syncStrategy() {
|
||||
return Input.getInput('syncStrategy') ?? 'full';
|
||||
}
|
||||
static get syncInputRef() {
|
||||
return Input.getInput('syncInputRef') ?? '';
|
||||
}
|
||||
static get syncStorageRemote() {
|
||||
return Input.getInput('syncStorageRemote') ?? '';
|
||||
}
|
||||
static get syncRevertAfter() {
|
||||
const input = Input.getInput('syncRevertAfter') ?? 'true';
|
||||
return input === 'true';
|
||||
}
|
||||
static get syncStatePath() {
|
||||
return Input.getInput('syncStatePath') ?? '.game-ci/sync-state.json';
|
||||
}
|
||||
static get dockerCpuLimit() {
|
||||
return Input.getInput('dockerCpuLimit') ?? node_os_1.default.cpus().length.toString();
|
||||
}
|
||||
@@ -1485,9 +1914,266 @@ class Input {
|
||||
static get containerRegistryImageVersion() {
|
||||
return Input.getInput('containerRegistryImageVersion') ?? '3';
|
||||
}
|
||||
static get artifactOutputTypes() {
|
||||
return Input.getInput('artifactOutputTypes') ?? 'build,logs,test-results';
|
||||
}
|
||||
static get artifactUploadTarget() {
|
||||
return Input.getInput('artifactUploadTarget') ?? 'github-artifacts';
|
||||
}
|
||||
static get artifactUploadPath() {
|
||||
return Input.getInput('artifactUploadPath') ?? '';
|
||||
}
|
||||
static get artifactCompression() {
|
||||
return Input.getInput('artifactCompression') ?? 'gzip';
|
||||
}
|
||||
static get artifactRetentionDays() {
|
||||
return Input.getInput('artifactRetentionDays') ?? '30';
|
||||
}
|
||||
static get artifactCustomTypes() {
|
||||
return Input.getInput('artifactCustomTypes') ?? '';
|
||||
}
|
||||
static get skipActivation() {
|
||||
return Input.getInput('skipActivation')?.toLowerCase() ?? 'false';
|
||||
}
|
||||
static get submoduleProfilePath() {
|
||||
return Input.getInput('submoduleProfilePath') ?? '';
|
||||
}
|
||||
static get submoduleVariantPath() {
|
||||
return Input.getInput('submoduleVariantPath') ?? '';
|
||||
}
|
||||
static get submoduleToken() {
|
||||
return Input.getInput('submoduleToken') ?? '';
|
||||
}
|
||||
static get localCacheEnabled() {
|
||||
return (Input.getInput('localCacheEnabled') ?? 'false') === 'true';
|
||||
}
|
||||
static get localCacheRoot() {
|
||||
return Input.getInput('localCacheRoot') ?? '';
|
||||
}
|
||||
static get localCacheLibrary() {
|
||||
return (Input.getInput('localCacheLibrary') ?? 'true') === 'true';
|
||||
}
|
||||
static get localCacheLfs() {
|
||||
return (Input.getInput('localCacheLfs') ?? 'false') === 'true';
|
||||
}
|
||||
static get childWorkspacesEnabled() {
|
||||
return (Input.getInput('childWorkspacesEnabled') ?? 'false') === 'true';
|
||||
}
|
||||
static get childWorkspaceName() {
|
||||
return Input.getInput('childWorkspaceName') ?? '';
|
||||
}
|
||||
static get childWorkspaceCacheRoot() {
|
||||
return Input.getInput('childWorkspaceCacheRoot') ?? '';
|
||||
}
|
||||
static get childWorkspacePreserveGit() {
|
||||
return (Input.getInput('childWorkspacePreserveGit') ?? 'true') === 'true';
|
||||
}
|
||||
static get childWorkspaceSeparateLibrary() {
|
||||
return (Input.getInput('childWorkspaceSeparateLibrary') ?? 'true') === 'true';
|
||||
}
|
||||
static get lfsTransferAgent() {
|
||||
return Input.getInput('lfsTransferAgent') ?? '';
|
||||
}
|
||||
static get lfsTransferAgentArgs() {
|
||||
return Input.getInput('lfsTransferAgentArgs') ?? '';
|
||||
}
|
||||
static get lfsStoragePaths() {
|
||||
return Input.getInput('lfsStoragePaths') ?? '';
|
||||
}
|
||||
static get gitHooksEnabled() {
|
||||
return (Input.getInput('gitHooksEnabled') ?? 'false') === 'true';
|
||||
}
|
||||
static get gitHooksSkipList() {
|
||||
return Input.getInput('gitHooksSkipList') ?? '';
|
||||
}
|
||||
static get gitHooksRunBeforeBuild() {
|
||||
return Input.getInput('gitHooksRunBeforeBuild') ?? '';
|
||||
}
|
||||
static get providerExecutable() {
|
||||
return Input.getInput('providerExecutable') ?? '';
|
||||
}
|
||||
// GCP Cloud Run (Experimental)
|
||||
static get gcpProject() {
|
||||
return Input.getInput('gcpProject') ?? '';
|
||||
}
|
||||
static get gcpRegion() {
|
||||
return Input.getInput('gcpRegion') ?? '';
|
||||
}
|
||||
static get gcpStorageType() {
|
||||
return Input.getInput('gcpStorageType') ?? 'gcs-fuse';
|
||||
}
|
||||
static get gcpBucket() {
|
||||
return Input.getInput('gcpBucket') ?? '';
|
||||
}
|
||||
static get gcpFilestoreIp() {
|
||||
return Input.getInput('gcpFilestoreIp') ?? '';
|
||||
}
|
||||
static get gcpFilestoreShare() {
|
||||
return Input.getInput('gcpFilestoreShare') ?? '/share1';
|
||||
}
|
||||
static get gcpMachineType() {
|
||||
return Input.getInput('gcpMachineType') ?? 'e2-standard-4';
|
||||
}
|
||||
static get gcpDiskSizeGb() {
|
||||
return Input.getInput('gcpDiskSizeGb') ?? '100';
|
||||
}
|
||||
static get gcpServiceAccount() {
|
||||
return Input.getInput('gcpServiceAccount') ?? '';
|
||||
}
|
||||
static get gcpVpcConnector() {
|
||||
return Input.getInput('gcpVpcConnector') ?? '';
|
||||
}
|
||||
// Azure Container Instances (Experimental)
|
||||
static get azureResourceGroup() {
|
||||
return Input.getInput('azureResourceGroup') ?? '';
|
||||
}
|
||||
static get azureLocation() {
|
||||
return Input.getInput('azureLocation') ?? '';
|
||||
}
|
||||
static get azureStorageType() {
|
||||
return Input.getInput('azureStorageType') ?? 'azure-files';
|
||||
}
|
||||
static get azureStorageAccount() {
|
||||
return Input.getInput('azureStorageAccount') ?? '';
|
||||
}
|
||||
static get azureBlobContainer() {
|
||||
return Input.getInput('azureBlobContainer') ?? 'unity-builds';
|
||||
}
|
||||
static get azureFileShareName() {
|
||||
return Input.getInput('azureFileShareName') ?? 'unity-builds';
|
||||
}
|
||||
static get azureSubscriptionId() {
|
||||
return Input.getInput('azureSubscriptionId') ?? '';
|
||||
}
|
||||
static get azureCpu() {
|
||||
return Input.getInput('azureCpu') ?? '4';
|
||||
}
|
||||
static get azureMemoryGb() {
|
||||
return Input.getInput('azureMemoryGb') ?? '16';
|
||||
}
|
||||
static get azureDiskSizeGb() {
|
||||
return Input.getInput('azureDiskSizeGb') ?? '100';
|
||||
}
|
||||
static get azureSubnetId() {
|
||||
return Input.getInput('azureSubnetId') ?? '';
|
||||
}
|
||||
// ### ### ###
|
||||
// Remote PowerShell provider
|
||||
// ### ### ###
|
||||
static get remotePowershellHost() {
|
||||
return Input.getInput('remotePowershellHost') ?? '';
|
||||
}
|
||||
static get remotePowershellCredential() {
|
||||
return Input.getInput('remotePowershellCredential') ?? '';
|
||||
}
|
||||
static get remotePowershellTransport() {
|
||||
return Input.getInput('remotePowershellTransport') ?? 'wsman';
|
||||
}
|
||||
// ### ### ###
|
||||
// GitHub Actions provider
|
||||
// ### ### ###
|
||||
static get githubActionsRepo() {
|
||||
return Input.getInput('githubActionsRepo') ?? '';
|
||||
}
|
||||
static get githubActionsWorkflow() {
|
||||
return Input.getInput('githubActionsWorkflow') ?? '';
|
||||
}
|
||||
static get githubActionsToken() {
|
||||
return Input.getInput('githubActionsToken') ?? '';
|
||||
}
|
||||
static get githubActionsRef() {
|
||||
return Input.getInput('githubActionsRef') ?? 'main';
|
||||
}
|
||||
// ### ### ###
|
||||
// GitLab CI provider
|
||||
// ### ### ###
|
||||
static get gitlabProjectId() {
|
||||
return Input.getInput('gitlabProjectId') ?? '';
|
||||
}
|
||||
static get gitlabTriggerToken() {
|
||||
return Input.getInput('gitlabTriggerToken') ?? '';
|
||||
}
|
||||
static get gitlabApiUrl() {
|
||||
return Input.getInput('gitlabApiUrl') ?? 'https://gitlab.com';
|
||||
}
|
||||
static get gitlabRef() {
|
||||
return Input.getInput('gitlabRef') ?? 'main';
|
||||
}
|
||||
// ### ### ###
|
||||
// Ansible provider
|
||||
// ### ### ###
|
||||
static get ansibleInventory() {
|
||||
return Input.getInput('ansibleInventory') ?? '';
|
||||
}
|
||||
static get ansiblePlaybook() {
|
||||
return Input.getInput('ansiblePlaybook') ?? '';
|
||||
}
|
||||
static get ansibleExtraVars() {
|
||||
return Input.getInput('ansibleExtraVars') ?? '';
|
||||
}
|
||||
static get ansibleVaultPassword() {
|
||||
return Input.getInput('ansibleVaultPassword') ?? '';
|
||||
}
|
||||
static get gitIntegrityCheck() {
|
||||
const input = Input.getInput('gitIntegrityCheck') ?? 'false';
|
||||
return input === 'true';
|
||||
}
|
||||
static get hotRunnerEnabled() {
|
||||
const input = Input.getInput('hotRunnerEnabled') ?? false;
|
||||
return input === 'true';
|
||||
}
|
||||
static get gitAutoRecover() {
|
||||
const input = Input.getInput('gitAutoRecover') ?? 'false';
|
||||
return input === 'true';
|
||||
}
|
||||
static get hotRunnerTransport() {
|
||||
return (Input.getInput('hotRunnerTransport') ?? 'websocket');
|
||||
}
|
||||
static get hotRunnerHost() {
|
||||
return Input.getInput('hotRunnerHost') ?? 'localhost';
|
||||
}
|
||||
static get hotRunnerPort() {
|
||||
return Number.parseInt(Input.getInput('hotRunnerPort') ?? '9090', 10);
|
||||
}
|
||||
static get hotRunnerHealthInterval() {
|
||||
return Number.parseInt(Input.getInput('hotRunnerHealthInterval') ?? '30', 10);
|
||||
}
|
||||
static get hotRunnerMaxIdle() {
|
||||
return Number.parseInt(Input.getInput('hotRunnerMaxIdle') ?? '3600', 10);
|
||||
}
|
||||
static get hotRunnerFallbackToCold() {
|
||||
const input = Input.getInput('hotRunnerFallbackToCold') ?? 'true';
|
||||
return input === 'true';
|
||||
}
|
||||
static get cleanReservedFilenames() {
|
||||
const input = Input.getInput('cleanReservedFilenames') ?? 'false';
|
||||
return input === 'true';
|
||||
}
|
||||
static get buildArchiveEnabled() {
|
||||
const input = Input.getInput('buildArchiveEnabled') ?? 'false';
|
||||
return input === 'true';
|
||||
}
|
||||
static get buildArchivePath() {
|
||||
return Input.getInput('buildArchivePath') ?? './build-archives';
|
||||
}
|
||||
static get buildArchiveRetention() {
|
||||
return Number.parseInt(Input.getInput('buildArchiveRetention') ?? '30', 10);
|
||||
}
|
||||
static get testSuitePath() {
|
||||
return Input.getInput('testSuitePath') ?? '';
|
||||
}
|
||||
static get testSuiteEvent() {
|
||||
return Input.getInput('testSuiteEvent') ?? '';
|
||||
}
|
||||
static get testTaxonomyPath() {
|
||||
return Input.getInput('testTaxonomyPath') ?? '';
|
||||
}
|
||||
static get testResultFormat() {
|
||||
return Input.getInput('testResultFormat') ?? 'junit';
|
||||
}
|
||||
static get testResultPath() {
|
||||
return Input.getInput('testResultPath') ?? './test-results';
|
||||
}
|
||||
static ToEnvVarFormat(input) {
|
||||
if (input.toUpperCase() === input) {
|
||||
return input;
|
||||
@@ -1553,22 +2239,25 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.loadOrchestratorPlugin = void 0;
|
||||
exports.loadPluginServices = exports.loadOrchestrator = void 0;
|
||||
const core = __importStar(__nccwpck_require__(42186));
|
||||
/**
|
||||
* Attempt to load the orchestrator plugin.
|
||||
* Returns undefined if @game-ci/orchestrator is not installed.
|
||||
* Load the orchestrator for remote builds.
|
||||
* Returns undefined if orchestrator is not available.
|
||||
*/
|
||||
async function loadOrchestratorPlugin() {
|
||||
async function loadOrchestrator() {
|
||||
try {
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
const orchestratorModule = await Promise.resolve().then(() => __importStar(__nccwpck_require__(70776)));
|
||||
if (typeof orchestratorModule.createPlugin !== 'function') {
|
||||
core.warning('Orchestrator package found but does not export createPlugin(). ' +
|
||||
'Update @game-ci/orchestrator to the latest version.');
|
||||
return;
|
||||
}
|
||||
return orchestratorModule.createPlugin();
|
||||
const { Orchestrator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(70776)));
|
||||
return {
|
||||
run: async (buildParameters, baseImage) => {
|
||||
const result = await Orchestrator.run(buildParameters, baseImage);
|
||||
return {
|
||||
exitCode: result.BuildSucceeded ? 0 : 1,
|
||||
BuildSucceeded: result.BuildSucceeded,
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
catch (error) {
|
||||
if (!isModuleNotFoundError(error)) {
|
||||
@@ -1576,7 +2265,50 @@ async function loadOrchestratorPlugin() {
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.loadOrchestratorPlugin = loadOrchestratorPlugin;
|
||||
exports.loadOrchestrator = loadOrchestrator;
|
||||
/**
|
||||
* Load orchestrator plugin services for local builds.
|
||||
* These services are part of the orchestrator but also used in local builds
|
||||
* (child workspaces, local cache, git hooks, LFS agents, etc.).
|
||||
*/
|
||||
async function loadPluginServices() {
|
||||
try {
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
const orchestrator = await Promise.resolve().then(() => __importStar(__nccwpck_require__(70776)));
|
||||
return {
|
||||
BuildReliabilityService: orchestrator.BuildReliabilityService,
|
||||
TestWorkflowService: orchestrator.TestWorkflowService,
|
||||
HotRunnerService: orchestrator.HotRunnerService,
|
||||
OutputService: orchestrator.OutputService,
|
||||
OutputTypeRegistry: orchestrator.OutputTypeRegistry,
|
||||
ArtifactUploadHandler: orchestrator.ArtifactUploadHandler,
|
||||
IncrementalSyncService: orchestrator.IncrementalSyncService,
|
||||
// Lazy-loaded services (only imported when needed)
|
||||
async loadChildWorkspaceService() {
|
||||
return orchestrator.ChildWorkspaceService;
|
||||
},
|
||||
async loadLocalCacheService() {
|
||||
return orchestrator.LocalCacheService;
|
||||
},
|
||||
async loadSubmoduleProfileService() {
|
||||
return orchestrator.SubmoduleProfileService;
|
||||
},
|
||||
async loadLfsAgentService() {
|
||||
return orchestrator.LfsAgentService;
|
||||
},
|
||||
async loadGitHooksService() {
|
||||
return orchestrator.GitHooksService;
|
||||
},
|
||||
};
|
||||
}
|
||||
catch (error) {
|
||||
if (!isModuleNotFoundError(error)) {
|
||||
throw error;
|
||||
}
|
||||
core.warning(`Orchestrator plugin not available: ${error.message}`);
|
||||
}
|
||||
}
|
||||
exports.loadPluginServices = loadPluginServices;
|
||||
function isModuleNotFoundError(error) {
|
||||
if (error && typeof error === 'object' && 'code' in error) {
|
||||
const code = error.code;
|
||||
|
||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -1,35 +1,121 @@
|
||||
/**
|
||||
* Integration wiring tests for the plugin lifecycle in index.ts
|
||||
* Integration wiring tests for plugin features in index.ts
|
||||
*
|
||||
* These tests verify that:
|
||||
* - The plugin lifecycle hooks are called in the correct order
|
||||
* - Plugin canHandleBuild() controls the execution path
|
||||
* - fallbackToLocal is handled correctly
|
||||
* - When no plugin is installed, local builds still work
|
||||
* - When providerStrategy is non-local without a plugin, an error is thrown
|
||||
* These tests verify the conditional gating logic in runMain():
|
||||
* - Each plugin feature is only invoked when its gate condition is met
|
||||
* - Services are NOT called when their feature is disabled (the default)
|
||||
* - The order of operations is correct (restore before build, save after build)
|
||||
*/
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
import { BuildParameters } from './model';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Mock plugin
|
||||
// Service mocks — must be declared before importing index.ts (jest hoists them)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const mockPlugin = {
|
||||
initialize: jest.fn().mockResolvedValue(undefined),
|
||||
canHandleBuild: jest.fn().mockReturnValue(false),
|
||||
handleBuild: jest.fn().mockResolvedValue({ exitCode: 0 }),
|
||||
beforeLocalBuild: jest.fn().mockResolvedValue(undefined),
|
||||
afterLocalBuild: jest.fn().mockResolvedValue(undefined),
|
||||
handlePostBuild: jest.fn().mockResolvedValue(undefined),
|
||||
const mockChildWorkspaceService = {
|
||||
buildConfig: jest.fn().mockReturnValue({ enabled: true, workspaceName: 'Test' }),
|
||||
initializeWorkspace: jest.fn().mockReturnValue(false),
|
||||
getWorkspaceSize: jest.fn().mockReturnValue('0 B'),
|
||||
saveWorkspace: jest.fn(),
|
||||
};
|
||||
|
||||
const mockLoadOrchestratorPlugin = jest.fn().mockResolvedValue(mockPlugin);
|
||||
const mockSubmoduleProfileService = {
|
||||
createInitPlan: jest.fn().mockResolvedValue([]),
|
||||
execute: jest.fn().mockResolvedValue(''),
|
||||
};
|
||||
|
||||
const mockLfsAgentService = {
|
||||
configure: jest.fn().mockResolvedValue(''),
|
||||
};
|
||||
|
||||
const mockLocalCacheService = {
|
||||
resolveCacheRoot: jest.fn().mockReturnValue('/cache'),
|
||||
generateCacheKey: jest.fn().mockReturnValue('key-1'),
|
||||
restoreLfsCache: jest.fn().mockResolvedValue(true),
|
||||
restoreLibraryCache: jest.fn().mockResolvedValue(true),
|
||||
saveLibraryCache: jest.fn().mockResolvedValue(''),
|
||||
saveLfsCache: jest.fn().mockResolvedValue(''),
|
||||
};
|
||||
|
||||
const mockGitHooksService = {
|
||||
installHooks: jest.fn().mockResolvedValue(''),
|
||||
configureSkipList: jest.fn().mockReturnValue({ LEFTHOOK_EXCLUDE: 'pre-commit' }),
|
||||
};
|
||||
|
||||
const mockBuildReliabilityService = {
|
||||
configureGitEnvironment: jest.fn(),
|
||||
checkGitIntegrity: jest.fn().mockReturnValue(true),
|
||||
cleanStaleLockFiles: jest.fn(),
|
||||
validateSubmoduleBackingStores: jest.fn(),
|
||||
cleanReservedFilenames: jest.fn(),
|
||||
recoverCorruptedRepo: jest.fn().mockReturnValue(true),
|
||||
archiveBuildOutput: jest.fn(),
|
||||
enforceRetention: jest.fn(),
|
||||
};
|
||||
|
||||
const mockTestWorkflowService = {
|
||||
executeTestSuite: jest.fn().mockResolvedValue([]),
|
||||
};
|
||||
|
||||
const mockHotRunnerService = jest.fn();
|
||||
|
||||
const mockIncrementalSyncService = {
|
||||
resolveStrategy: jest.fn().mockReturnValue('full'),
|
||||
syncGitDelta: jest.fn().mockResolvedValue(0),
|
||||
applyDirectInput: jest.fn().mockResolvedValue([]),
|
||||
syncStoragePull: jest.fn().mockResolvedValue([]),
|
||||
revertOverlays: jest.fn().mockImplementation(() => Promise.resolve()),
|
||||
};
|
||||
|
||||
const mockOutputService = {
|
||||
collectOutputs: jest.fn().mockImplementation(() => Promise.resolve()),
|
||||
};
|
||||
|
||||
const mockOutputTypeRegistry = {
|
||||
registerType: jest.fn(),
|
||||
};
|
||||
|
||||
const mockArtifactUploadHandler = {
|
||||
parseConfig: jest.fn().mockImplementation(() => {
|
||||
/* no config */
|
||||
}),
|
||||
uploadArtifacts: jest.fn().mockResolvedValue({ success: true, entries: [] }),
|
||||
};
|
||||
|
||||
const mockOrchestrator = {
|
||||
run: jest.fn().mockImplementation(() => Promise.resolve()),
|
||||
};
|
||||
|
||||
// Mock the orchestrator-plugin module to directly return our mock services.
|
||||
// This avoids any issues with dynamic imports inside loadPluginServices().
|
||||
jest.mock('./model/orchestrator-plugin', () => ({
|
||||
loadOrchestratorPlugin: mockLoadOrchestratorPlugin,
|
||||
loadOrchestrator: jest.fn().mockResolvedValue({
|
||||
run: mockOrchestrator.run,
|
||||
}),
|
||||
loadPluginServices: jest.fn().mockResolvedValue({
|
||||
BuildReliabilityService: mockBuildReliabilityService,
|
||||
TestWorkflowService: mockTestWorkflowService,
|
||||
HotRunnerService: mockHotRunnerService,
|
||||
OutputService: mockOutputService,
|
||||
OutputTypeRegistry: mockOutputTypeRegistry,
|
||||
ArtifactUploadHandler: mockArtifactUploadHandler,
|
||||
IncrementalSyncService: mockIncrementalSyncService,
|
||||
|
||||
// Lazy-loaded services (matching the plugin loader API)
|
||||
loadChildWorkspaceService: jest.fn().mockResolvedValue(mockChildWorkspaceService),
|
||||
loadLocalCacheService: jest.fn().mockResolvedValue(mockLocalCacheService),
|
||||
loadSubmoduleProfileService: jest.fn().mockResolvedValue(mockSubmoduleProfileService),
|
||||
loadLfsAgentService: jest.fn().mockResolvedValue(mockLfsAgentService),
|
||||
loadGitHooksService: jest.fn().mockResolvedValue(mockGitHooksService),
|
||||
}),
|
||||
}));
|
||||
|
||||
// Mock all non-plugin dependencies to isolate the wiring logic
|
||||
jest.mock('@actions/core');
|
||||
jest.mock('./model', () => ({
|
||||
Action: {
|
||||
@@ -78,8 +164,32 @@ jest.mock('./model/platform-setup', () => ({
|
||||
|
||||
const mockedBuildParametersCreate = BuildParameters.create as jest.Mock;
|
||||
|
||||
function createMockBuildParameters(overrides: Record<string, any> = {}) {
|
||||
interface PluginBuildParametersOverrides {
|
||||
providerStrategy?: string;
|
||||
childWorkspacesEnabled?: boolean;
|
||||
childWorkspaceName?: string;
|
||||
childWorkspaceCacheRoot?: string;
|
||||
childWorkspacePreserveGit?: boolean;
|
||||
childWorkspaceSeparateLibrary?: boolean;
|
||||
submoduleProfilePath?: string;
|
||||
submoduleVariantPath?: string;
|
||||
submoduleToken?: string;
|
||||
gitPrivateToken?: string;
|
||||
lfsTransferAgent?: string;
|
||||
lfsTransferAgentArgs?: string;
|
||||
lfsStoragePaths?: string;
|
||||
localCacheEnabled?: boolean;
|
||||
localCacheRoot?: string;
|
||||
localCacheLibrary?: boolean;
|
||||
localCacheLfs?: boolean;
|
||||
gitHooksEnabled?: boolean;
|
||||
gitHooksSkipList?: string;
|
||||
gitHooksRunBeforeBuild?: string;
|
||||
}
|
||||
|
||||
function createMockBuildParameters(overrides: PluginBuildParametersOverrides = {}) {
|
||||
return {
|
||||
// Required base properties
|
||||
providerStrategy: 'local',
|
||||
targetPlatform: 'StandaloneLinux64',
|
||||
editorVersion: '2021.3.1f1',
|
||||
@@ -88,17 +198,49 @@ function createMockBuildParameters(overrides: Record<string, any> = {}) {
|
||||
projectPath: '.',
|
||||
branch: 'main',
|
||||
runnerTempPath: '/tmp',
|
||||
|
||||
// Plugin features - all disabled by default
|
||||
childWorkspacesEnabled: false,
|
||||
childWorkspaceName: '',
|
||||
childWorkspaceCacheRoot: '',
|
||||
childWorkspacePreserveGit: true,
|
||||
childWorkspaceSeparateLibrary: true,
|
||||
submoduleProfilePath: '',
|
||||
submoduleVariantPath: '',
|
||||
submoduleToken: '',
|
||||
gitPrivateToken: '',
|
||||
lfsTransferAgent: '',
|
||||
lfsTransferAgentArgs: '',
|
||||
lfsStoragePaths: '',
|
||||
localCacheEnabled: false,
|
||||
localCacheRoot: '',
|
||||
localCacheLibrary: true,
|
||||
localCacheLfs: false,
|
||||
gitHooksEnabled: false,
|
||||
gitHooksSkipList: '',
|
||||
gitHooksRunBeforeBuild: '',
|
||||
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
async function runIndex(overrides: Record<string, any> = {}): Promise<void> {
|
||||
/**
|
||||
* The entry point (runMain) is invoked by importing index.ts.
|
||||
* Since it calls `runMain()` at module scope, we need to re-import it
|
||||
* for each test. jest.isolateModules() handles this.
|
||||
*/
|
||||
async function runIndex(overrides: PluginBuildParametersOverrides = {}): Promise<void> {
|
||||
mockedBuildParametersCreate.mockResolvedValue(createMockBuildParameters(overrides));
|
||||
|
||||
return new Promise<void>((resolve) => {
|
||||
jest.isolateModules(() => {
|
||||
require('./index');
|
||||
|
||||
// runMain() is async; give it a tick to complete
|
||||
// We use setImmediate to ensure all microtasks from the dynamic imports resolve
|
||||
});
|
||||
|
||||
// Allow all promises and microtasks to settle
|
||||
setTimeout(resolve, 100);
|
||||
});
|
||||
}
|
||||
@@ -107,19 +249,16 @@ async function runIndex(overrides: Record<string, any> = {}): Promise<void> {
|
||||
// Tests
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
describe('index.ts plugin lifecycle wiring', () => {
|
||||
describe('index.ts plugin feature wiring', () => {
|
||||
const originalPlatform = process.platform;
|
||||
const originalEnvironment = { ...process.env };
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
process.env.GITHUB_WORKSPACE = '/workspace';
|
||||
Object.defineProperty(process, 'platform', { value: 'linux' });
|
||||
|
||||
// Reset plugin to default behavior
|
||||
mockPlugin.canHandleBuild.mockReturnValue(false);
|
||||
mockPlugin.handleBuild.mockResolvedValue({ exitCode: 0 });
|
||||
mockLoadOrchestratorPlugin.mockResolvedValue(mockPlugin);
|
||||
// Force linux platform so Docker.run is used (not MacBuilder)
|
||||
Object.defineProperty(process, 'platform', { value: 'linux' });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -128,135 +267,382 @@ describe('index.ts plugin lifecycle wiring', () => {
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Local build with plugin
|
||||
// GitHooksService gating
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
describe('local build with plugin installed', () => {
|
||||
it('should call lifecycle hooks in order: initialize → beforeLocalBuild → [build] → afterLocalBuild → handlePostBuild', async () => {
|
||||
const callOrder: string[] = [];
|
||||
mockPlugin.initialize.mockImplementation(async () => callOrder.push('initialize'));
|
||||
mockPlugin.beforeLocalBuild.mockImplementation(async () => callOrder.push('beforeLocalBuild'));
|
||||
mockPlugin.afterLocalBuild.mockImplementation(async () => callOrder.push('afterLocalBuild'));
|
||||
mockPlugin.handlePostBuild.mockImplementation(async () => callOrder.push('handlePostBuild'));
|
||||
describe('GitHooksService gating', () => {
|
||||
it('should NOT call GitHooksService when gitHooksEnabled is false (default)', async () => {
|
||||
await runIndex({ gitHooksEnabled: false });
|
||||
|
||||
await runIndex();
|
||||
|
||||
expect(callOrder).toEqual(['initialize', 'beforeLocalBuild', 'afterLocalBuild', 'handlePostBuild']);
|
||||
expect(mockGitHooksService.installHooks).not.toHaveBeenCalled();
|
||||
expect(mockGitHooksService.configureSkipList).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should pass buildParameters and workspace to initialize', async () => {
|
||||
await runIndex({ targetPlatform: 'WebGL' });
|
||||
it('should call installHooks when gitHooksEnabled is true', async () => {
|
||||
await runIndex({ gitHooksEnabled: true });
|
||||
|
||||
expect(mockPlugin.initialize).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ targetPlatform: 'WebGL' }),
|
||||
expect(mockGitHooksService.installHooks).toHaveBeenCalledWith('/workspace');
|
||||
});
|
||||
|
||||
it('should call configureSkipList when gitHooksEnabled and gitHooksSkipList is set', async () => {
|
||||
await runIndex({
|
||||
gitHooksEnabled: true,
|
||||
gitHooksSkipList: 'pre-commit,pre-push',
|
||||
});
|
||||
|
||||
expect(mockGitHooksService.configureSkipList).toHaveBeenCalledWith(['pre-commit', 'pre-push']);
|
||||
});
|
||||
|
||||
it('should NOT call configureSkipList when gitHooksSkipList is empty', async () => {
|
||||
await runIndex({
|
||||
gitHooksEnabled: true,
|
||||
gitHooksSkipList: '',
|
||||
});
|
||||
|
||||
expect(mockGitHooksService.installHooks).toHaveBeenCalled();
|
||||
expect(mockGitHooksService.configureSkipList).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// LocalCacheService gating
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
describe('LocalCacheService gating', () => {
|
||||
it('should NOT call LocalCacheService when localCacheEnabled is false (default)', async () => {
|
||||
await runIndex({ localCacheEnabled: false });
|
||||
|
||||
expect(mockLocalCacheService.resolveCacheRoot).not.toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.generateCacheKey).not.toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.restoreLibraryCache).not.toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.restoreLfsCache).not.toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.saveLibraryCache).not.toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.saveLfsCache).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call restore and save operations when localCacheEnabled is true', async () => {
|
||||
await runIndex({
|
||||
localCacheEnabled: true,
|
||||
localCacheLibrary: true,
|
||||
localCacheLfs: true,
|
||||
});
|
||||
|
||||
expect(mockLocalCacheService.resolveCacheRoot).toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.generateCacheKey).toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.restoreLibraryCache).toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.restoreLfsCache).toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.saveLibraryCache).toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.saveLfsCache).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should only cache Library when localCacheLibrary is true and localCacheLfs is false', async () => {
|
||||
await runIndex({
|
||||
localCacheEnabled: true,
|
||||
localCacheLibrary: true,
|
||||
localCacheLfs: false,
|
||||
});
|
||||
|
||||
expect(mockLocalCacheService.restoreLibraryCache).toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.restoreLfsCache).not.toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.saveLibraryCache).toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.saveLfsCache).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should only cache LFS when localCacheLfs is true and localCacheLibrary is false', async () => {
|
||||
await runIndex({
|
||||
localCacheEnabled: true,
|
||||
localCacheLibrary: false,
|
||||
localCacheLfs: true,
|
||||
});
|
||||
|
||||
expect(mockLocalCacheService.restoreLibraryCache).not.toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.restoreLfsCache).toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.saveLibraryCache).not.toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.saveLfsCache).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// ChildWorkspaceService gating
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
describe('ChildWorkspaceService gating', () => {
|
||||
it('should NOT call ChildWorkspaceService when childWorkspacesEnabled is false (default)', async () => {
|
||||
await runIndex({ childWorkspacesEnabled: false });
|
||||
|
||||
expect(mockChildWorkspaceService.buildConfig).not.toHaveBeenCalled();
|
||||
expect(mockChildWorkspaceService.initializeWorkspace).not.toHaveBeenCalled();
|
||||
expect(mockChildWorkspaceService.saveWorkspace).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should NOT call ChildWorkspaceService when childWorkspacesEnabled is true but childWorkspaceName is empty', async () => {
|
||||
await runIndex({
|
||||
childWorkspacesEnabled: true,
|
||||
childWorkspaceName: '',
|
||||
});
|
||||
|
||||
expect(mockChildWorkspaceService.buildConfig).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call buildConfig, initializeWorkspace, and saveWorkspace when enabled with a name', async () => {
|
||||
mockChildWorkspaceService.buildConfig.mockReturnValue({ enabled: true, workspaceName: 'TurnOfWar' });
|
||||
|
||||
await runIndex({
|
||||
childWorkspacesEnabled: true,
|
||||
childWorkspaceName: 'TurnOfWar',
|
||||
childWorkspaceCacheRoot: '/cache/workspaces',
|
||||
});
|
||||
|
||||
expect(mockChildWorkspaceService.buildConfig).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
childWorkspacesEnabled: true,
|
||||
childWorkspaceName: 'TurnOfWar',
|
||||
}),
|
||||
);
|
||||
expect(mockChildWorkspaceService.initializeWorkspace).toHaveBeenCalled();
|
||||
expect(mockChildWorkspaceService.getWorkspaceSize).toHaveBeenCalled();
|
||||
expect(mockChildWorkspaceService.saveWorkspace).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// SubmoduleProfileService gating
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
describe('SubmoduleProfileService gating', () => {
|
||||
it('should NOT call SubmoduleProfileService when submoduleProfilePath is empty (default)', async () => {
|
||||
await runIndex({ submoduleProfilePath: '' });
|
||||
|
||||
expect(mockSubmoduleProfileService.createInitPlan).not.toHaveBeenCalled();
|
||||
expect(mockSubmoduleProfileService.execute).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call createInitPlan and execute when submoduleProfilePath is set', async () => {
|
||||
await runIndex({
|
||||
submoduleProfilePath: '/path/to/profile.yml',
|
||||
submoduleVariantPath: '',
|
||||
submoduleToken: 'my-token',
|
||||
});
|
||||
|
||||
expect(mockSubmoduleProfileService.createInitPlan).toHaveBeenCalledWith('/path/to/profile.yml', '', '/workspace');
|
||||
expect(mockSubmoduleProfileService.execute).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should pass variant path when provided', async () => {
|
||||
await runIndex({
|
||||
submoduleProfilePath: '/path/to/profile.yml',
|
||||
submoduleVariantPath: '/path/to/variant.yml',
|
||||
});
|
||||
|
||||
expect(mockSubmoduleProfileService.createInitPlan).toHaveBeenCalledWith(
|
||||
'/path/to/profile.yml',
|
||||
'/path/to/variant.yml',
|
||||
'/workspace',
|
||||
);
|
||||
});
|
||||
|
||||
it('should pass workspace to beforeLocalBuild', async () => {
|
||||
await runIndex();
|
||||
it('should use submoduleToken for auth, falling back to gitPrivateToken', async () => {
|
||||
await runIndex({
|
||||
submoduleProfilePath: '/path/to/profile.yml',
|
||||
submoduleToken: '',
|
||||
gitPrivateToken: 'fallback-token',
|
||||
});
|
||||
|
||||
expect(mockPlugin.beforeLocalBuild).toHaveBeenCalledWith('/workspace');
|
||||
expect(mockSubmoduleProfileService.execute).toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
'/workspace',
|
||||
'fallback-token',
|
||||
);
|
||||
});
|
||||
|
||||
it('should pass workspace and exit code to afterLocalBuild', async () => {
|
||||
await runIndex();
|
||||
it('should prefer submoduleToken over gitPrivateToken', async () => {
|
||||
await runIndex({
|
||||
submoduleProfilePath: '/path/to/profile.yml',
|
||||
submoduleToken: 'specific-token',
|
||||
gitPrivateToken: 'fallback-token',
|
||||
});
|
||||
|
||||
expect(mockPlugin.afterLocalBuild).toHaveBeenCalledWith('/workspace', 0);
|
||||
});
|
||||
|
||||
it('should pass exit code to handlePostBuild', async () => {
|
||||
await runIndex();
|
||||
|
||||
expect(mockPlugin.handlePostBuild).toHaveBeenCalledWith(0);
|
||||
expect(mockSubmoduleProfileService.execute).toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
'/workspace',
|
||||
'specific-token',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Plugin handles build entirely
|
||||
// LfsAgentService gating
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
describe('plugin handles build (canHandleBuild = true)', () => {
|
||||
it('should call handleBuild instead of Docker.run', async () => {
|
||||
const { Docker } = require('./model');
|
||||
mockPlugin.canHandleBuild.mockReturnValue(true);
|
||||
mockPlugin.handleBuild.mockResolvedValue({ exitCode: 0 });
|
||||
describe('LfsAgentService gating', () => {
|
||||
it('should NOT call LfsAgentService when lfsTransferAgent is empty (default)', async () => {
|
||||
await runIndex({ lfsTransferAgent: '' });
|
||||
|
||||
await runIndex();
|
||||
|
||||
expect(mockPlugin.handleBuild).toHaveBeenCalledWith('mock-image:latest');
|
||||
expect(Docker.run).not.toHaveBeenCalled();
|
||||
expect(mockPlugin.beforeLocalBuild).not.toHaveBeenCalled();
|
||||
expect(mockPlugin.afterLocalBuild).not.toHaveBeenCalled();
|
||||
expect(mockLfsAgentService.configure).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should still call handlePostBuild after handleBuild', async () => {
|
||||
mockPlugin.canHandleBuild.mockReturnValue(true);
|
||||
mockPlugin.handleBuild.mockResolvedValue({ exitCode: 0 });
|
||||
it('should call configure when lfsTransferAgent is set', async () => {
|
||||
await runIndex({
|
||||
lfsTransferAgent: '/tools/elastic-git-storage',
|
||||
lfsTransferAgentArgs: '--verbose',
|
||||
lfsStoragePaths: '/path/a;/path/b',
|
||||
});
|
||||
|
||||
await runIndex();
|
||||
expect(mockLfsAgentService.configure).toHaveBeenCalledWith(
|
||||
'/tools/elastic-git-storage',
|
||||
'--verbose',
|
||||
['/path/a', '/path/b'],
|
||||
'/workspace',
|
||||
);
|
||||
});
|
||||
|
||||
expect(mockPlugin.handlePostBuild).toHaveBeenCalledWith(0);
|
||||
it('should pass empty array when lfsStoragePaths is empty', async () => {
|
||||
await runIndex({
|
||||
lfsTransferAgent: '/tools/agent',
|
||||
lfsStoragePaths: '',
|
||||
});
|
||||
|
||||
expect(mockLfsAgentService.configure).toHaveBeenCalledWith('/tools/agent', '', [], '/workspace');
|
||||
});
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Fallback to local
|
||||
// Order of operations (restore before build, save after build)
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
describe('fallback to local build', () => {
|
||||
it('should do a local build when handleBuild returns fallbackToLocal', async () => {
|
||||
const { Docker } = require('./model');
|
||||
mockPlugin.canHandleBuild.mockReturnValue(true);
|
||||
mockPlugin.handleBuild.mockResolvedValue({ exitCode: -1, fallbackToLocal: true });
|
||||
describe('order of operations', () => {
|
||||
it('should execute restore operations before build and save operations after build', async () => {
|
||||
const callOrder: string[] = [];
|
||||
|
||||
await runIndex();
|
||||
// Track call order for each relevant operation
|
||||
mockChildWorkspaceService.buildConfig.mockReturnValue({ enabled: true, workspaceName: 'Test' });
|
||||
mockChildWorkspaceService.initializeWorkspace.mockImplementation(() => {
|
||||
callOrder.push('child-workspace-restore');
|
||||
|
||||
expect(mockPlugin.handleBuild).toHaveBeenCalled();
|
||||
expect(mockPlugin.beforeLocalBuild).toHaveBeenCalled();
|
||||
expect(Docker.run).toHaveBeenCalled();
|
||||
expect(mockPlugin.afterLocalBuild).toHaveBeenCalled();
|
||||
return false;
|
||||
});
|
||||
mockChildWorkspaceService.getWorkspaceSize.mockImplementation(() => {
|
||||
callOrder.push('child-workspace-size');
|
||||
|
||||
return '0 B';
|
||||
});
|
||||
mockSubmoduleProfileService.createInitPlan.mockImplementation(async () => {
|
||||
callOrder.push('submodule-profile-plan');
|
||||
|
||||
return [];
|
||||
});
|
||||
mockSubmoduleProfileService.execute.mockImplementation(async () => {
|
||||
callOrder.push('submodule-profile-execute');
|
||||
});
|
||||
mockLfsAgentService.configure.mockImplementation(async () => {
|
||||
callOrder.push('lfs-agent-configure');
|
||||
});
|
||||
mockLocalCacheService.resolveCacheRoot.mockImplementation(() => {
|
||||
callOrder.push('local-cache-resolve');
|
||||
|
||||
return '/cache';
|
||||
});
|
||||
mockLocalCacheService.generateCacheKey.mockImplementation(() => {
|
||||
callOrder.push('local-cache-keygen');
|
||||
|
||||
return 'key-1';
|
||||
});
|
||||
mockLocalCacheService.restoreLfsCache.mockImplementation(async () => {
|
||||
callOrder.push('local-cache-restore-lfs');
|
||||
|
||||
return true;
|
||||
});
|
||||
mockLocalCacheService.restoreLibraryCache.mockImplementation(async () => {
|
||||
callOrder.push('local-cache-restore-library');
|
||||
|
||||
return true;
|
||||
});
|
||||
mockGitHooksService.installHooks.mockImplementation(async () => {
|
||||
callOrder.push('git-hooks-install');
|
||||
});
|
||||
mockLocalCacheService.saveLibraryCache.mockImplementation(async () => {
|
||||
callOrder.push('local-cache-save-library');
|
||||
});
|
||||
mockLocalCacheService.saveLfsCache.mockImplementation(async () => {
|
||||
callOrder.push('local-cache-save-lfs');
|
||||
});
|
||||
mockChildWorkspaceService.saveWorkspace.mockImplementation(() => {
|
||||
callOrder.push('child-workspace-save');
|
||||
});
|
||||
|
||||
await runIndex({
|
||||
childWorkspacesEnabled: true,
|
||||
childWorkspaceName: 'TurnOfWar',
|
||||
submoduleProfilePath: '/profile.yml',
|
||||
lfsTransferAgent: '/tools/agent',
|
||||
localCacheEnabled: true,
|
||||
localCacheLfs: true,
|
||||
localCacheLibrary: true,
|
||||
gitHooksEnabled: true,
|
||||
});
|
||||
|
||||
// Verify restore operations happen before save operations.
|
||||
// The expected order from index.ts is:
|
||||
// 1. Child workspace restore
|
||||
// 2. Submodule profile init
|
||||
// 3. LFS agent configure
|
||||
// 4. Local cache restore (LFS then Library)
|
||||
// 5. Git hooks install
|
||||
// 6. [BUILD happens here - Docker.run or MacBuilder.run]
|
||||
// 7. Local cache save (Library then LFS)
|
||||
// 8. Child workspace save
|
||||
|
||||
const restoreOps = [
|
||||
'child-workspace-restore',
|
||||
'submodule-profile-plan',
|
||||
'submodule-profile-execute',
|
||||
'lfs-agent-configure',
|
||||
'local-cache-restore-lfs',
|
||||
'local-cache-restore-library',
|
||||
'git-hooks-install',
|
||||
];
|
||||
|
||||
const saveOps = ['local-cache-save-library', 'local-cache-save-lfs', 'child-workspace-save'];
|
||||
|
||||
// All restore ops should appear before all save ops
|
||||
for (const restoreOp of restoreOps) {
|
||||
if (!callOrder.includes(restoreOp)) continue; // Skip if the operation wasn't called
|
||||
for (const saveOp of saveOps) {
|
||||
if (!callOrder.includes(saveOp)) continue;
|
||||
expect(callOrder.indexOf(restoreOp)).toBeLessThan(callOrder.indexOf(saveOp));
|
||||
}
|
||||
}
|
||||
|
||||
// Child workspace save should be last
|
||||
if (callOrder.includes('child-workspace-save') && callOrder.includes('local-cache-save-lfs')) {
|
||||
expect(callOrder.indexOf('local-cache-save-lfs')).toBeLessThan(callOrder.indexOf('child-workspace-save'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// No plugin installed
|
||||
// Non-local provider strategy
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
describe('no plugin installed', () => {
|
||||
it('should build locally without errors when providerStrategy is local', async () => {
|
||||
const { Docker } = require('./model');
|
||||
mockLoadOrchestratorPlugin.mockResolvedValue(undefined);
|
||||
describe('non-local provider strategy', () => {
|
||||
it('should skip all plugin features when providerStrategy is not local', async () => {
|
||||
await runIndex({
|
||||
providerStrategy: 'aws',
|
||||
childWorkspacesEnabled: true,
|
||||
childWorkspaceName: 'Test',
|
||||
submoduleProfilePath: '/profile.yml',
|
||||
lfsTransferAgent: '/tools/agent',
|
||||
localCacheEnabled: true,
|
||||
gitHooksEnabled: true,
|
||||
});
|
||||
|
||||
await runIndex({ providerStrategy: 'local' });
|
||||
|
||||
expect(Docker.run).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should error when providerStrategy is non-local and no plugin', async () => {
|
||||
const core = require('@actions/core');
|
||||
mockLoadOrchestratorPlugin.mockResolvedValue(undefined);
|
||||
|
||||
await runIndex({ providerStrategy: 'aws' });
|
||||
|
||||
expect(core.setFailed).toHaveBeenCalledWith(expect.stringContaining('requires @game-ci/orchestrator'));
|
||||
});
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// canHandleBuild = false with non-local provider
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
describe('plugin installed but canHandleBuild returns false with non-local provider', () => {
|
||||
it('should error when providerStrategy is non-local', async () => {
|
||||
const core = require('@actions/core');
|
||||
mockPlugin.canHandleBuild.mockReturnValue(false);
|
||||
|
||||
await runIndex({ providerStrategy: 'aws' });
|
||||
|
||||
// The plugin is initialized but says it can't handle the build,
|
||||
// and providerStrategy is not local, so it falls to the error case
|
||||
expect(core.setFailed).toHaveBeenCalledWith(expect.stringContaining('requires @game-ci/orchestrator'));
|
||||
// None of the plugin services should be called because
|
||||
// they are inside the `if (providerStrategy === 'local')` block
|
||||
expect(mockChildWorkspaceService.buildConfig).not.toHaveBeenCalled();
|
||||
expect(mockSubmoduleProfileService.createInitPlan).not.toHaveBeenCalled();
|
||||
expect(mockLfsAgentService.configure).not.toHaveBeenCalled();
|
||||
expect(mockLocalCacheService.resolveCacheRoot).not.toHaveBeenCalled();
|
||||
expect(mockGitHooksService.installHooks).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
424
src/index.ts
424
src/index.ts
@@ -1,9 +1,13 @@
|
||||
import * as core from '@actions/core';
|
||||
import path from 'node:path';
|
||||
import { Action, BuildParameters, Cache, Docker, ImageTag, Output } from './model';
|
||||
import { Cli } from './model/cli/cli';
|
||||
import MacBuilder from './model/mac-builder';
|
||||
import PlatformSetup from './model/platform-setup';
|
||||
import { loadOrchestratorPlugin, OrchestratorPlugin } from './model/orchestrator-plugin';
|
||||
import { loadOrchestrator, loadPluginServices } from './model/orchestrator-plugin';
|
||||
type SyncStrategy = 'full' | 'git-delta' | 'direct-input' | 'storage-pull';
|
||||
|
||||
type PluginServices = Exclude<ReturnType<typeof loadPluginServices> extends Promise<infer T> ? T : never, undefined>;
|
||||
|
||||
async function runMain() {
|
||||
try {
|
||||
@@ -15,39 +19,338 @@ async function runMain() {
|
||||
Action.checkCompatibility();
|
||||
Cache.verify();
|
||||
|
||||
const plugin = await loadPluginServices();
|
||||
|
||||
// Always configure git environment for CI reliability
|
||||
plugin?.BuildReliabilityService.configureGitEnvironment();
|
||||
|
||||
const { workspace, actionFolder } = Action;
|
||||
|
||||
const buildParameters = await BuildParameters.create();
|
||||
|
||||
// If a test suite path is provided, use the test workflow engine
|
||||
// instead of the standard build execution path
|
||||
if (buildParameters.testSuitePath) {
|
||||
core.info('[TestWorkflow] Test suite path detected, using test workflow engine');
|
||||
const results = await plugin?.TestWorkflowService.executeTestSuite(
|
||||
buildParameters.testSuitePath,
|
||||
buildParameters,
|
||||
);
|
||||
|
||||
let totalFailed = 0;
|
||||
for (const result of results || []) {
|
||||
totalFailed += result.failed;
|
||||
}
|
||||
|
||||
if (totalFailed > 0) {
|
||||
core.setFailed(`Test workflow completed with ${totalFailed} failure(s)`);
|
||||
} else {
|
||||
core.info('[TestWorkflow] All test runs passed');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const baseImage = new ImageTag(buildParameters);
|
||||
|
||||
// Load orchestrator plugin (optional — only needed for remote builds and plugin features)
|
||||
const plugin = await loadOrchestratorPlugin();
|
||||
await plugin?.initialize(buildParameters, workspace);
|
||||
// Pre-build reliability checks
|
||||
if (buildParameters.gitIntegrityCheck) {
|
||||
core.info('Running git integrity checks...');
|
||||
|
||||
const isHealthy = plugin?.BuildReliabilityService.checkGitIntegrity(workspace);
|
||||
plugin?.BuildReliabilityService.cleanStaleLockFiles(workspace);
|
||||
plugin?.BuildReliabilityService.validateSubmoduleBackingStores(workspace);
|
||||
|
||||
if (buildParameters.cleanReservedFilenames) {
|
||||
plugin?.BuildReliabilityService.cleanReservedFilenames(buildParameters.projectPath);
|
||||
}
|
||||
|
||||
if (!isHealthy && buildParameters.gitAutoRecover) {
|
||||
core.info('Git corruption detected, attempting automatic recovery...');
|
||||
const recovered = plugin?.BuildReliabilityService.recoverCorruptedRepo(workspace);
|
||||
if (!recovered) {
|
||||
core.warning('Automatic recovery failed. Build may encounter issues.');
|
||||
}
|
||||
}
|
||||
} else if (buildParameters.cleanReservedFilenames) {
|
||||
// cleanReservedFilenames can run independently of gitIntegrityCheck
|
||||
plugin?.BuildReliabilityService.cleanReservedFilenames(buildParameters.projectPath);
|
||||
}
|
||||
|
||||
let exitCode = -1;
|
||||
|
||||
if (plugin?.canHandleBuild()) {
|
||||
// Plugin handles the build entirely (remote providers, hot runner, test workflows)
|
||||
const result = await plugin.handleBuild(baseImage.toString());
|
||||
// Hot runner path: attempt to use a persistent Unity editor instance
|
||||
if (buildParameters.hotRunnerEnabled) {
|
||||
core.info('[HotRunner] Hot runner mode enabled, attempting hot build...');
|
||||
|
||||
exitCode = result.fallbackToLocal
|
||||
? await runLocalBuild(buildParameters, baseImage, workspace, actionFolder, plugin)
|
||||
: result.exitCode;
|
||||
const hotRunnerConfig = {
|
||||
enabled: true,
|
||||
transport: buildParameters.hotRunnerTransport,
|
||||
host: buildParameters.hotRunnerHost,
|
||||
port: buildParameters.hotRunnerPort,
|
||||
healthCheckInterval: buildParameters.hotRunnerHealthInterval,
|
||||
maxIdleTime: buildParameters.hotRunnerMaxIdle,
|
||||
maxJobsBeforeRecycle: 0, // no automatic recycle by job count
|
||||
};
|
||||
|
||||
if (!plugin?.HotRunnerService) {
|
||||
throw new Error('[HotRunner] Orchestrator plugin required for hot runner mode');
|
||||
}
|
||||
|
||||
const hotRunnerService = new plugin.HotRunnerService();
|
||||
|
||||
try {
|
||||
await hotRunnerService.initialize(hotRunnerConfig);
|
||||
const result = await hotRunnerService.submitBuild(buildParameters, (output: string) => {
|
||||
core.info(output);
|
||||
});
|
||||
|
||||
exitCode = result.exitCode;
|
||||
core.info(`[HotRunner] Build completed with exit code ${exitCode}`);
|
||||
await hotRunnerService.shutdown();
|
||||
} catch (hotRunnerError) {
|
||||
await hotRunnerService.shutdown();
|
||||
|
||||
if (buildParameters.hotRunnerFallbackToCold) {
|
||||
core.warning(
|
||||
`[HotRunner] Hot runner failed: ${(hotRunnerError as Error).message}. Falling back to cold build.`,
|
||||
);
|
||||
exitCode = await runColdBuild(buildParameters, baseImage, workspace, actionFolder);
|
||||
} else {
|
||||
throw hotRunnerError;
|
||||
}
|
||||
}
|
||||
} else if (buildParameters.providerStrategy === 'local') {
|
||||
exitCode = await runLocalBuild(buildParameters, baseImage, workspace, actionFolder, plugin);
|
||||
core.info('Building locally');
|
||||
|
||||
// Child workspace isolation - restore cached workspace before any other setup
|
||||
let childWorkspaceConfig: any;
|
||||
if (buildParameters.childWorkspacesEnabled && buildParameters.childWorkspaceName) {
|
||||
const ChildWorkspaceService = await plugin?.loadChildWorkspaceService();
|
||||
const cacheRoot =
|
||||
buildParameters.childWorkspaceCacheRoot ||
|
||||
path.join(buildParameters.runnerTempPath || process.env.RUNNER_TEMP || '', 'game-ci-workspaces');
|
||||
childWorkspaceConfig = ChildWorkspaceService?.buildConfig({
|
||||
childWorkspacesEnabled: buildParameters.childWorkspacesEnabled,
|
||||
childWorkspaceName: buildParameters.childWorkspaceName,
|
||||
childWorkspaceCacheRoot: cacheRoot,
|
||||
childWorkspacePreserveGit: buildParameters.childWorkspacePreserveGit,
|
||||
childWorkspaceSeparateLibrary: buildParameters.childWorkspaceSeparateLibrary,
|
||||
});
|
||||
const projectFullPath = path.join(workspace, buildParameters.projectPath);
|
||||
const restored = ChildWorkspaceService?.initializeWorkspace(projectFullPath, childWorkspaceConfig);
|
||||
core.info(
|
||||
`Child workspace "${buildParameters.childWorkspaceName}": ${
|
||||
restored ? 'restored from cache' : 'starting fresh'
|
||||
}`,
|
||||
);
|
||||
|
||||
// Log workspace size for resource tracking
|
||||
const size = ChildWorkspaceService?.getWorkspaceSize(projectFullPath);
|
||||
core.info(`Child workspace size after restore: ${size}`);
|
||||
}
|
||||
|
||||
// Submodule profile initialization
|
||||
if (buildParameters.submoduleProfilePath) {
|
||||
core.info('Initializing submodules from profile...');
|
||||
const SubmoduleProfileService = await plugin?.loadSubmoduleProfileService();
|
||||
const plan = await SubmoduleProfileService?.createInitPlan(
|
||||
buildParameters.submoduleProfilePath,
|
||||
buildParameters.submoduleVariantPath,
|
||||
workspace,
|
||||
);
|
||||
|
||||
if (plan) {
|
||||
await SubmoduleProfileService?.execute(
|
||||
plan,
|
||||
workspace,
|
||||
buildParameters.submoduleToken || buildParameters.gitPrivateToken,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Configure custom LFS transfer agent
|
||||
if (buildParameters.lfsTransferAgent) {
|
||||
core.info('Configuring custom LFS transfer agent...');
|
||||
const LfsAgentService = await plugin?.loadLfsAgentService();
|
||||
await LfsAgentService?.configure(
|
||||
buildParameters.lfsTransferAgent,
|
||||
buildParameters.lfsTransferAgentArgs,
|
||||
buildParameters.lfsStoragePaths ? buildParameters.lfsStoragePaths.split(';') : [],
|
||||
workspace,
|
||||
);
|
||||
}
|
||||
|
||||
// Local build caching - restore
|
||||
let cacheRoot = '';
|
||||
let cacheKey = '';
|
||||
// eslint-disable-next-line no-undef
|
||||
let LocalCacheService: Awaited<ReturnType<NonNullable<typeof plugin>['loadLocalCacheService']>> | undefined;
|
||||
if (buildParameters.localCacheEnabled) {
|
||||
LocalCacheService = await plugin?.loadLocalCacheService();
|
||||
cacheRoot = LocalCacheService?.resolveCacheRoot(buildParameters) || '';
|
||||
cacheKey =
|
||||
LocalCacheService?.generateCacheKey(
|
||||
buildParameters.targetPlatform,
|
||||
buildParameters.editorVersion,
|
||||
buildParameters.branch || '',
|
||||
) || '';
|
||||
if (buildParameters.localCacheLfs) {
|
||||
await LocalCacheService?.restoreLfsCache(workspace, cacheRoot, cacheKey);
|
||||
}
|
||||
if (buildParameters.localCacheLibrary) {
|
||||
const projectFullPath = path.join(workspace, buildParameters.projectPath);
|
||||
await LocalCacheService?.restoreLibraryCache(projectFullPath, cacheRoot, cacheKey);
|
||||
}
|
||||
}
|
||||
|
||||
// Git hooks — opt-in only. When disabled (default), do not touch hooks at all.
|
||||
if (buildParameters.gitHooksEnabled) {
|
||||
const GitHooksService = await plugin?.loadGitHooksService();
|
||||
await GitHooksService?.installHooks(workspace);
|
||||
if (buildParameters.gitHooksSkipList) {
|
||||
const environment = GitHooksService?.configureSkipList(buildParameters.gitHooksSkipList.split(','));
|
||||
if (environment) {
|
||||
Object.assign(process.env, environment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Apply incremental sync strategy before build
|
||||
const syncStrategy = buildParameters.syncStrategy as SyncStrategy;
|
||||
if (syncStrategy !== 'full') {
|
||||
core.info(`[Sync] Applying sync strategy: ${syncStrategy}`);
|
||||
await applySyncStrategy(buildParameters, workspace, plugin);
|
||||
}
|
||||
|
||||
await PlatformSetup.setup(buildParameters, actionFolder);
|
||||
exitCode =
|
||||
process.platform === 'darwin'
|
||||
? await MacBuilder.run(actionFolder)
|
||||
: await Docker.run(baseImage.toString(), {
|
||||
workspace,
|
||||
actionFolder,
|
||||
...buildParameters,
|
||||
});
|
||||
|
||||
// Local build caching - save
|
||||
if (buildParameters.localCacheEnabled && LocalCacheService) {
|
||||
if (buildParameters.localCacheLibrary) {
|
||||
const projectFullPath = path.join(workspace, buildParameters.projectPath);
|
||||
await LocalCacheService.saveLibraryCache(projectFullPath, cacheRoot, cacheKey);
|
||||
}
|
||||
if (buildParameters.localCacheLfs) {
|
||||
await LocalCacheService.saveLfsCache(workspace, cacheRoot, cacheKey);
|
||||
}
|
||||
}
|
||||
|
||||
// Child workspace isolation - save workspace for next run
|
||||
if (childWorkspaceConfig && childWorkspaceConfig.enabled) {
|
||||
const ChildWorkspaceService = await plugin?.loadChildWorkspaceService();
|
||||
const projectFullPath = path.join(workspace, buildParameters.projectPath);
|
||||
const preSaveSize = ChildWorkspaceService?.getWorkspaceSize(projectFullPath);
|
||||
core.info(`Child workspace size before save: ${preSaveSize}`);
|
||||
|
||||
ChildWorkspaceService?.saveWorkspace(projectFullPath, childWorkspaceConfig);
|
||||
core.info(`Child workspace "${buildParameters.childWorkspaceName}" saved to cache`);
|
||||
}
|
||||
|
||||
// Revert overlays after job completion if configured
|
||||
if (buildParameters.syncRevertAfter && syncStrategy !== 'full') {
|
||||
core.info('[Sync] Reverting overlay changes after job completion');
|
||||
try {
|
||||
await plugin?.IncrementalSyncService.revertOverlays(workspace, buildParameters.syncStatePath);
|
||||
} catch (revertError) {
|
||||
core.warning(`[Sync] Overlay revert failed: ${(revertError as Error).message}`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Error(
|
||||
`Provider strategy "${buildParameters.providerStrategy}" requires @game-ci/orchestrator. ` +
|
||||
'Install it via the game-ci/orchestrator action, or use providerStrategy=local.',
|
||||
const orchestrator = await loadOrchestrator();
|
||||
if (!orchestrator) {
|
||||
throw new Error(
|
||||
'Orchestrator package not available. Install @game-ci/orchestrator or use providerStrategy=local.',
|
||||
);
|
||||
}
|
||||
await orchestrator.run(buildParameters, baseImage.toString());
|
||||
exitCode = 0;
|
||||
}
|
||||
|
||||
// Post-build: archive and enforce retention
|
||||
if (buildParameters.buildArchiveEnabled && exitCode === 0) {
|
||||
core.info('Archiving build output...');
|
||||
plugin?.BuildReliabilityService.archiveBuildOutput(buildParameters.buildPath, buildParameters.buildArchivePath);
|
||||
plugin?.BuildReliabilityService.enforceRetention(
|
||||
buildParameters.buildArchivePath,
|
||||
buildParameters.buildArchiveRetention,
|
||||
);
|
||||
}
|
||||
|
||||
// Set core outputs
|
||||
// Set output
|
||||
await Output.setBuildVersion(buildParameters.buildVersion);
|
||||
await Output.setAndroidVersionCode(buildParameters.androidVersionCode);
|
||||
await Output.setEngineExitCode(exitCode);
|
||||
|
||||
// Plugin handles post-build (artifacts, archiving, retention)
|
||||
await plugin?.handlePostBuild(exitCode);
|
||||
// Artifact collection and upload (runs on both success and failure)
|
||||
try {
|
||||
// Register custom output types if provided
|
||||
if (buildParameters.artifactCustomTypes) {
|
||||
try {
|
||||
const customTypes = JSON.parse(buildParameters.artifactCustomTypes);
|
||||
if (Array.isArray(customTypes)) {
|
||||
for (const ct of customTypes) {
|
||||
plugin?.OutputTypeRegistry.registerType({
|
||||
name: ct.name,
|
||||
defaultPath: ct.defaultPath || ct.pattern || `./${ct.name}/`,
|
||||
description: ct.description || `Custom output type: ${ct.name}`,
|
||||
builtIn: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (parseError) {
|
||||
core.warning(`Failed to parse artifactCustomTypes: ${(parseError as Error).message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Collect outputs and generate manifest
|
||||
const manifestPath = path.join(buildParameters.projectPath, 'output-manifest.json');
|
||||
const manifest = await plugin?.OutputService.collectOutputs(
|
||||
buildParameters.projectPath,
|
||||
buildParameters.buildGuid,
|
||||
buildParameters.artifactOutputTypes,
|
||||
manifestPath,
|
||||
);
|
||||
|
||||
core.setOutput('artifactManifestPath', manifestPath);
|
||||
|
||||
if (manifest) {
|
||||
// Upload artifacts
|
||||
const uploadConfig = plugin?.ArtifactUploadHandler.parseConfig(
|
||||
buildParameters.artifactUploadTarget,
|
||||
buildParameters.artifactUploadPath || undefined,
|
||||
buildParameters.artifactCompression,
|
||||
buildParameters.artifactRetentionDays,
|
||||
);
|
||||
|
||||
if (uploadConfig) {
|
||||
const uploadResult = await plugin?.ArtifactUploadHandler.uploadArtifacts(
|
||||
manifest,
|
||||
uploadConfig,
|
||||
buildParameters.projectPath,
|
||||
);
|
||||
|
||||
if (uploadResult && !uploadResult.success) {
|
||||
core.warning(
|
||||
`Artifact upload completed with errors: ${uploadResult.entries
|
||||
.filter((entry: any) => !entry.success)
|
||||
.map((entry: any) => `${entry.type}: ${entry.error}`)
|
||||
.join('; ')}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (artifactError) {
|
||||
core.warning(`Artifact collection/upload failed: ${(artifactError as Error).message}`);
|
||||
}
|
||||
|
||||
if (exitCode !== 0) {
|
||||
core.setFailed(`Build failed with exit code ${exitCode}`);
|
||||
@@ -57,28 +360,99 @@ async function runMain() {
|
||||
}
|
||||
}
|
||||
|
||||
async function runLocalBuild(
|
||||
async function runColdBuild(
|
||||
buildParameters: BuildParameters,
|
||||
baseImage: ImageTag,
|
||||
workspace: string,
|
||||
actionFolder: string,
|
||||
plugin?: OrchestratorPlugin,
|
||||
): Promise<number> {
|
||||
await plugin?.beforeLocalBuild(workspace);
|
||||
if (buildParameters.providerStrategy === 'local') {
|
||||
core.info('Building locally');
|
||||
await PlatformSetup.setup(buildParameters, actionFolder);
|
||||
|
||||
await PlatformSetup.setup(buildParameters, actionFolder);
|
||||
const exitCode =
|
||||
process.platform === 'darwin'
|
||||
return process.platform === 'darwin'
|
||||
? await MacBuilder.run(actionFolder)
|
||||
: await Docker.run(baseImage.toString(), {
|
||||
workspace,
|
||||
actionFolder,
|
||||
...buildParameters,
|
||||
});
|
||||
} else {
|
||||
const orchestrator = await loadOrchestrator();
|
||||
if (!orchestrator) {
|
||||
throw new Error(
|
||||
'Orchestrator package not available. Install @game-ci/orchestrator or use providerStrategy=local.',
|
||||
);
|
||||
}
|
||||
await orchestrator.run(buildParameters, baseImage.toString());
|
||||
|
||||
await plugin?.afterLocalBuild(workspace, exitCode);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return exitCode;
|
||||
/**
|
||||
* Apply the configured sync strategy to the workspace before build.
|
||||
*/
|
||||
async function applySyncStrategy(
|
||||
buildParameters: BuildParameters,
|
||||
workspace: string,
|
||||
plugin?: PluginServices | undefined,
|
||||
): Promise<void> {
|
||||
if (!plugin?.IncrementalSyncService) {
|
||||
core.warning('[Sync] Orchestrator plugin not available, skipping sync strategy');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const { IncrementalSyncService } = plugin;
|
||||
const strategy = buildParameters.syncStrategy as SyncStrategy;
|
||||
const resolvedStrategy = IncrementalSyncService.resolveStrategy(strategy, workspace, buildParameters.syncStatePath);
|
||||
|
||||
if (resolvedStrategy === 'full') {
|
||||
core.info('[Sync] Resolved to full sync (no incremental state available)');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (resolvedStrategy) {
|
||||
case 'git-delta': {
|
||||
const targetReference = buildParameters.gitSha || buildParameters.branch;
|
||||
const changedFiles = await IncrementalSyncService.syncGitDelta(
|
||||
workspace,
|
||||
targetReference,
|
||||
buildParameters.syncStatePath,
|
||||
);
|
||||
core.info(`[Sync] Git delta sync applied: ${changedFiles} file(s) changed`);
|
||||
break;
|
||||
}
|
||||
case 'direct-input': {
|
||||
if (!buildParameters.syncInputRef) {
|
||||
throw new Error('[Sync] direct-input strategy requires syncInputRef to be set');
|
||||
}
|
||||
const overlays = await IncrementalSyncService.applyDirectInput(
|
||||
workspace,
|
||||
buildParameters.syncInputRef,
|
||||
buildParameters.syncStorageRemote || undefined,
|
||||
buildParameters.syncStatePath,
|
||||
);
|
||||
core.info(`[Sync] Direct input applied: ${overlays.length} overlay(s)`);
|
||||
break;
|
||||
}
|
||||
case 'storage-pull': {
|
||||
if (!buildParameters.syncInputRef) {
|
||||
throw new Error('[Sync] storage-pull strategy requires syncInputRef to be set');
|
||||
}
|
||||
const pulledFiles = await IncrementalSyncService.syncStoragePull(workspace, buildParameters.syncInputRef, {
|
||||
rcloneRemote: buildParameters.syncStorageRemote || undefined,
|
||||
syncRevertAfter: buildParameters.syncRevertAfter,
|
||||
statePath: buildParameters.syncStatePath,
|
||||
});
|
||||
core.info(`[Sync] Storage pull complete: ${pulledFiles.length} file(s)`);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
core.warning(`[Sync] Unknown sync strategy: ${resolvedStrategy}`);
|
||||
}
|
||||
}
|
||||
|
||||
runMain();
|
||||
|
||||
@@ -219,10 +219,5 @@ describe('BuildParameters', () => {
|
||||
jest.spyOn(Input, 'customParameters', 'get').mockReturnValue(mockValue);
|
||||
await expect(BuildParameters.create()).resolves.toEqual(expect.objectContaining({ customParameters: mockValue }));
|
||||
});
|
||||
|
||||
it.each([true, false])('returns the flag for useHostNetwork when %s', async (mockValue) => {
|
||||
jest.spyOn(Input, 'useHostNetwork', 'get').mockReturnValue(mockValue);
|
||||
await expect(BuildParameters.create()).resolves.toEqual(expect.objectContaining({ useHostNetwork: mockValue }));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -47,26 +47,165 @@ class BuildParameters {
|
||||
public containerRegistryImageVersion!: string;
|
||||
|
||||
public customParameters!: string;
|
||||
public useHostNetwork!: boolean;
|
||||
public sshAgent!: string;
|
||||
public sshPublicKeysDirectoryPath!: string;
|
||||
public providerStrategy!: string;
|
||||
public fallbackProviderStrategy!: string;
|
||||
public runnerCheckEnabled!: boolean;
|
||||
public runnerCheckLabels!: string[];
|
||||
public runnerCheckMinAvailable!: number;
|
||||
public retryOnFallback!: boolean;
|
||||
public providerInitTimeout!: number;
|
||||
public gitAuthMode!: string;
|
||||
public gitPrivateToken!: string;
|
||||
public awsStackName!: string;
|
||||
public awsEndpoint?: string;
|
||||
public awsCloudFormationEndpoint?: string;
|
||||
public awsEcsEndpoint?: string;
|
||||
public awsKinesisEndpoint?: string;
|
||||
public awsCloudWatchLogsEndpoint?: string;
|
||||
public awsS3Endpoint?: string;
|
||||
public storageProvider!: string;
|
||||
public rcloneRemote!: string;
|
||||
public kubeConfig!: string;
|
||||
public containerMemory!: string;
|
||||
public containerCpu!: string;
|
||||
public containerNamespace!: string;
|
||||
public kubeVolumeSize!: string;
|
||||
public kubeVolume!: string;
|
||||
public kubeStorageClass!: string;
|
||||
public runAsHostUser!: string;
|
||||
public chownFilesTo!: string;
|
||||
public commandHooks!: string;
|
||||
public pullInputList!: string[];
|
||||
public inputPullCommand!: string;
|
||||
public cacheKey!: string;
|
||||
|
||||
public postBuildContainerHooks!: string;
|
||||
public preBuildContainerHooks!: string;
|
||||
public customJob!: string;
|
||||
public runNumber!: string;
|
||||
public branch!: string;
|
||||
public githubRepo!: string;
|
||||
public orchestratorRepoName!: string;
|
||||
public cloneDepth!: number;
|
||||
public gitSha!: string;
|
||||
public logId!: string;
|
||||
public buildGuid!: string;
|
||||
public orchestratorBranch!: string;
|
||||
public orchestratorDebug!: boolean | undefined;
|
||||
public buildPlatform!: string | undefined;
|
||||
public isCliMode!: boolean;
|
||||
|
||||
public maxRetainedWorkspaces!: number;
|
||||
public useLargePackages!: boolean;
|
||||
public useCompressionStrategy!: boolean;
|
||||
public garbageMaxAge!: number;
|
||||
public githubChecks!: boolean;
|
||||
public asyncWorkflow!: boolean;
|
||||
public githubCheckId!: string;
|
||||
public finalHooks!: string[];
|
||||
public skipLfs!: boolean;
|
||||
public skipCache!: boolean;
|
||||
public cacheUnityInstallationOnMac!: boolean;
|
||||
public unityHubVersionOnMac!: string;
|
||||
public dockerWorkspacePath!: string;
|
||||
public submoduleProfilePath!: string;
|
||||
public submoduleVariantPath!: string;
|
||||
public submoduleToken!: string;
|
||||
public localCacheEnabled!: boolean;
|
||||
public localCacheRoot!: string;
|
||||
public localCacheLibrary!: boolean;
|
||||
public localCacheLfs!: boolean;
|
||||
public childWorkspacesEnabled!: boolean;
|
||||
public childWorkspaceName!: string;
|
||||
public childWorkspaceCacheRoot!: string;
|
||||
public childWorkspacePreserveGit!: boolean;
|
||||
public childWorkspaceSeparateLibrary!: boolean;
|
||||
public lfsTransferAgent!: string;
|
||||
public lfsTransferAgentArgs!: string;
|
||||
public lfsStoragePaths!: string;
|
||||
public gitHooksEnabled!: boolean;
|
||||
public gitHooksSkipList!: string;
|
||||
public gitHooksRunBeforeBuild!: string;
|
||||
public providerExecutable!: string;
|
||||
|
||||
// GCP Cloud Run (Experimental)
|
||||
public gcpProject!: string;
|
||||
public gcpRegion!: string;
|
||||
public gcpStorageType!: string;
|
||||
public gcpBucket!: string;
|
||||
public gcpFilestoreIp!: string;
|
||||
public gcpFilestoreShare!: string;
|
||||
public gcpMachineType!: string;
|
||||
public gcpDiskSizeGb!: string;
|
||||
public gcpServiceAccount!: string;
|
||||
public gcpVpcConnector!: string;
|
||||
|
||||
// Azure Container Instances (Experimental)
|
||||
public azureResourceGroup!: string;
|
||||
public azureLocation!: string;
|
||||
public azureStorageType!: string;
|
||||
public azureStorageAccount!: string;
|
||||
public azureBlobContainer!: string;
|
||||
public azureFileShareName!: string;
|
||||
public azureSubscriptionId!: string;
|
||||
public azureCpu!: string;
|
||||
public azureMemoryGb!: string;
|
||||
public azureDiskSizeGb!: string;
|
||||
public azureSubnetId!: string;
|
||||
|
||||
// Remote PowerShell provider
|
||||
public remotePowershellHost!: string;
|
||||
public remotePowershellCredential!: string;
|
||||
public remotePowershellTransport!: string;
|
||||
|
||||
// GitHub Actions provider
|
||||
public githubActionsRepo!: string;
|
||||
public githubActionsWorkflow!: string;
|
||||
public githubActionsToken!: string;
|
||||
public githubActionsRef!: string;
|
||||
|
||||
// GitLab CI provider
|
||||
public gitlabProjectId!: string;
|
||||
public gitlabTriggerToken!: string;
|
||||
public gitlabApiUrl!: string;
|
||||
public gitlabRef!: string;
|
||||
|
||||
// Ansible provider
|
||||
public ansibleInventory!: string;
|
||||
public ansiblePlaybook!: string;
|
||||
public ansibleExtraVars!: string;
|
||||
public ansibleVaultPassword!: string;
|
||||
public gitIntegrityCheck!: boolean;
|
||||
public gitAutoRecover!: boolean;
|
||||
public cleanReservedFilenames!: boolean;
|
||||
public buildArchiveEnabled!: boolean;
|
||||
public buildArchivePath!: string;
|
||||
public buildArchiveRetention!: number;
|
||||
|
||||
public testSuitePath!: string;
|
||||
public testSuiteEvent!: string;
|
||||
public testTaxonomyPath!: string;
|
||||
public testResultFormat!: string;
|
||||
public testResultPath!: string;
|
||||
public hotRunnerEnabled!: boolean;
|
||||
public hotRunnerTransport!: 'websocket' | 'grpc' | 'named-pipe';
|
||||
public hotRunnerHost!: string;
|
||||
public hotRunnerPort!: number;
|
||||
public hotRunnerHealthInterval!: number;
|
||||
public hotRunnerMaxIdle!: number;
|
||||
public hotRunnerFallbackToCold!: boolean;
|
||||
public artifactOutputTypes!: string;
|
||||
public artifactUploadTarget!: string;
|
||||
public artifactUploadPath!: string;
|
||||
public artifactCompression!: string;
|
||||
public artifactRetentionDays!: string;
|
||||
public artifactCustomTypes!: string;
|
||||
public syncStrategy!: string;
|
||||
public syncInputRef!: string;
|
||||
public syncStorageRemote!: string;
|
||||
public syncRevertAfter!: boolean;
|
||||
public syncStatePath!: string;
|
||||
|
||||
static async create(): Promise<BuildParameters> {
|
||||
const buildFile = this.parseBuildFile(Input.buildName, Input.targetPlatform, Input.androidExportType);
|
||||
@@ -112,8 +251,6 @@ class BuildParameters {
|
||||
core.setSecret(`${unitySerial.slice(0, -4)}XXXX`);
|
||||
}
|
||||
|
||||
const providerStrategy = Input.getInput('providerStrategy') || (Cli.isCliMode ? 'aws' : 'local');
|
||||
|
||||
return {
|
||||
editorVersion,
|
||||
customImage: Input.customImage,
|
||||
@@ -142,7 +279,6 @@ class BuildParameters {
|
||||
androidExportType: Input.androidExportType,
|
||||
androidSymbolType: androidSymbolExportType,
|
||||
customParameters: Input.customParameters,
|
||||
useHostNetwork: Input.useHostNetwork,
|
||||
sshAgent: Input.sshAgent,
|
||||
sshPublicKeysDirectoryPath: Input.sshPublicKeysDirectoryPath,
|
||||
gitPrivateToken: Input.gitPrivateToken ?? (await GithubCliReader.GetGitHubAuthToken()),
|
||||
@@ -153,21 +289,166 @@ class BuildParameters {
|
||||
dockerIsolationMode: Input.dockerIsolationMode,
|
||||
containerRegistryRepository: Input.containerRegistryRepository,
|
||||
containerRegistryImageVersion: Input.containerRegistryImageVersion,
|
||||
providerStrategy,
|
||||
buildPlatform: providerStrategy !== 'local' ? 'linux' : process.platform,
|
||||
providerStrategy: Input.getInput('providerStrategy') || (Cli.isCliMode ? 'aws' : 'local'),
|
||||
fallbackProviderStrategy: Input.getInput('fallbackProviderStrategy') || '',
|
||||
runnerCheckEnabled: Input.getInput('runnerCheckEnabled') === 'true',
|
||||
runnerCheckLabels: (Input.getInput('runnerCheckLabels') || '')
|
||||
.split(',')
|
||||
.map((l: string) => l.trim())
|
||||
.filter(Boolean),
|
||||
runnerCheckMinAvailable: Number(Input.getInput('runnerCheckMinAvailable')) || 1,
|
||||
retryOnFallback: Input.getInput('retryOnFallback') === 'true',
|
||||
providerInitTimeout: Number(Input.getInput('providerInitTimeout')) || 0,
|
||||
gitAuthMode: Input.getInput('gitAuthMode') || 'header',
|
||||
buildPlatform:
|
||||
Input.getInput('buildPlatform') ||
|
||||
((Input.getInput('providerStrategy') || 'local') !== 'local' ? 'linux' : process.platform),
|
||||
kubeConfig: Input.getInput('kubeConfig') || '',
|
||||
containerMemory: Input.getInput('containerMemory') || '3072',
|
||||
containerCpu: Input.getInput('containerCpu') || '1024',
|
||||
containerNamespace: Input.getInput('containerNamespace') || 'default',
|
||||
kubeVolumeSize: Input.getInput('kubeVolumeSize') || '25Gi',
|
||||
kubeVolume: Input.getInput('kubeVolume') || '',
|
||||
postBuildContainerHooks: Input.getInput('postBuildContainerHooks') || '',
|
||||
preBuildContainerHooks: Input.getInput('preBuildContainerHooks') || '',
|
||||
customJob: Input.getInput('customJob') || '',
|
||||
runNumber: Input.runNumber,
|
||||
branch: Input.branch.replace('/head', '') || (await GitRepoReader.GetBranch()),
|
||||
githubRepo: (Input.githubRepo ?? (await GitRepoReader.GetRemote())) || 'game-ci/unity-builder',
|
||||
orchestratorBranch: (Input.getInput('orchestratorBranch') || 'main').split('/').reverse()[0],
|
||||
orchestratorDebug:
|
||||
Input.getInput('orchestratorDebug') === 'true' || Input.getInput('orchestratorTests') === 'true',
|
||||
githubRepo:
|
||||
(Input.githubRepo ?? (await GitRepoReader.GetRemote())) ||
|
||||
Input.getInput('orchestratorRepoName') ||
|
||||
'game-ci/unity-builder',
|
||||
orchestratorRepoName: Input.getInput('orchestratorRepoName') || 'game-ci/unity-builder',
|
||||
cloneDepth: Number.parseInt(Input.getInput('cloneDepth') || '50'),
|
||||
isCliMode: Cli.isCliMode,
|
||||
awsStackName: Input.getInput('awsStackName') || 'game-ci',
|
||||
awsEndpoint: Input.getInput('awsEndpoint'),
|
||||
awsCloudFormationEndpoint: Input.getInput('awsCloudFormationEndpoint') || Input.getInput('awsEndpoint'),
|
||||
awsEcsEndpoint: Input.getInput('awsEcsEndpoint') || Input.getInput('awsEndpoint'),
|
||||
awsKinesisEndpoint: Input.getInput('awsKinesisEndpoint') || Input.getInput('awsEndpoint'),
|
||||
awsCloudWatchLogsEndpoint: Input.getInput('awsCloudWatchLogsEndpoint') || Input.getInput('awsEndpoint'),
|
||||
awsS3Endpoint: Input.getInput('awsS3Endpoint') || Input.getInput('awsEndpoint'),
|
||||
storageProvider: Input.getInput('storageProvider') || 's3',
|
||||
rcloneRemote: Input.getInput('rcloneRemote') || '',
|
||||
gitSha: Input.gitSha,
|
||||
logId: customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', 9)(),
|
||||
buildGuid: `${Input.runNumber}-${Input.targetPlatform.toLowerCase().replace('standalone', '')}-${customAlphabet(
|
||||
'0123456789abcdefghijklmnopqrstuvwxyz',
|
||||
4,
|
||||
)()}`,
|
||||
isCliMode: Cli.isCliMode,
|
||||
commandHooks: Input.getInput('commandHooks') || '',
|
||||
inputPullCommand: Input.getInput('inputPullCommand') || '',
|
||||
pullInputList: (Input.getInput('pullInputList') || '').split(',').filter(Boolean),
|
||||
kubeStorageClass: Input.getInput('kubeStorageClass') || '',
|
||||
gcpProject: Input.gcpProject,
|
||||
gcpRegion: Input.gcpRegion,
|
||||
gcpStorageType: Input.gcpStorageType,
|
||||
gcpBucket: Input.gcpBucket,
|
||||
gcpFilestoreIp: Input.gcpFilestoreIp,
|
||||
gcpFilestoreShare: Input.gcpFilestoreShare,
|
||||
gcpMachineType: Input.gcpMachineType,
|
||||
gcpDiskSizeGb: Input.gcpDiskSizeGb,
|
||||
gcpServiceAccount: Input.gcpServiceAccount,
|
||||
gcpVpcConnector: Input.gcpVpcConnector,
|
||||
azureResourceGroup: Input.azureResourceGroup,
|
||||
azureLocation: Input.azureLocation,
|
||||
azureStorageType: Input.azureStorageType,
|
||||
azureStorageAccount: Input.azureStorageAccount,
|
||||
azureBlobContainer: Input.azureBlobContainer,
|
||||
azureFileShareName: Input.azureFileShareName,
|
||||
azureSubscriptionId: Input.azureSubscriptionId,
|
||||
azureCpu: Input.azureCpu,
|
||||
azureMemoryGb: Input.azureMemoryGb,
|
||||
azureDiskSizeGb: Input.azureDiskSizeGb,
|
||||
azureSubnetId: Input.azureSubnetId,
|
||||
cacheKey: Input.getInput('cacheKey') || Input.branch,
|
||||
maxRetainedWorkspaces: Number.parseInt(Input.getInput('maxRetainedWorkspaces') || '0'),
|
||||
useLargePackages: Input.getInput('useLargePackages') === 'true',
|
||||
useCompressionStrategy: Input.getInput('useCompressionStrategy') === 'true',
|
||||
garbageMaxAge: Number(Input.getInput('garbageMaxAge')) || 24,
|
||||
githubChecks: Input.getInput('githubChecks') === 'true',
|
||||
asyncWorkflow: Input.getInput('asyncOrchestrator') === 'true',
|
||||
githubCheckId: Input.getInput('githubCheckId') || '',
|
||||
finalHooks: (Input.getInput('finalHooks') || '').split(',').filter(Boolean),
|
||||
skipLfs: Input.getInput('skipLfs') === 'true',
|
||||
skipCache: Input.getInput('skipCache') === 'true',
|
||||
cacheUnityInstallationOnMac: Input.cacheUnityInstallationOnMac,
|
||||
unityHubVersionOnMac: Input.unityHubVersionOnMac,
|
||||
dockerWorkspacePath: Input.dockerWorkspacePath,
|
||||
submoduleProfilePath: Input.submoduleProfilePath,
|
||||
submoduleVariantPath: Input.submoduleVariantPath,
|
||||
submoduleToken: Input.submoduleToken,
|
||||
localCacheEnabled: Input.localCacheEnabled,
|
||||
localCacheRoot: Input.localCacheRoot,
|
||||
localCacheLibrary: Input.localCacheLibrary,
|
||||
localCacheLfs: Input.localCacheLfs,
|
||||
childWorkspacesEnabled: Input.childWorkspacesEnabled,
|
||||
childWorkspaceName: Input.childWorkspaceName,
|
||||
childWorkspaceCacheRoot: Input.childWorkspaceCacheRoot,
|
||||
childWorkspacePreserveGit: Input.childWorkspacePreserveGit,
|
||||
childWorkspaceSeparateLibrary: Input.childWorkspaceSeparateLibrary,
|
||||
lfsTransferAgent: Input.lfsTransferAgent,
|
||||
lfsTransferAgentArgs: Input.lfsTransferAgentArgs,
|
||||
lfsStoragePaths: Input.lfsStoragePaths,
|
||||
gitHooksEnabled: Input.gitHooksEnabled,
|
||||
gitHooksSkipList: Input.gitHooksSkipList,
|
||||
gitHooksRunBeforeBuild: Input.gitHooksRunBeforeBuild,
|
||||
providerExecutable: Input.providerExecutable,
|
||||
|
||||
// Remote PowerShell provider
|
||||
remotePowershellHost: Input.remotePowershellHost,
|
||||
remotePowershellCredential: Input.remotePowershellCredential,
|
||||
remotePowershellTransport: Input.remotePowershellTransport,
|
||||
|
||||
// GitHub Actions provider
|
||||
githubActionsRepo: Input.githubActionsRepo,
|
||||
githubActionsWorkflow: Input.githubActionsWorkflow,
|
||||
githubActionsToken: Input.githubActionsToken,
|
||||
githubActionsRef: Input.githubActionsRef,
|
||||
|
||||
// GitLab CI provider
|
||||
gitlabProjectId: Input.gitlabProjectId,
|
||||
gitlabTriggerToken: Input.gitlabTriggerToken,
|
||||
gitlabApiUrl: Input.gitlabApiUrl,
|
||||
gitlabRef: Input.gitlabRef,
|
||||
|
||||
// Ansible provider
|
||||
ansibleInventory: Input.ansibleInventory,
|
||||
ansiblePlaybook: Input.ansiblePlaybook,
|
||||
ansibleExtraVars: Input.ansibleExtraVars,
|
||||
ansibleVaultPassword: Input.ansibleVaultPassword,
|
||||
gitIntegrityCheck: Input.gitIntegrityCheck,
|
||||
gitAutoRecover: Input.gitAutoRecover,
|
||||
cleanReservedFilenames: Input.cleanReservedFilenames,
|
||||
buildArchiveEnabled: Input.buildArchiveEnabled,
|
||||
buildArchivePath: Input.buildArchivePath,
|
||||
buildArchiveRetention: Input.buildArchiveRetention,
|
||||
testSuitePath: Input.testSuitePath,
|
||||
testSuiteEvent: Input.testSuiteEvent,
|
||||
testTaxonomyPath: Input.testTaxonomyPath,
|
||||
testResultFormat: Input.testResultFormat,
|
||||
testResultPath: Input.testResultPath,
|
||||
hotRunnerEnabled: Input.hotRunnerEnabled,
|
||||
hotRunnerTransport: Input.hotRunnerTransport,
|
||||
hotRunnerHost: Input.hotRunnerHost,
|
||||
hotRunnerPort: Input.hotRunnerPort,
|
||||
hotRunnerHealthInterval: Input.hotRunnerHealthInterval,
|
||||
hotRunnerMaxIdle: Input.hotRunnerMaxIdle,
|
||||
hotRunnerFallbackToCold: Input.hotRunnerFallbackToCold,
|
||||
artifactOutputTypes: Input.artifactOutputTypes,
|
||||
artifactUploadTarget: Input.artifactUploadTarget,
|
||||
artifactUploadPath: Input.artifactUploadPath,
|
||||
artifactCompression: Input.artifactCompression,
|
||||
artifactRetentionDays: Input.artifactRetentionDays,
|
||||
artifactCustomTypes: Input.artifactCustomTypes,
|
||||
syncStrategy: Input.syncStrategy,
|
||||
syncInputRef: Input.syncInputRef,
|
||||
syncStorageRemote: Input.syncStorageRemote,
|
||||
syncRevertAfter: Input.syncRevertAfter,
|
||||
syncStatePath: Input.syncStatePath,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ class Docker {
|
||||
const {
|
||||
workspace,
|
||||
actionFolder,
|
||||
useHostNetwork,
|
||||
runnerTempPath,
|
||||
sshAgent,
|
||||
sshPublicKeysDirectoryPath,
|
||||
@@ -86,7 +85,6 @@ class Docker {
|
||||
: ''
|
||||
} \
|
||||
${sshPublicKeysDirectoryPath ? `--volume ${sshPublicKeysDirectoryPath}:/root/.ssh:ro` : ''} \
|
||||
${useHostNetwork ? '--net=host' : ''} \
|
||||
${entrypointBash ? `--entrypoint ${commandPrefix}` : ``} \
|
||||
${image} \
|
||||
${entrypointBash ? `-c` : `${commandPrefix} -c`} \
|
||||
|
||||
@@ -334,22 +334,4 @@ describe('Input', () => {
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('useHostNetwork', () => {
|
||||
it('returns the default value', () => {
|
||||
expect(Input.useHostNetwork).toStrictEqual(false);
|
||||
});
|
||||
|
||||
it('returns true when string true is passed', () => {
|
||||
const spy = jest.spyOn(core, 'getInput').mockReturnValue('true');
|
||||
expect(Input.useHostNetwork).toStrictEqual(true);
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('returns false when string false is passed', () => {
|
||||
const spy = jest.spyOn(core, 'getInput').mockReturnValue('false');
|
||||
expect(Input.useHostNetwork).toStrictEqual(false);
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,8 +14,7 @@ export type InputKey = keyof typeof Input;
|
||||
*
|
||||
* Note that input is always passed as a string, even booleans.
|
||||
*
|
||||
* Only core build inputs belong here. Orchestrator/plugin inputs are read
|
||||
* directly by the @game-ci/orchestrator plugin via core.getInput() / env vars.
|
||||
* Todo: rename to UserInput and remove anything that is not direct input from the user / ci workflow
|
||||
*/
|
||||
class Input {
|
||||
public static getInput(query: string): string | undefined {
|
||||
@@ -41,6 +40,10 @@ class Input {
|
||||
}
|
||||
}
|
||||
|
||||
static get region(): string {
|
||||
return Input.getInput('region') ?? 'eu-west-2';
|
||||
}
|
||||
|
||||
static get githubRepo(): string | undefined {
|
||||
return Input.getInput('GITHUB_REPOSITORY') ?? Input.getInput('GITHUB_REPO') ?? undefined;
|
||||
}
|
||||
@@ -139,12 +142,6 @@ class Input {
|
||||
return Input.getInput('customParameters') ?? '';
|
||||
}
|
||||
|
||||
static get useHostNetwork(): boolean {
|
||||
const input = Input.getInput('useHostNetwork') ?? false;
|
||||
|
||||
return input === 'true';
|
||||
}
|
||||
|
||||
static get versioningStrategy(): string {
|
||||
return Input.getInput('versioning') ?? 'Semantic';
|
||||
}
|
||||
@@ -239,6 +236,28 @@ class Input {
|
||||
return Input.getInput('dockerWorkspacePath') ?? '/github/workspace';
|
||||
}
|
||||
|
||||
static get syncStrategy(): string {
|
||||
return Input.getInput('syncStrategy') ?? 'full';
|
||||
}
|
||||
|
||||
static get syncInputRef(): string {
|
||||
return Input.getInput('syncInputRef') ?? '';
|
||||
}
|
||||
|
||||
static get syncStorageRemote(): string {
|
||||
return Input.getInput('syncStorageRemote') ?? '';
|
||||
}
|
||||
|
||||
static get syncRevertAfter(): boolean {
|
||||
const input = Input.getInput('syncRevertAfter') ?? 'true';
|
||||
|
||||
return input === 'true';
|
||||
}
|
||||
|
||||
static get syncStatePath(): string {
|
||||
return Input.getInput('syncStatePath') ?? '.game-ci/sync-state.json';
|
||||
}
|
||||
|
||||
static get dockerCpuLimit(): string {
|
||||
return Input.getInput('dockerCpuLimit') ?? os.cpus().length.toString();
|
||||
}
|
||||
@@ -276,10 +295,356 @@ class Input {
|
||||
return Input.getInput('containerRegistryImageVersion') ?? '3';
|
||||
}
|
||||
|
||||
static get artifactOutputTypes(): string {
|
||||
return Input.getInput('artifactOutputTypes') ?? 'build,logs,test-results';
|
||||
}
|
||||
|
||||
static get artifactUploadTarget(): string {
|
||||
return Input.getInput('artifactUploadTarget') ?? 'github-artifacts';
|
||||
}
|
||||
|
||||
static get artifactUploadPath(): string {
|
||||
return Input.getInput('artifactUploadPath') ?? '';
|
||||
}
|
||||
|
||||
static get artifactCompression(): string {
|
||||
return Input.getInput('artifactCompression') ?? 'gzip';
|
||||
}
|
||||
|
||||
static get artifactRetentionDays(): string {
|
||||
return Input.getInput('artifactRetentionDays') ?? '30';
|
||||
}
|
||||
|
||||
static get artifactCustomTypes(): string {
|
||||
return Input.getInput('artifactCustomTypes') ?? '';
|
||||
}
|
||||
|
||||
static get skipActivation(): string {
|
||||
return Input.getInput('skipActivation')?.toLowerCase() ?? 'false';
|
||||
}
|
||||
|
||||
static get submoduleProfilePath(): string {
|
||||
return Input.getInput('submoduleProfilePath') ?? '';
|
||||
}
|
||||
|
||||
static get submoduleVariantPath(): string {
|
||||
return Input.getInput('submoduleVariantPath') ?? '';
|
||||
}
|
||||
|
||||
static get submoduleToken(): string {
|
||||
return Input.getInput('submoduleToken') ?? '';
|
||||
}
|
||||
|
||||
static get localCacheEnabled(): boolean {
|
||||
return (Input.getInput('localCacheEnabled') ?? 'false') === 'true';
|
||||
}
|
||||
|
||||
static get localCacheRoot(): string {
|
||||
return Input.getInput('localCacheRoot') ?? '';
|
||||
}
|
||||
|
||||
static get localCacheLibrary(): boolean {
|
||||
return (Input.getInput('localCacheLibrary') ?? 'true') === 'true';
|
||||
}
|
||||
|
||||
static get localCacheLfs(): boolean {
|
||||
return (Input.getInput('localCacheLfs') ?? 'false') === 'true';
|
||||
}
|
||||
|
||||
static get childWorkspacesEnabled(): boolean {
|
||||
return (Input.getInput('childWorkspacesEnabled') ?? 'false') === 'true';
|
||||
}
|
||||
|
||||
static get childWorkspaceName(): string {
|
||||
return Input.getInput('childWorkspaceName') ?? '';
|
||||
}
|
||||
|
||||
static get childWorkspaceCacheRoot(): string {
|
||||
return Input.getInput('childWorkspaceCacheRoot') ?? '';
|
||||
}
|
||||
|
||||
static get childWorkspacePreserveGit(): boolean {
|
||||
return (Input.getInput('childWorkspacePreserveGit') ?? 'true') === 'true';
|
||||
}
|
||||
|
||||
static get childWorkspaceSeparateLibrary(): boolean {
|
||||
return (Input.getInput('childWorkspaceSeparateLibrary') ?? 'true') === 'true';
|
||||
}
|
||||
|
||||
static get lfsTransferAgent(): string {
|
||||
return Input.getInput('lfsTransferAgent') ?? '';
|
||||
}
|
||||
|
||||
static get lfsTransferAgentArgs(): string {
|
||||
return Input.getInput('lfsTransferAgentArgs') ?? '';
|
||||
}
|
||||
|
||||
static get lfsStoragePaths(): string {
|
||||
return Input.getInput('lfsStoragePaths') ?? '';
|
||||
}
|
||||
|
||||
static get gitHooksEnabled(): boolean {
|
||||
return (Input.getInput('gitHooksEnabled') ?? 'false') === 'true';
|
||||
}
|
||||
|
||||
static get gitHooksSkipList(): string {
|
||||
return Input.getInput('gitHooksSkipList') ?? '';
|
||||
}
|
||||
|
||||
static get gitHooksRunBeforeBuild(): string {
|
||||
return Input.getInput('gitHooksRunBeforeBuild') ?? '';
|
||||
}
|
||||
|
||||
static get providerExecutable(): string {
|
||||
return Input.getInput('providerExecutable') ?? '';
|
||||
}
|
||||
|
||||
// GCP Cloud Run (Experimental)
|
||||
static get gcpProject(): string {
|
||||
return Input.getInput('gcpProject') ?? '';
|
||||
}
|
||||
|
||||
static get gcpRegion(): string {
|
||||
return Input.getInput('gcpRegion') ?? '';
|
||||
}
|
||||
|
||||
static get gcpStorageType(): string {
|
||||
return Input.getInput('gcpStorageType') ?? 'gcs-fuse';
|
||||
}
|
||||
|
||||
static get gcpBucket(): string {
|
||||
return Input.getInput('gcpBucket') ?? '';
|
||||
}
|
||||
|
||||
static get gcpFilestoreIp(): string {
|
||||
return Input.getInput('gcpFilestoreIp') ?? '';
|
||||
}
|
||||
|
||||
static get gcpFilestoreShare(): string {
|
||||
return Input.getInput('gcpFilestoreShare') ?? '/share1';
|
||||
}
|
||||
|
||||
static get gcpMachineType(): string {
|
||||
return Input.getInput('gcpMachineType') ?? 'e2-standard-4';
|
||||
}
|
||||
|
||||
static get gcpDiskSizeGb(): string {
|
||||
return Input.getInput('gcpDiskSizeGb') ?? '100';
|
||||
}
|
||||
|
||||
static get gcpServiceAccount(): string {
|
||||
return Input.getInput('gcpServiceAccount') ?? '';
|
||||
}
|
||||
|
||||
static get gcpVpcConnector(): string {
|
||||
return Input.getInput('gcpVpcConnector') ?? '';
|
||||
}
|
||||
|
||||
// Azure Container Instances (Experimental)
|
||||
static get azureResourceGroup(): string {
|
||||
return Input.getInput('azureResourceGroup') ?? '';
|
||||
}
|
||||
|
||||
static get azureLocation(): string {
|
||||
return Input.getInput('azureLocation') ?? '';
|
||||
}
|
||||
|
||||
static get azureStorageType(): string {
|
||||
return Input.getInput('azureStorageType') ?? 'azure-files';
|
||||
}
|
||||
|
||||
static get azureStorageAccount(): string {
|
||||
return Input.getInput('azureStorageAccount') ?? '';
|
||||
}
|
||||
|
||||
static get azureBlobContainer(): string {
|
||||
return Input.getInput('azureBlobContainer') ?? 'unity-builds';
|
||||
}
|
||||
|
||||
static get azureFileShareName(): string {
|
||||
return Input.getInput('azureFileShareName') ?? 'unity-builds';
|
||||
}
|
||||
|
||||
static get azureSubscriptionId(): string {
|
||||
return Input.getInput('azureSubscriptionId') ?? '';
|
||||
}
|
||||
|
||||
static get azureCpu(): string {
|
||||
return Input.getInput('azureCpu') ?? '4';
|
||||
}
|
||||
|
||||
static get azureMemoryGb(): string {
|
||||
return Input.getInput('azureMemoryGb') ?? '16';
|
||||
}
|
||||
|
||||
static get azureDiskSizeGb(): string {
|
||||
return Input.getInput('azureDiskSizeGb') ?? '100';
|
||||
}
|
||||
|
||||
static get azureSubnetId(): string {
|
||||
return Input.getInput('azureSubnetId') ?? '';
|
||||
}
|
||||
|
||||
// ### ### ###
|
||||
// Remote PowerShell provider
|
||||
// ### ### ###
|
||||
|
||||
static get remotePowershellHost(): string {
|
||||
return Input.getInput('remotePowershellHost') ?? '';
|
||||
}
|
||||
|
||||
static get remotePowershellCredential(): string {
|
||||
return Input.getInput('remotePowershellCredential') ?? '';
|
||||
}
|
||||
|
||||
static get remotePowershellTransport(): string {
|
||||
return Input.getInput('remotePowershellTransport') ?? 'wsman';
|
||||
}
|
||||
|
||||
// ### ### ###
|
||||
// GitHub Actions provider
|
||||
// ### ### ###
|
||||
|
||||
static get githubActionsRepo(): string {
|
||||
return Input.getInput('githubActionsRepo') ?? '';
|
||||
}
|
||||
|
||||
static get githubActionsWorkflow(): string {
|
||||
return Input.getInput('githubActionsWorkflow') ?? '';
|
||||
}
|
||||
|
||||
static get githubActionsToken(): string {
|
||||
return Input.getInput('githubActionsToken') ?? '';
|
||||
}
|
||||
|
||||
static get githubActionsRef(): string {
|
||||
return Input.getInput('githubActionsRef') ?? 'main';
|
||||
}
|
||||
|
||||
// ### ### ###
|
||||
// GitLab CI provider
|
||||
// ### ### ###
|
||||
|
||||
static get gitlabProjectId(): string {
|
||||
return Input.getInput('gitlabProjectId') ?? '';
|
||||
}
|
||||
|
||||
static get gitlabTriggerToken(): string {
|
||||
return Input.getInput('gitlabTriggerToken') ?? '';
|
||||
}
|
||||
|
||||
static get gitlabApiUrl(): string {
|
||||
return Input.getInput('gitlabApiUrl') ?? 'https://gitlab.com';
|
||||
}
|
||||
|
||||
static get gitlabRef(): string {
|
||||
return Input.getInput('gitlabRef') ?? 'main';
|
||||
}
|
||||
|
||||
// ### ### ###
|
||||
// Ansible provider
|
||||
// ### ### ###
|
||||
|
||||
static get ansibleInventory(): string {
|
||||
return Input.getInput('ansibleInventory') ?? '';
|
||||
}
|
||||
|
||||
static get ansiblePlaybook(): string {
|
||||
return Input.getInput('ansiblePlaybook') ?? '';
|
||||
}
|
||||
|
||||
static get ansibleExtraVars(): string {
|
||||
return Input.getInput('ansibleExtraVars') ?? '';
|
||||
}
|
||||
|
||||
static get ansibleVaultPassword(): string {
|
||||
return Input.getInput('ansibleVaultPassword') ?? '';
|
||||
}
|
||||
|
||||
static get gitIntegrityCheck(): boolean {
|
||||
const input = Input.getInput('gitIntegrityCheck') ?? 'false';
|
||||
|
||||
return input === 'true';
|
||||
}
|
||||
|
||||
static get hotRunnerEnabled(): boolean {
|
||||
const input = Input.getInput('hotRunnerEnabled') ?? false;
|
||||
|
||||
return input === 'true';
|
||||
}
|
||||
|
||||
static get gitAutoRecover(): boolean {
|
||||
const input = Input.getInput('gitAutoRecover') ?? 'false';
|
||||
|
||||
return input === 'true';
|
||||
}
|
||||
|
||||
static get hotRunnerTransport(): 'websocket' | 'grpc' | 'named-pipe' {
|
||||
return (Input.getInput('hotRunnerTransport') ?? 'websocket') as 'websocket' | 'grpc' | 'named-pipe';
|
||||
}
|
||||
|
||||
static get hotRunnerHost(): string {
|
||||
return Input.getInput('hotRunnerHost') ?? 'localhost';
|
||||
}
|
||||
|
||||
static get hotRunnerPort(): number {
|
||||
return Number.parseInt(Input.getInput('hotRunnerPort') ?? '9090', 10);
|
||||
}
|
||||
|
||||
static get hotRunnerHealthInterval(): number {
|
||||
return Number.parseInt(Input.getInput('hotRunnerHealthInterval') ?? '30', 10);
|
||||
}
|
||||
|
||||
static get hotRunnerMaxIdle(): number {
|
||||
return Number.parseInt(Input.getInput('hotRunnerMaxIdle') ?? '3600', 10);
|
||||
}
|
||||
|
||||
static get hotRunnerFallbackToCold(): boolean {
|
||||
const input = Input.getInput('hotRunnerFallbackToCold') ?? 'true';
|
||||
|
||||
return input === 'true';
|
||||
}
|
||||
|
||||
static get cleanReservedFilenames(): boolean {
|
||||
const input = Input.getInput('cleanReservedFilenames') ?? 'false';
|
||||
|
||||
return input === 'true';
|
||||
}
|
||||
|
||||
static get buildArchiveEnabled(): boolean {
|
||||
const input = Input.getInput('buildArchiveEnabled') ?? 'false';
|
||||
|
||||
return input === 'true';
|
||||
}
|
||||
|
||||
static get buildArchivePath(): string {
|
||||
return Input.getInput('buildArchivePath') ?? './build-archives';
|
||||
}
|
||||
|
||||
static get buildArchiveRetention(): number {
|
||||
return Number.parseInt(Input.getInput('buildArchiveRetention') ?? '30', 10);
|
||||
}
|
||||
|
||||
static get testSuitePath(): string {
|
||||
return Input.getInput('testSuitePath') ?? '';
|
||||
}
|
||||
|
||||
static get testSuiteEvent(): string {
|
||||
return Input.getInput('testSuiteEvent') ?? '';
|
||||
}
|
||||
|
||||
static get testTaxonomyPath(): string {
|
||||
return Input.getInput('testTaxonomyPath') ?? '';
|
||||
}
|
||||
|
||||
static get testResultFormat(): string {
|
||||
return Input.getInput('testResultFormat') ?? 'junit';
|
||||
}
|
||||
|
||||
static get testResultPath(): string {
|
||||
return Input.getInput('testResultPath') ?? './test-results';
|
||||
}
|
||||
|
||||
public static ToEnvVarFormat(input: string) {
|
||||
if (input.toUpperCase() === input) {
|
||||
return input;
|
||||
|
||||
@@ -1,38 +1,55 @@
|
||||
/**
|
||||
* Tests for the orchestrator plugin loader (orchestrator-plugin.ts).
|
||||
* Tests for the orchestrator plugin interface (orchestrator-plugin.ts).
|
||||
*
|
||||
* The plugin loader dynamically imports @game-ci/orchestrator and calls
|
||||
* createPlugin(). Two scenarios:
|
||||
* The plugin acts as a dynamic bridge to @game-ci/orchestrator, which is an
|
||||
* optional dependency. Two scenarios exist:
|
||||
*
|
||||
* 1. Package NOT installed — loadOrchestratorPlugin() returns undefined.
|
||||
* 2. Package IS installed — returns the plugin from createPlugin().
|
||||
* 1. Package NOT installed (the natural state in unity-builder) -- both
|
||||
* loadOrchestrator() and loadPluginServices() must degrade gracefully.
|
||||
*
|
||||
* 2. Package IS installed (mocked) -- the returned wrappers must faithfully
|
||||
* forward calls and map results.
|
||||
*/
|
||||
|
||||
// Mock @actions/core so we can inspect core.warning calls even after
|
||||
// jest.resetModules() re-imports orchestrator-plugin (which statically
|
||||
// imports @actions/core at the top level).
|
||||
const mockWarning = jest.fn();
|
||||
const mockInfo = jest.fn();
|
||||
jest.mock('@actions/core', () => ({
|
||||
warning: mockWarning,
|
||||
info: mockInfo,
|
||||
}));
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Setup
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
mockWarning.mockClear();
|
||||
mockInfo.mockClear();
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Part 1: Package NOT installed
|
||||
// Part 1: Package NOT installed (natural state)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
describe('orchestrator-plugin (package not installed)', () => {
|
||||
it('loadOrchestratorPlugin() returns undefined', async () => {
|
||||
const { loadOrchestratorPlugin } = await import('./orchestrator-plugin');
|
||||
it('loadOrchestrator() returns undefined', async () => {
|
||||
const { loadOrchestrator } = await import('./orchestrator-plugin');
|
||||
|
||||
const result = await loadOrchestratorPlugin();
|
||||
const result = await loadOrchestrator();
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it('loadPluginServices() returns undefined and logs a warning', async () => {
|
||||
const { loadPluginServices } = await import('./orchestrator-plugin');
|
||||
|
||||
const result = await loadPluginServices();
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
expect(mockWarning).toHaveBeenCalledTimes(1);
|
||||
expect(mockWarning).toHaveBeenCalledWith(expect.stringContaining('Orchestrator plugin not available'));
|
||||
});
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -40,22 +57,47 @@ describe('orchestrator-plugin (package not installed)', () => {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
describe('orchestrator-plugin (package installed)', () => {
|
||||
const fakePlugin = {
|
||||
initialize: jest.fn(),
|
||||
canHandleBuild: jest.fn().mockReturnValue(false),
|
||||
handleBuild: jest.fn().mockResolvedValue({ exitCode: 0 }),
|
||||
beforeLocalBuild: jest.fn(),
|
||||
afterLocalBuild: jest.fn(),
|
||||
handlePostBuild: jest.fn(),
|
||||
};
|
||||
// Fake service sentinels -- unique objects so we can assert identity.
|
||||
const fakeBuildReliabilityService = { _id: 'BuildReliabilityService' };
|
||||
const fakeTestWorkflowService = { _id: 'TestWorkflowService' };
|
||||
const fakeHotRunnerService = { _id: 'HotRunnerService' };
|
||||
const fakeOutputService = { _id: 'OutputService' };
|
||||
const fakeOutputTypeRegistry = { _id: 'OutputTypeRegistry' };
|
||||
const fakeArtifactUploadHandler = { _id: 'ArtifactUploadHandler' };
|
||||
const fakeIncrementalSyncService = { _id: 'IncrementalSyncService' };
|
||||
const fakeChildWorkspaceService = { _id: 'ChildWorkspaceService' };
|
||||
const fakeLocalCacheService = { _id: 'LocalCacheService' };
|
||||
const fakeSubmoduleProfileService = { _id: 'SubmoduleProfileService' };
|
||||
const fakeLfsAgentService = { _id: 'LfsAgentService' };
|
||||
const fakeGitHooksService = { _id: 'GitHooksService' };
|
||||
|
||||
const mockCreatePlugin = jest.fn().mockReturnValue(fakePlugin);
|
||||
const mockOrchestratorRun = jest.fn();
|
||||
|
||||
/**
|
||||
* Install the mock BEFORE importing orchestrator-plugin so that the dynamic
|
||||
* import('@game-ci/orchestrator') inside loadOrchestrator / loadPluginServices
|
||||
* resolves to our fake module.
|
||||
*
|
||||
* The { virtual: true } flag is required because @game-ci/orchestrator is
|
||||
* not physically installed in unity-builder's node_modules.
|
||||
*/
|
||||
function installOrchestratorMock(overrides: Record<string, unknown> = {}) {
|
||||
jest.doMock(
|
||||
'@game-ci/orchestrator',
|
||||
() => ({
|
||||
createPlugin: mockCreatePlugin,
|
||||
Orchestrator: { run: mockOrchestratorRun },
|
||||
BuildReliabilityService: fakeBuildReliabilityService,
|
||||
TestWorkflowService: fakeTestWorkflowService,
|
||||
HotRunnerService: fakeHotRunnerService,
|
||||
OutputService: fakeOutputService,
|
||||
OutputTypeRegistry: fakeOutputTypeRegistry,
|
||||
ArtifactUploadHandler: fakeArtifactUploadHandler,
|
||||
IncrementalSyncService: fakeIncrementalSyncService,
|
||||
ChildWorkspaceService: fakeChildWorkspaceService,
|
||||
LocalCacheService: fakeLocalCacheService,
|
||||
SubmoduleProfileService: fakeSubmoduleProfileService,
|
||||
LfsAgentService: fakeLfsAgentService,
|
||||
GitHooksService: fakeGitHooksService,
|
||||
...overrides,
|
||||
}),
|
||||
{ virtual: true },
|
||||
@@ -63,48 +105,148 @@ describe('orchestrator-plugin (package installed)', () => {
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
mockCreatePlugin.mockClear();
|
||||
fakePlugin.initialize.mockClear();
|
||||
fakePlugin.canHandleBuild.mockClear();
|
||||
fakePlugin.handleBuild.mockClear();
|
||||
fakePlugin.beforeLocalBuild.mockClear();
|
||||
fakePlugin.afterLocalBuild.mockClear();
|
||||
fakePlugin.handlePostBuild.mockClear();
|
||||
mockOrchestratorRun.mockReset();
|
||||
});
|
||||
|
||||
it('returns the plugin from createPlugin()', async () => {
|
||||
installOrchestratorMock();
|
||||
const { loadOrchestratorPlugin } = await import('./orchestrator-plugin');
|
||||
// -----------------------------------------------------------------------
|
||||
// loadOrchestrator()
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
const plugin = await loadOrchestratorPlugin();
|
||||
describe('loadOrchestrator()', () => {
|
||||
it('returns an object with a run function', async () => {
|
||||
installOrchestratorMock();
|
||||
const { loadOrchestrator } = await import('./orchestrator-plugin');
|
||||
|
||||
expect(plugin).toBeDefined();
|
||||
expect(mockCreatePlugin).toHaveBeenCalledTimes(1);
|
||||
expect(plugin).toBe(fakePlugin);
|
||||
const orchestrator = await loadOrchestrator();
|
||||
|
||||
expect(orchestrator).toBeDefined();
|
||||
expect(typeof orchestrator!.run).toBe('function');
|
||||
});
|
||||
|
||||
it('run() maps BuildSucceeded=true to exitCode=0', async () => {
|
||||
mockOrchestratorRun.mockResolvedValue({ BuildSucceeded: true, BuildResults: 'ok' });
|
||||
installOrchestratorMock();
|
||||
const { loadOrchestrator } = await import('./orchestrator-plugin');
|
||||
|
||||
const orchestrator = await loadOrchestrator();
|
||||
const result = await orchestrator!.run({}, 'ubuntu:latest');
|
||||
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.BuildSucceeded).toBe(true);
|
||||
});
|
||||
|
||||
it('run() maps BuildSucceeded=false to exitCode=1', async () => {
|
||||
mockOrchestratorRun.mockResolvedValue({ BuildSucceeded: false, BuildResults: 'fail' });
|
||||
installOrchestratorMock();
|
||||
const { loadOrchestrator } = await import('./orchestrator-plugin');
|
||||
|
||||
const orchestrator = await loadOrchestrator();
|
||||
const result = await orchestrator!.run({}, 'ubuntu:latest');
|
||||
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.BuildSucceeded).toBe(false);
|
||||
});
|
||||
|
||||
it('run() passes buildParameters and baseImage to Orchestrator.run', async () => {
|
||||
const buildParameters = { targetPlatform: 'StandaloneLinux64', editorVersion: '2021.3.1f1' };
|
||||
const baseImage = 'unityci/editor:2021.3.1f1-linux-il2cpp-1';
|
||||
|
||||
mockOrchestratorRun.mockResolvedValue({ BuildSucceeded: true, BuildResults: '' });
|
||||
installOrchestratorMock();
|
||||
const { loadOrchestrator } = await import('./orchestrator-plugin');
|
||||
|
||||
const orchestrator = await loadOrchestrator();
|
||||
await orchestrator!.run(buildParameters, baseImage);
|
||||
|
||||
expect(mockOrchestratorRun).toHaveBeenCalledTimes(1);
|
||||
expect(mockOrchestratorRun).toHaveBeenCalledWith(buildParameters, baseImage);
|
||||
});
|
||||
});
|
||||
|
||||
it('returns the plugin with all lifecycle methods', async () => {
|
||||
installOrchestratorMock();
|
||||
const { loadOrchestratorPlugin } = await import('./orchestrator-plugin');
|
||||
// -----------------------------------------------------------------------
|
||||
// loadPluginServices()
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
const plugin = await loadOrchestratorPlugin();
|
||||
describe('loadPluginServices()', () => {
|
||||
it('returns all 7 eager services', async () => {
|
||||
installOrchestratorMock();
|
||||
const { loadPluginServices } = await import('./orchestrator-plugin');
|
||||
|
||||
expect(typeof plugin!.initialize).toBe('function');
|
||||
expect(typeof plugin!.canHandleBuild).toBe('function');
|
||||
expect(typeof plugin!.handleBuild).toBe('function');
|
||||
expect(typeof plugin!.beforeLocalBuild).toBe('function');
|
||||
expect(typeof plugin!.afterLocalBuild).toBe('function');
|
||||
expect(typeof plugin!.handlePostBuild).toBe('function');
|
||||
});
|
||||
const services = await loadPluginServices();
|
||||
|
||||
it('returns undefined and warns when createPlugin is not a function', async () => {
|
||||
installOrchestratorMock({ createPlugin: undefined });
|
||||
const { loadOrchestratorPlugin } = await import('./orchestrator-plugin');
|
||||
expect(services).toBeDefined();
|
||||
expect(services!.BuildReliabilityService).toBe(fakeBuildReliabilityService);
|
||||
expect(services!.TestWorkflowService).toBe(fakeTestWorkflowService);
|
||||
expect(services!.HotRunnerService).toBe(fakeHotRunnerService);
|
||||
expect(services!.OutputService).toBe(fakeOutputService);
|
||||
expect(services!.OutputTypeRegistry).toBe(fakeOutputTypeRegistry);
|
||||
expect(services!.ArtifactUploadHandler).toBe(fakeArtifactUploadHandler);
|
||||
expect(services!.IncrementalSyncService).toBe(fakeIncrementalSyncService);
|
||||
});
|
||||
|
||||
const plugin = await loadOrchestratorPlugin();
|
||||
it('returns all 5 lazy loader functions', async () => {
|
||||
installOrchestratorMock();
|
||||
const { loadPluginServices } = await import('./orchestrator-plugin');
|
||||
|
||||
expect(plugin).toBeUndefined();
|
||||
expect(mockWarning).toHaveBeenCalledWith(expect.stringContaining('does not export createPlugin'));
|
||||
const services = await loadPluginServices();
|
||||
|
||||
expect(services).toBeDefined();
|
||||
expect(typeof services!.loadChildWorkspaceService).toBe('function');
|
||||
expect(typeof services!.loadLocalCacheService).toBe('function');
|
||||
expect(typeof services!.loadSubmoduleProfileService).toBe('function');
|
||||
expect(typeof services!.loadLfsAgentService).toBe('function');
|
||||
expect(typeof services!.loadGitHooksService).toBe('function');
|
||||
});
|
||||
|
||||
it('loadChildWorkspaceService() returns the correct service', async () => {
|
||||
installOrchestratorMock();
|
||||
const { loadPluginServices } = await import('./orchestrator-plugin');
|
||||
|
||||
const services = await loadPluginServices();
|
||||
const service = await services!.loadChildWorkspaceService();
|
||||
|
||||
expect(service).toBe(fakeChildWorkspaceService);
|
||||
});
|
||||
|
||||
it('loadLocalCacheService() returns the correct service', async () => {
|
||||
installOrchestratorMock();
|
||||
const { loadPluginServices } = await import('./orchestrator-plugin');
|
||||
|
||||
const services = await loadPluginServices();
|
||||
const service = await services!.loadLocalCacheService();
|
||||
|
||||
expect(service).toBe(fakeLocalCacheService);
|
||||
});
|
||||
|
||||
it('loadSubmoduleProfileService() returns the correct service', async () => {
|
||||
installOrchestratorMock();
|
||||
const { loadPluginServices } = await import('./orchestrator-plugin');
|
||||
|
||||
const services = await loadPluginServices();
|
||||
const service = await services!.loadSubmoduleProfileService();
|
||||
|
||||
expect(service).toBe(fakeSubmoduleProfileService);
|
||||
});
|
||||
|
||||
it('loadLfsAgentService() returns the correct service', async () => {
|
||||
installOrchestratorMock();
|
||||
const { loadPluginServices } = await import('./orchestrator-plugin');
|
||||
|
||||
const services = await loadPluginServices();
|
||||
const service = await services!.loadLfsAgentService();
|
||||
|
||||
expect(service).toBe(fakeLfsAgentService);
|
||||
});
|
||||
|
||||
it('loadGitHooksService() returns the correct service', async () => {
|
||||
installOrchestratorMock();
|
||||
const { loadPluginServices } = await import('./orchestrator-plugin');
|
||||
|
||||
const services = await loadPluginServices();
|
||||
const service = await services!.loadGitHooksService();
|
||||
|
||||
expect(service).toBe(fakeGitHooksService);
|
||||
});
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -112,18 +254,32 @@ describe('orchestrator-plugin (package installed)', () => {
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
describe('error handling', () => {
|
||||
it('propagates non-MODULE_NOT_FOUND errors', async () => {
|
||||
const importError = new Error('Syntax error in module');
|
||||
jest.doMock(
|
||||
'@game-ci/orchestrator',
|
||||
() => {
|
||||
throw importError;
|
||||
},
|
||||
{ virtual: true },
|
||||
);
|
||||
const { loadOrchestratorPlugin } = await import('./orchestrator-plugin');
|
||||
it('propagates errors thrown by Orchestrator.run()', async () => {
|
||||
const orchestratorError = new Error('Build infrastructure failure');
|
||||
mockOrchestratorRun.mockRejectedValue(orchestratorError);
|
||||
installOrchestratorMock();
|
||||
const { loadOrchestrator } = await import('./orchestrator-plugin');
|
||||
|
||||
await expect(loadOrchestratorPlugin()).rejects.toThrow('Syntax error in module');
|
||||
const orchestrator = await loadOrchestrator();
|
||||
|
||||
await expect(orchestrator!.run({}, 'ubuntu:latest')).rejects.toThrow('Build infrastructure failure');
|
||||
});
|
||||
|
||||
it('returns undefined services as-is when a service export is undefined', async () => {
|
||||
installOrchestratorMock({
|
||||
BuildReliabilityService: undefined,
|
||||
ChildWorkspaceService: undefined,
|
||||
});
|
||||
const { loadPluginServices } = await import('./orchestrator-plugin');
|
||||
|
||||
const services = await loadPluginServices();
|
||||
|
||||
expect(services).toBeDefined();
|
||||
expect(services!.BuildReliabilityService).toBeUndefined();
|
||||
|
||||
// The lazy loader still works -- it just returns undefined
|
||||
const childService = await services!.loadChildWorkspaceService();
|
||||
expect(childService).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,59 +1,35 @@
|
||||
import * as core from '@actions/core';
|
||||
|
||||
/**
|
||||
* Lifecycle interface for the orchestrator plugin.
|
||||
*
|
||||
* The orchestrator reads its own configuration from environment variables
|
||||
* and GitHub Actions inputs. Unity-builder only calls these lifecycle hooks
|
||||
* at the appropriate times — it never needs to know individual plugin params.
|
||||
*/
|
||||
export interface OrchestratorPlugin {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
initialize(coreParameters: Record<string, any>, workspace: string): Promise<void>;
|
||||
|
||||
/** Whether the plugin wants to handle the entire build (remote, hot runner, test workflow). */
|
||||
canHandleBuild(): boolean;
|
||||
|
||||
/**
|
||||
* Execute the build when canHandleBuild() returns true.
|
||||
* If the plugin needs to fall back to a local build (e.g. hot runner failure),
|
||||
* it returns { exitCode: -1, fallbackToLocal: true }.
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
handleBuild(baseImage: string): Promise<{ exitCode: number; fallbackToLocal?: boolean }>;
|
||||
|
||||
/** Pre-build hook for local builds (cache restore, git hooks, sync, etc.). */
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
beforeLocalBuild(workspace: string): Promise<void>;
|
||||
|
||||
/** Post-build hook for local builds (cache save, workspace save, etc.). */
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
afterLocalBuild(workspace: string, exitCode: number): Promise<void>;
|
||||
|
||||
/** Post-build hook for all build types (archiving, artifacts, etc.). */
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
handlePostBuild(exitCode: number): Promise<void>;
|
||||
export interface OrchestratorPluginResult {
|
||||
exitCode: number;
|
||||
BuildSucceeded: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to load the orchestrator plugin.
|
||||
* Returns undefined if @game-ci/orchestrator is not installed.
|
||||
* Load the orchestrator for remote builds.
|
||||
* Returns undefined if orchestrator is not available.
|
||||
*/
|
||||
export async function loadOrchestratorPlugin(): Promise<OrchestratorPlugin | undefined> {
|
||||
export async function loadOrchestrator(): Promise<
|
||||
| {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
run: (buildParameters: any, baseImage: string) => Promise<OrchestratorPluginResult>;
|
||||
}
|
||||
| undefined
|
||||
> {
|
||||
try {
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
const orchestratorModule = await import('@game-ci/orchestrator');
|
||||
const { Orchestrator } = await import('@game-ci/orchestrator');
|
||||
|
||||
if (typeof orchestratorModule.createPlugin !== 'function') {
|
||||
core.warning(
|
||||
'Orchestrator package found but does not export createPlugin(). ' +
|
||||
'Update @game-ci/orchestrator to the latest version.',
|
||||
);
|
||||
return {
|
||||
run: async (buildParameters: any, baseImage: string): Promise<OrchestratorPluginResult> => {
|
||||
const result = await Orchestrator.run(buildParameters, baseImage);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return orchestratorModule.createPlugin();
|
||||
return {
|
||||
exitCode: result.BuildSucceeded ? 0 : 1,
|
||||
BuildSucceeded: result.BuildSucceeded,
|
||||
};
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
if (!isModuleNotFoundError(error)) {
|
||||
throw error;
|
||||
@@ -61,6 +37,54 @@ export async function loadOrchestratorPlugin(): Promise<OrchestratorPlugin | und
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load orchestrator plugin services for local builds.
|
||||
* These services are part of the orchestrator but also used in local builds
|
||||
* (child workspaces, local cache, git hooks, LFS agents, etc.).
|
||||
*/
|
||||
export async function loadPluginServices() {
|
||||
try {
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
const orchestrator = await import('@game-ci/orchestrator');
|
||||
|
||||
return {
|
||||
BuildReliabilityService: orchestrator.BuildReliabilityService,
|
||||
TestWorkflowService: orchestrator.TestWorkflowService,
|
||||
HotRunnerService: orchestrator.HotRunnerService,
|
||||
OutputService: orchestrator.OutputService,
|
||||
OutputTypeRegistry: orchestrator.OutputTypeRegistry,
|
||||
ArtifactUploadHandler: orchestrator.ArtifactUploadHandler,
|
||||
IncrementalSyncService: orchestrator.IncrementalSyncService,
|
||||
|
||||
// Lazy-loaded services (only imported when needed)
|
||||
async loadChildWorkspaceService() {
|
||||
return orchestrator.ChildWorkspaceService;
|
||||
},
|
||||
|
||||
async loadLocalCacheService() {
|
||||
return orchestrator.LocalCacheService;
|
||||
},
|
||||
|
||||
async loadSubmoduleProfileService() {
|
||||
return orchestrator.SubmoduleProfileService;
|
||||
},
|
||||
|
||||
async loadLfsAgentService() {
|
||||
return orchestrator.LfsAgentService;
|
||||
},
|
||||
|
||||
async loadGitHooksService() {
|
||||
return orchestrator.GitHooksService;
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
if (!isModuleNotFoundError(error)) {
|
||||
throw error;
|
||||
}
|
||||
core.warning(`Orchestrator plugin not available: ${(error as Error).message}`);
|
||||
}
|
||||
}
|
||||
|
||||
function isModuleNotFoundError(error: unknown): boolean {
|
||||
if (error && typeof error === 'object' && 'code' in error) {
|
||||
const code = (error as { code: string }).code;
|
||||
|
||||
509
src/model/plugin-inputs.test.ts
Normal file
509
src/model/plugin-inputs.test.ts
Normal file
@@ -0,0 +1,509 @@
|
||||
/**
|
||||
* Tests for plugin input properties and their wiring into BuildParameters.
|
||||
*
|
||||
* Covers all 20 new input properties added for plugin features:
|
||||
* - Boolean inputs: localCacheEnabled, childWorkspacesEnabled, gitHooksEnabled,
|
||||
* localCacheLibrary, localCacheLfs, childWorkspacePreserveGit, childWorkspaceSeparateLibrary
|
||||
* - String inputs: submoduleProfilePath, submoduleVariantPath, submoduleToken,
|
||||
* localCacheRoot, childWorkspaceName, childWorkspaceCacheRoot, lfsTransferAgent,
|
||||
* lfsTransferAgentArgs, lfsStoragePaths, providerExecutable, gitHooksSkipList,
|
||||
* gitHooksRunBeforeBuild
|
||||
*
|
||||
* Special attention to boolean inputs: GitHub Actions always passes inputs as strings,
|
||||
* so 'false' must NOT evaluate as truthy (the #1 source of bugs).
|
||||
*/
|
||||
|
||||
import * as core from '@actions/core';
|
||||
import Input from './input';
|
||||
import Versioning from './versioning';
|
||||
import BuildParameters from './build-parameters';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Setup
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
afterEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Part 1: Input getters — defaults and explicit values
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
describe('Plugin Input properties', () => {
|
||||
// -----------------------------------------------------------------------
|
||||
// Boolean inputs — default and string parsing
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
describe('localCacheEnabled', () => {
|
||||
it('returns false by default', () => {
|
||||
expect(Input.localCacheEnabled).toBe(false);
|
||||
});
|
||||
|
||||
it('returns true when string "true" is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('true');
|
||||
expect(Input.localCacheEnabled).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false when string "false" is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('false');
|
||||
expect(Input.localCacheEnabled).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false when empty string is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('');
|
||||
expect(Input.localCacheEnabled).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('localCacheLibrary', () => {
|
||||
it('returns true by default (library caching on by default when cache enabled)', () => {
|
||||
expect(Input.localCacheLibrary).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true when string "true" is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('true');
|
||||
expect(Input.localCacheLibrary).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false when string "false" is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('false');
|
||||
expect(Input.localCacheLibrary).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('localCacheLfs', () => {
|
||||
it('returns false by default', () => {
|
||||
expect(Input.localCacheLfs).toBe(false);
|
||||
});
|
||||
|
||||
it('returns true when string "true" is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('true');
|
||||
expect(Input.localCacheLfs).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false when string "false" is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('false');
|
||||
expect(Input.localCacheLfs).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('childWorkspacesEnabled', () => {
|
||||
it('returns false by default', () => {
|
||||
expect(Input.childWorkspacesEnabled).toBe(false);
|
||||
});
|
||||
|
||||
it('returns true when string "true" is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('true');
|
||||
expect(Input.childWorkspacesEnabled).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false when string "false" is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('false');
|
||||
expect(Input.childWorkspacesEnabled).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false when empty string is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('');
|
||||
expect(Input.childWorkspacesEnabled).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('childWorkspacePreserveGit', () => {
|
||||
it('returns true by default', () => {
|
||||
expect(Input.childWorkspacePreserveGit).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false when string "false" is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('false');
|
||||
expect(Input.childWorkspacePreserveGit).toBe(false);
|
||||
});
|
||||
|
||||
it('returns true when string "true" is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('true');
|
||||
expect(Input.childWorkspacePreserveGit).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('childWorkspaceSeparateLibrary', () => {
|
||||
it('returns true by default', () => {
|
||||
expect(Input.childWorkspaceSeparateLibrary).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false when string "false" is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('false');
|
||||
expect(Input.childWorkspaceSeparateLibrary).toBe(false);
|
||||
});
|
||||
|
||||
it('returns true when string "true" is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('true');
|
||||
expect(Input.childWorkspaceSeparateLibrary).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('gitHooksEnabled', () => {
|
||||
it('returns false by default', () => {
|
||||
expect(Input.gitHooksEnabled).toBe(false);
|
||||
});
|
||||
|
||||
it('returns true when string "true" is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('true');
|
||||
expect(Input.gitHooksEnabled).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false when string "false" is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('false');
|
||||
expect(Input.gitHooksEnabled).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false when empty string is passed', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('');
|
||||
expect(Input.gitHooksEnabled).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Boolean truthiness edge cases — the #1 source of bugs
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
describe('boolean input string handling (edge cases)', () => {
|
||||
// These tests verify that the === 'true' comparison is correct.
|
||||
// In JavaScript, 'false' is truthy when used in a boolean context,
|
||||
// but the Input class correctly uses === 'true' comparison.
|
||||
|
||||
const booleanInputs: Array<{
|
||||
name: string;
|
||||
getter: () => boolean;
|
||||
defaultValue: boolean;
|
||||
}> = [
|
||||
{ name: 'localCacheEnabled', getter: () => Input.localCacheEnabled, defaultValue: false },
|
||||
{ name: 'localCacheLfs', getter: () => Input.localCacheLfs, defaultValue: false },
|
||||
{ name: 'childWorkspacesEnabled', getter: () => Input.childWorkspacesEnabled, defaultValue: false },
|
||||
{ name: 'gitHooksEnabled', getter: () => Input.gitHooksEnabled, defaultValue: false },
|
||||
|
||||
// These default to true:
|
||||
{ name: 'localCacheLibrary', getter: () => Input.localCacheLibrary, defaultValue: true },
|
||||
{ name: 'childWorkspacePreserveGit', getter: () => Input.childWorkspacePreserveGit, defaultValue: true },
|
||||
{ name: 'childWorkspaceSeparateLibrary', getter: () => Input.childWorkspaceSeparateLibrary, defaultValue: true },
|
||||
];
|
||||
|
||||
test.each(booleanInputs)('$name: "false" string does NOT evaluate as truthy', ({ getter }) => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('false');
|
||||
expect(getter()).toBe(false);
|
||||
});
|
||||
|
||||
test.each(booleanInputs)('$name: "true" string evaluates as truthy', ({ getter }) => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('true');
|
||||
expect(getter()).toBe(true);
|
||||
});
|
||||
|
||||
test.each(booleanInputs)('$name: "TRUE" (uppercase) does NOT evaluate as true (case sensitive)', ({ getter }) => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('TRUE');
|
||||
expect(getter()).toBe(false);
|
||||
});
|
||||
|
||||
test.each(booleanInputs)('$name: "1" does NOT evaluate as true', ({ getter }) => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('1');
|
||||
expect(getter()).toBe(false);
|
||||
});
|
||||
|
||||
test.each(booleanInputs)('$name: "yes" does NOT evaluate as true', ({ getter }) => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('yes');
|
||||
expect(getter()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// String inputs — defaults and explicit values
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
describe('submoduleProfilePath', () => {
|
||||
it('returns empty string by default', () => {
|
||||
expect(Input.submoduleProfilePath).toBe('');
|
||||
});
|
||||
|
||||
it('takes input from workflow', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('config/submodule-profiles/tow/ec/profile.yml');
|
||||
expect(Input.submoduleProfilePath).toBe('config/submodule-profiles/tow/ec/profile.yml');
|
||||
});
|
||||
});
|
||||
|
||||
describe('submoduleVariantPath', () => {
|
||||
it('returns empty string by default', () => {
|
||||
expect(Input.submoduleVariantPath).toBe('');
|
||||
});
|
||||
|
||||
it('takes input from workflow', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('config/submodule-profiles/tow/ec/server.yml');
|
||||
expect(Input.submoduleVariantPath).toBe('config/submodule-profiles/tow/ec/server.yml');
|
||||
});
|
||||
});
|
||||
|
||||
describe('submoduleToken', () => {
|
||||
it('returns empty string by default', () => {
|
||||
expect(Input.submoduleToken).toBe('');
|
||||
});
|
||||
|
||||
it('takes input from workflow', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('ghp_abc123');
|
||||
expect(Input.submoduleToken).toBe('ghp_abc123');
|
||||
});
|
||||
});
|
||||
|
||||
describe('localCacheRoot', () => {
|
||||
it('returns empty string by default', () => {
|
||||
expect(Input.localCacheRoot).toBe('');
|
||||
});
|
||||
|
||||
it('takes input from workflow', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('/d/cache/game-ci');
|
||||
expect(Input.localCacheRoot).toBe('/d/cache/game-ci');
|
||||
});
|
||||
});
|
||||
|
||||
describe('childWorkspaceName', () => {
|
||||
it('returns empty string by default', () => {
|
||||
expect(Input.childWorkspaceName).toBe('');
|
||||
});
|
||||
|
||||
it('takes input from workflow', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('TurnOfWarEndlessCrusade');
|
||||
expect(Input.childWorkspaceName).toBe('TurnOfWarEndlessCrusade');
|
||||
});
|
||||
});
|
||||
|
||||
describe('childWorkspaceCacheRoot', () => {
|
||||
it('returns empty string by default', () => {
|
||||
expect(Input.childWorkspaceCacheRoot).toBe('');
|
||||
});
|
||||
|
||||
it('takes input from workflow', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('/d/workspaces');
|
||||
expect(Input.childWorkspaceCacheRoot).toBe('/d/workspaces');
|
||||
});
|
||||
});
|
||||
|
||||
describe('lfsTransferAgent', () => {
|
||||
it('returns empty string by default', () => {
|
||||
expect(Input.lfsTransferAgent).toBe('');
|
||||
});
|
||||
|
||||
it('takes input from workflow', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('/tools/elastic-git-storage');
|
||||
expect(Input.lfsTransferAgent).toBe('/tools/elastic-git-storage');
|
||||
});
|
||||
});
|
||||
|
||||
describe('lfsTransferAgentArgs', () => {
|
||||
it('returns empty string by default', () => {
|
||||
expect(Input.lfsTransferAgentArgs).toBe('');
|
||||
});
|
||||
|
||||
it('takes input from workflow', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('--verbose --timeout=60');
|
||||
expect(Input.lfsTransferAgentArgs).toBe('--verbose --timeout=60');
|
||||
});
|
||||
});
|
||||
|
||||
describe('lfsStoragePaths', () => {
|
||||
it('returns empty string by default', () => {
|
||||
expect(Input.lfsStoragePaths).toBe('');
|
||||
});
|
||||
|
||||
it('takes input from workflow', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('/storage/primary;/storage/secondary');
|
||||
expect(Input.lfsStoragePaths).toBe('/storage/primary;/storage/secondary');
|
||||
});
|
||||
});
|
||||
|
||||
describe('providerExecutable', () => {
|
||||
it('returns empty string by default', () => {
|
||||
expect(Input.providerExecutable).toBe('');
|
||||
});
|
||||
|
||||
it('takes input from workflow', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('/usr/local/bin/custom-provider');
|
||||
expect(Input.providerExecutable).toBe('/usr/local/bin/custom-provider');
|
||||
});
|
||||
});
|
||||
|
||||
describe('gitHooksSkipList', () => {
|
||||
it('returns empty string by default', () => {
|
||||
expect(Input.gitHooksSkipList).toBe('');
|
||||
});
|
||||
|
||||
it('takes input from workflow', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('pre-commit,pre-push');
|
||||
expect(Input.gitHooksSkipList).toBe('pre-commit,pre-push');
|
||||
});
|
||||
});
|
||||
|
||||
describe('gitHooksRunBeforeBuild', () => {
|
||||
it('returns empty string by default', () => {
|
||||
expect(Input.gitHooksRunBeforeBuild).toBe('');
|
||||
});
|
||||
|
||||
it('takes input from workflow', () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('pre-commit');
|
||||
expect(Input.gitHooksRunBeforeBuild).toBe('pre-commit');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Part 2: BuildParameters.create() maps new inputs to properties
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const testLicense =
|
||||
'<?xml version="1.0" encoding="UTF-8"?><root>\n <License id="Terms">\n <MachineBindings>\n <Binding Key="1" Value="576562626572264761624c65526f7578"/>\n <Binding Key="2" Value="576562626572264761624c65526f7578"/>\n </MachineBindings>\n <MachineID Value="D7nTUnjNAmtsUMcnoyrqkgIbYdM="/>\n <SerialHash Value="2033b8ac3e6faa3742ca9f0bfae44d18f2a96b80"/>\n <Features>\n <Feature Value="33"/>\n <Feature Value="1"/>\n <Feature Value="12"/>\n <Feature Value="2"/>\n <Feature Value="24"/>\n <Feature Value="3"/>\n <Feature Value="36"/>\n <Feature Value="17"/>\n <Feature Value="19"/>\n <Feature Value="62"/>\n </Features>\n <DeveloperData Value="AQAAAEY0LUJHUlgtWEQ0RS1aQ1dWLUM1SlctR0RIQg=="/>\n <SerialMasked Value="F4-BGRX-XD4E-ZCWV-C5JW-XXXX"/>\n <StartDate Value="2021-02-08T00:00:00"/>\n <UpdateDate Value="2021-02-09T00:34:57"/>\n <InitialActivationDate Value="2021-02-08T00:34:56"/>\n <LicenseVersion Value="6.x"/>\n <ClientProvidedVersion Value="2018.4.30f1"/>\n <AlwaysOnline Value="false"/>\n <Entitlements>\n <Entitlement Ns="unity_editor" Tag="UnityPersonal" Type="EDITOR" ValidTo="9999-12-31T00:00:00"/>\n <Entitlement Ns="unity_editor" Tag="DarkSkin" Type="EDITOR_FEATURE" ValidTo="9999-12-31T00:00:00"/>\n </Entitlements>\n </License>\n<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"/><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><Reference URI="#Terms"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>m0Db8UK+ktnOLJBtHybkfetpcKo=</DigestValue></Reference></SignedInfo><SignatureValue>o/pUbSQAukz7+ZYAWhnA0AJbIlyyCPL7bKVEM2lVqbrXt7cyey+umkCXamuOgsWPVUKBMkXtMH8L\n5etLmD0getWIhTGhzOnDCk+gtIPfL4jMo9tkEuOCROQAXCci23VFscKcrkB+3X6h4wEOtA2APhOY\nB+wvC794o8/82ffjP79aVAi57rp3Wmzx+9pe9yMwoJuljAy2sc2tIMgdQGWVmOGBpQm3JqsidyzI\nJWG2kjnc7pDXK9pwYzXoKiqUqqrut90d+kQqRyv7MSZXR50HFqD/LI69h68b7P8Bjo3bPXOhNXGR\n9YCoemH6EkfCJxp2gIjzjWW+l2Hj2EsFQi8YXw==</SignatureValue></Signature></root>';
|
||||
|
||||
describe('BuildParameters.create() plugin property mapping', () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(Versioning, 'determineBuildVersion').mockImplementation(async () => '1.3.37');
|
||||
process.env.UNITY_LICENSE = testLicense;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('maps submoduleProfilePath from Input', async () => {
|
||||
jest.spyOn(Input, 'submoduleProfilePath', 'get').mockReturnValue('/path/to/profile.yml');
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.submoduleProfilePath).toBe('/path/to/profile.yml');
|
||||
});
|
||||
|
||||
it('maps submoduleVariantPath from Input', async () => {
|
||||
jest.spyOn(Input, 'submoduleVariantPath', 'get').mockReturnValue('/path/to/variant.yml');
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.submoduleVariantPath).toBe('/path/to/variant.yml');
|
||||
});
|
||||
|
||||
it('maps submoduleToken from Input', async () => {
|
||||
jest.spyOn(Input, 'submoduleToken', 'get').mockReturnValue('ghp_token123');
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.submoduleToken).toBe('ghp_token123');
|
||||
});
|
||||
|
||||
it('maps localCacheEnabled from Input', async () => {
|
||||
jest.spyOn(Input, 'localCacheEnabled', 'get').mockReturnValue(true);
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.localCacheEnabled).toBe(true);
|
||||
});
|
||||
|
||||
it('maps localCacheRoot from Input', async () => {
|
||||
jest.spyOn(Input, 'localCacheRoot', 'get').mockReturnValue('/d/cache');
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.localCacheRoot).toBe('/d/cache');
|
||||
});
|
||||
|
||||
it('maps localCacheLibrary from Input', async () => {
|
||||
jest.spyOn(Input, 'localCacheLibrary', 'get').mockReturnValue(false);
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.localCacheLibrary).toBe(false);
|
||||
});
|
||||
|
||||
it('maps localCacheLfs from Input', async () => {
|
||||
jest.spyOn(Input, 'localCacheLfs', 'get').mockReturnValue(true);
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.localCacheLfs).toBe(true);
|
||||
});
|
||||
|
||||
it('maps childWorkspacesEnabled from Input', async () => {
|
||||
jest.spyOn(Input, 'childWorkspacesEnabled', 'get').mockReturnValue(true);
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.childWorkspacesEnabled).toBe(true);
|
||||
});
|
||||
|
||||
it('maps childWorkspaceName from Input', async () => {
|
||||
jest.spyOn(Input, 'childWorkspaceName', 'get').mockReturnValue('TurnOfWar');
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.childWorkspaceName).toBe('TurnOfWar');
|
||||
});
|
||||
|
||||
it('maps childWorkspaceCacheRoot from Input', async () => {
|
||||
jest.spyOn(Input, 'childWorkspaceCacheRoot', 'get').mockReturnValue('/cache/workspaces');
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.childWorkspaceCacheRoot).toBe('/cache/workspaces');
|
||||
});
|
||||
|
||||
it('maps childWorkspacePreserveGit from Input', async () => {
|
||||
jest.spyOn(Input, 'childWorkspacePreserveGit', 'get').mockReturnValue(false);
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.childWorkspacePreserveGit).toBe(false);
|
||||
});
|
||||
|
||||
it('maps childWorkspaceSeparateLibrary from Input', async () => {
|
||||
jest.spyOn(Input, 'childWorkspaceSeparateLibrary', 'get').mockReturnValue(false);
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.childWorkspaceSeparateLibrary).toBe(false);
|
||||
});
|
||||
|
||||
it('maps lfsTransferAgent from Input', async () => {
|
||||
jest.spyOn(Input, 'lfsTransferAgent', 'get').mockReturnValue('/tools/elastic-git-storage');
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.lfsTransferAgent).toBe('/tools/elastic-git-storage');
|
||||
});
|
||||
|
||||
it('maps lfsTransferAgentArgs from Input', async () => {
|
||||
jest.spyOn(Input, 'lfsTransferAgentArgs', 'get').mockReturnValue('--verbose');
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.lfsTransferAgentArgs).toBe('--verbose');
|
||||
});
|
||||
|
||||
it('maps lfsStoragePaths from Input', async () => {
|
||||
jest.spyOn(Input, 'lfsStoragePaths', 'get').mockReturnValue('/path/a;/path/b');
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.lfsStoragePaths).toBe('/path/a;/path/b');
|
||||
});
|
||||
|
||||
it('maps gitHooksEnabled from Input', async () => {
|
||||
jest.spyOn(Input, 'gitHooksEnabled', 'get').mockReturnValue(true);
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.gitHooksEnabled).toBe(true);
|
||||
});
|
||||
|
||||
it('maps gitHooksSkipList from Input', async () => {
|
||||
jest.spyOn(Input, 'gitHooksSkipList', 'get').mockReturnValue('pre-commit,pre-push');
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.gitHooksSkipList).toBe('pre-commit,pre-push');
|
||||
});
|
||||
|
||||
it('maps gitHooksRunBeforeBuild from Input', async () => {
|
||||
jest.spyOn(Input, 'gitHooksRunBeforeBuild', 'get').mockReturnValue('pre-commit');
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.gitHooksRunBeforeBuild).toBe('pre-commit');
|
||||
});
|
||||
|
||||
it('maps providerExecutable from Input', async () => {
|
||||
jest.spyOn(Input, 'providerExecutable', 'get').mockReturnValue('/usr/local/bin/provider');
|
||||
const parameters = await BuildParameters.create();
|
||||
expect(parameters.providerExecutable).toBe('/usr/local/bin/provider');
|
||||
});
|
||||
|
||||
// Test that all plugin properties have correct defaults when not explicitly set
|
||||
it('has correct defaults for all plugin properties', async () => {
|
||||
const parameters = await BuildParameters.create();
|
||||
|
||||
expect(parameters.submoduleProfilePath).toBe('');
|
||||
expect(parameters.submoduleVariantPath).toBe('');
|
||||
expect(parameters.submoduleToken).toBe('');
|
||||
expect(parameters.localCacheEnabled).toBe(false);
|
||||
expect(parameters.localCacheRoot).toBe('');
|
||||
expect(parameters.localCacheLibrary).toBe(true);
|
||||
expect(parameters.localCacheLfs).toBe(false);
|
||||
expect(parameters.childWorkspacesEnabled).toBe(false);
|
||||
expect(parameters.childWorkspaceName).toBe('');
|
||||
expect(parameters.childWorkspaceCacheRoot).toBe('');
|
||||
expect(parameters.childWorkspacePreserveGit).toBe(true);
|
||||
expect(parameters.childWorkspaceSeparateLibrary).toBe(true);
|
||||
expect(parameters.lfsTransferAgent).toBe('');
|
||||
expect(parameters.lfsTransferAgentArgs).toBe('');
|
||||
expect(parameters.lfsStoragePaths).toBe('');
|
||||
expect(parameters.gitHooksEnabled).toBe(false);
|
||||
expect(parameters.gitHooksSkipList).toBe('');
|
||||
expect(parameters.gitHooksRunBeforeBuild).toBe('');
|
||||
expect(parameters.providerExecutable).toBe('');
|
||||
});
|
||||
});
|
||||
30
src/types/game-ci-orchestrator.d.ts
vendored
30
src/types/game-ci-orchestrator.d.ts
vendored
@@ -6,27 +6,23 @@
|
||||
* dynamically imports it.
|
||||
*/
|
||||
declare module '@game-ci/orchestrator' {
|
||||
interface OrchestratorPlugin {
|
||||
initialize(coreParams: Record<string, any>, workspace: string): Promise<void>;
|
||||
canHandleBuild(): boolean;
|
||||
handleBuild(baseImage: string): Promise<{ exitCode: number; fallbackToLocal?: boolean }>;
|
||||
beforeLocalBuild(workspace: string): Promise<void>;
|
||||
afterLocalBuild(workspace: string, exitCode: number): Promise<void>;
|
||||
handlePostBuild(exitCode: number): Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an orchestrator plugin instance.
|
||||
* The plugin reads its own configuration from environment variables
|
||||
* and GitHub Actions inputs — unity-builder does not need to proxy them.
|
||||
*/
|
||||
export function createPlugin(): OrchestratorPlugin;
|
||||
|
||||
// Legacy export — kept for backward compatibility with CLI and direct consumers
|
||||
export const Orchestrator: {
|
||||
run: (arg0: any, arg1: string) => Promise<{ BuildSucceeded: boolean; BuildResults: string }>;
|
||||
setup: (arg0: any) => Promise<void>;
|
||||
buildParameters: any;
|
||||
lockedWorkspace: string;
|
||||
};
|
||||
|
||||
export const BuildReliabilityService: any;
|
||||
export const TestWorkflowService: any;
|
||||
export const HotRunnerService: any;
|
||||
export const OutputService: any;
|
||||
export const OutputTypeRegistry: any;
|
||||
export const ArtifactUploadHandler: any;
|
||||
export const IncrementalSyncService: any;
|
||||
export const ChildWorkspaceService: any;
|
||||
export const LocalCacheService: any;
|
||||
export const SubmoduleProfileService: any;
|
||||
export const LfsAgentService: any;
|
||||
export const GitHooksService: any;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user