Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ function Install-PinnedUnityCli {
finally {
Remove-Item -LiteralPath $temporaryPath -Force -ErrorAction SilentlyContinue
}
}
}
5 changes: 3 additions & 2 deletions .github/scripts/Export-PureBaseValidationZip.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ catch { throw "package.json version must be valid strict SemVer: '$version'." }

$sourceZips = @(
Get-ChildItem -LiteralPath $validationArtifactRoot -Filter 'jp.penguin.purebase-*.zip' -File -Recurse |
Where-Object { $_.Directory.Name -ceq 'archive' }
Where-Object { $_.Directory.Name -ceq 'archive' }
)
if ($sourceZips.Count -ne 1) {
throw "Release validation must produce exactly one audited package ZIP below '$validationArtifactRoot/archive'."
Expand All @@ -83,7 +83,7 @@ Add-Type -AssemblyName System.IO.Compression.FileSystem
$archive = $null
try {
$archive = [IO.Compression.ZipFile]::OpenRead($sourceZip.FullName)
$manifestEntries = @($archive.Entries | Where-Object FullName -ceq 'package.json')
$manifestEntries = @($archive.Entries | Where-Object FullName -CEQ 'package.json')
if ($manifestEntries.Count -ne 1) { throw 'Audited package ZIP must contain exactly one package.json.' }
$reader = [IO.StreamReader]::new($manifestEntries[0].Open(), [Text.UTF8Encoding]::new($false, $true))
try {
Expand Down Expand Up @@ -137,3 +137,4 @@ finally {

Write-Output "Validated package ZIP: $destinationZip"
Write-Output "SHA-256: $sha256"

53 changes: 27 additions & 26 deletions .github/scripts/Get-ReleaseAuthorizationPredicate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,45 +84,46 @@ if ($actualSha256 -cne $expectedSha256) {
$predicate = [ordered]@{
schemaVersion = 1
authorization = [ordered]@{
method = 'github-actions-workflow-dispatch'
actor = [ordered]@{
method = 'github-actions-workflow-dispatch'
actor = [ordered]@{
login = $ActorLogin
id = $ActorId
id = $ActorId
}
triggeringActor = $TriggeringActorLogin
eventName = $EventName
eventName = $EventName
}
release = [ordered]@{
repository = $Repository
repositoryId = $RepositoryId
repositoryOwner = $RepositoryOwner
release = [ordered]@{
repository = $Repository
repositoryId = $RepositoryId
repositoryOwner = $RepositoryOwner
repositoryOwnerId = $RepositoryOwnerId
version = $ConfirmedVersion
commitSha = [string]$state.commitSha
releaseUrl = [string]$state.releaseUrl
vpmRepository = [string]$state.vpmRepository
artifact = [ordered]@{
name = $assetName
version = $ConfirmedVersion
commitSha = [string]$state.commitSha
releaseUrl = [string]$state.releaseUrl
vpmRepository = [string]$state.vpmRepository
artifact = [ordered]@{
name = $assetName
sha256 = $actualSha256
}
}
workflow = [ordered]@{
name = $WorkflowName
ref = $WorkflowRef
sha = $WorkflowSha
runId = $RunId
runNumber = $RunNumber
runAttempt = $RunAttempt
workflow = [ordered]@{
name = $WorkflowName
ref = $WorkflowRef
sha = $WorkflowSha
runId = $RunId
runNumber = $RunNumber
runAttempt = $RunAttempt
environment = 'release'
}
request = [ordered]@{
ref = $DispatchRef
refName = $DispatchRefName
refType = $DispatchRefType
resume = [bool]$Resume
request = [ordered]@{
ref = $DispatchRef
refName = $DispatchRefName
refType = $DispatchRefType
resume = [bool]$Resume
preflightOnly = $false
}
recordedAtUtc = [DateTime]::UtcNow.ToString('o')
}

$predicate | ConvertTo-Json -Depth 8

Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,4 @@ Describe 'Install-VerifiedShaderCoreRelease' {
Assert-RecoverableBackupPreserved
}
}

1 change: 1 addition & 0 deletions .github/scripts/Install-VerifiedShaderCoreRelease.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,4 @@ function Install-VerifiedShaderCoreRelease {
if ($MyInvocation.InvocationName -ne '.') {
Install-VerifiedShaderCoreRelease @PSBoundParameters
}

1 change: 1 addition & 0 deletions .github/scripts/Invoke-PureBaseRelease.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,4 @@ $dispatchPayload = New-PureBaseDispatchPayload -PackageName $packageName -Reposi
Invoke-Api POST "$apiRoot/repos/$VpmRepository/dispatches" $dispatchToken $dispatchPayload | Out-Null
Write-State 'completed' @{ commitSha = $releaseTargetSha; validationRunId = [long]$run.id; validationRunAttempt = [int]$run.run_attempt; releaseUrl = [string]$release.html_url; vpmRepository = $VpmRepository; sha256 = $artifact.Sha256; mode = $releaseMode.Mode }
Write-Output "Release completed: $($release.html_url)"

47 changes: 24 additions & 23 deletions .github/scripts/New-PureBaseCiProject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$ProjectRoot
[Parameter(Mandatory = $true)]
[string]$ProjectRoot
)

Set-StrictMode -Version Latest
Expand All @@ -26,54 +26,54 @@ $packageRoot = Join-Path $projectRootFullPath 'Packages/jp.penguin.purebase'
$shaderCoreRoot = Join-Path $projectRootFullPath 'Packages/jp.lilxyzw.shadercore'

foreach ($requiredPath in @($packageRoot, $shaderCoreRoot)) {
if (-not (Test-Path -LiteralPath $requiredPath -PathType Container)) {
throw "Required package checkout is missing: '$requiredPath'."
}
if (-not (Test-Path -LiteralPath $requiredPath -PathType Container)) {
throw "Required package checkout is missing: '$requiredPath'."
}
}

$packageJson = Get-Content -LiteralPath (Join-Path $packageRoot 'package.json') -Raw | ConvertFrom-Json
if ([string]$packageJson.name -ne 'jp.penguin.purebase') {
throw "Unexpected Pure-Base package identity '$($packageJson.name)'."
throw "Unexpected Pure-Base package identity '$($packageJson.name)'."
}

$shaderCoreJson = Get-Content -LiteralPath (Join-Path $shaderCoreRoot 'package.json') -Raw | ConvertFrom-Json
if ([string]$shaderCoreJson.name -ne 'jp.lilxyzw.shadercore' -or [string]$shaderCoreJson.version -ne '0.1.9') {
throw "The CI workspace requires jp.lilxyzw.shadercore exactly 0.1.9."
throw "The CI workspace requires jp.lilxyzw.shadercore exactly 0.1.9."
}

$ownerLightingDataRelativePath = 'Tests/Fixtures/Scenes/PureBaseValidation/OwnerLightingData.asset'
$ownerLightingDataAssetPath = Join-Path $packageRoot $ownerLightingDataRelativePath
if (-not (Test-Path -LiteralPath $ownerLightingDataAssetPath -PathType Leaf)) {
throw "Owner LightingData fixture is missing: '$ownerLightingDataRelativePath'."
throw "Owner LightingData fixture is missing: '$ownerLightingDataRelativePath'."
}

$ownerLightingDataMetaRelativePath = "$ownerLightingDataRelativePath.meta"
$ownerLightingDataMetaPath = Join-Path $packageRoot $ownerLightingDataMetaRelativePath
if (-not (Test-Path -LiteralPath $ownerLightingDataMetaPath -PathType Leaf)) {
throw "Owner LightingData metadata is missing: '$ownerLightingDataMetaRelativePath'."
throw "Owner LightingData metadata is missing: '$ownerLightingDataMetaRelativePath'."
}

$ownerLightingDataGuidLines = @([regex]::Matches((Get-Content -LiteralPath $ownerLightingDataMetaPath -Raw), '(?m)^guid:\s*(\S+)\s*$'))
if ($ownerLightingDataGuidLines.Count -ne 1) {
throw "Owner LightingData metadata must contain exactly one GUID: '$ownerLightingDataMetaRelativePath'."
throw "Owner LightingData metadata must contain exactly one GUID: '$ownerLightingDataMetaRelativePath'."
}

$ownerLightingDataGuid = $ownerLightingDataGuidLines[0].Groups[1].Value
if ($ownerLightingDataGuid -notmatch '^[0-9a-fA-F]{32}$') {
throw "Owner LightingData metadata contains a malformed GUID: '$ownerLightingDataMetaRelativePath'."
throw "Owner LightingData metadata contains a malformed GUID: '$ownerLightingDataMetaRelativePath'."
}

$assetsRoot = Join-Path $projectRootFullPath 'Assets'
$projectSettingsRoot = Join-Path $projectRootFullPath 'ProjectSettings'
$packagesRoot = Join-Path $projectRootFullPath 'Packages'
foreach ($directory in @($assetsRoot, $projectSettingsRoot, $packagesRoot)) {
New-Item -ItemType Directory -Path $directory -Force | Out-Null
New-Item -ItemType Directory -Path $directory -Force | Out-Null
}

$consumerProjectSettingsRoot = Join-Path $packageRoot 'Tests/Release/ConsumerProject/ProjectSettings'
$projectVersionSource = Join-Path $consumerProjectSettingsRoot 'ProjectVersion.txt'
if (-not (Test-Path -LiteralPath $projectVersionSource -PathType Leaf)) {
throw "Pinned Unity ProjectVersion source is missing: '$projectVersionSource'."
throw "Pinned Unity ProjectVersion source is missing: '$projectVersionSource'."
}
Copy-Item -LiteralPath $projectVersionSource -Destination (Join-Path $projectSettingsRoot 'ProjectVersion.txt') -Force

Expand All @@ -85,20 +85,20 @@ Copy-Item -LiteralPath $projectVersionSource -Destination (Join-Path $projectSet
# Recompare and refresh this fixture whenever the VRChat SDK or its Project Setup changes.
$qualitySettingsSource = Join-Path $consumerProjectSettingsRoot 'QualitySettings.asset'
if (-not (Test-Path -LiteralPath $qualitySettingsSource -PathType Leaf)) {
throw "Reviewed VRChat-project QualitySettings snapshot is missing: '$qualitySettingsSource'."
throw "Reviewed VRChat-project QualitySettings snapshot is missing: '$qualitySettingsSource'."
}
Copy-Item -LiteralPath $qualitySettingsSource -Destination (Join-Path $projectSettingsRoot 'QualitySettings.asset') -Force

$manifest = [ordered]@{
dependencies = [ordered]@{
'com.unity.test-framework' = '1.1.33'
}
dependencies = [ordered]@{
'com.unity.test-framework' = '1.1.33'
}
}
$manifestText = ($manifest | ConvertTo-Json -Depth 4) + "`n"
[System.IO.File]::WriteAllText(
(Join-Path $packagesRoot 'manifest.json'),
$manifestText,
[System.Text.UTF8Encoding]::new($false)
(Join-Path $packagesRoot 'manifest.json'),
$manifestText,
[System.Text.UTF8Encoding]::new($false)
)

$ownerSceneText = @"
Expand Down Expand Up @@ -233,9 +233,9 @@ SceneRoots:
m_Roots: []
"@
[System.IO.File]::WriteAllText(
(Join-Path $assetsRoot 'Pure-Base.unity'),
$ownerSceneText.Replace("`r`n", "`n") + "`n",
[System.Text.UTF8Encoding]::new($false)
(Join-Path $assetsRoot 'Pure-Base.unity'),
$ownerSceneText.Replace("`r`n", "`n") + "`n",
[System.Text.UTF8Encoding]::new($false)
)

Write-Output "Prepared Pure-Base CI Unity project: $projectRootFullPath"
Expand All @@ -246,3 +246,4 @@ Write-Output "VRChat SDK packages installed in generated CI project: none"

# Normalize only an accepted native-command status when the caller has one.
if ((Test-Path Variable:LASTEXITCODE) -and $LASTEXITCODE -lt 8) { $global:LASTEXITCODE = 0 }

21 changes: 11 additions & 10 deletions .github/scripts/PureBase.Automation.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ function ConvertTo-PureBaseSemVer {
}

return [pscustomobject][ordered]@{
original = $Value
major = $major
minor = $minor
patch = $patch
prerelease = $prerelease
isPrerelease = $prerelease.Count -ne 0
original = $Value
major = $major
minor = $minor
patch = $patch
prerelease = $prerelease
isPrerelease = $prerelease.Count -ne 0
prereleaseKind = if ($prerelease.Count -eq 0) { '' } else { $prerelease[0] }
}
}
Expand Down Expand Up @@ -505,7 +505,7 @@ function Resolve-PureBasePublishedArtifact {
throw 'GitHub did not report the published release as immutable.'
}

$assets = @($Release.assets | Where-Object name -eq $AssetName)
$assets = @($Release.assets | Where-Object name -EQ $AssetName)
if ($assets.Count -ne 1) {
throw "Published release must contain exactly one asset named '$AssetName'."
}
Expand Down Expand Up @@ -548,9 +548,9 @@ function Select-PureBaseReleaseValidationRun {
try { $runWorkflowPath = ConvertTo-PureBaseReleaseValidationWorkflowPath -Value ([string]$_.path) }
catch { return $false }
return $runWorkflowPath -ceq $expectedWorkflowPath -and
[string]::Equals([string]$_.head_sha, $HeadSha, [StringComparison]::OrdinalIgnoreCase) -and
[string]$_.head_branch -ceq $Branch -and [string]$_.event -ceq 'workflow_dispatch' -and
[int]$_.run_number -gt 0 -and [int]$_.run_attempt -gt 0
[string]::Equals([string]$_.head_sha, $HeadSha, [StringComparison]::OrdinalIgnoreCase) -and
[string]$_.head_branch -ceq $Branch -and [string]$_.event -ceq 'workflow_dispatch' -and
[int]$_.run_number -gt 0 -and [int]$_.run_attempt -gt 0
})
if ($candidates.Count -eq 0) { throw 'No matching validation run was found for the exact workflow, branch, and commit.' }
$latest = @($candidates | Sort-Object @{ Expression = { [int]$_.run_number }; Descending = $true }, @{ Expression = { [int]$_.run_attempt }; Descending = $true })[0]
Expand Down Expand Up @@ -843,3 +843,4 @@ Export-ModuleMember -Function @(
'Read-PureBaseVpmYankPolicy',
'Invoke-PureBaseYankDispatch'
)

9 changes: 5 additions & 4 deletions .github/scripts/PureBase.ReleasePublication.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ Set-Alias -Name New-PureBaseReleasePublicationBody -Value ConvertTo-PureBaseRele

Export-ModuleMember `
-Function @(
'ConvertTo-PureBaseReleasePublicationBody',
'Assert-PureBasePublishedReleaseIdentity',
'Invoke-PureBaseReleaseLookupWithRetry'
) `
'ConvertTo-PureBaseReleasePublicationBody',
'Assert-PureBasePublishedReleaseIdentity',
'Invoke-PureBaseReleaseLookupWithRetry'
) `
-Alias 'New-PureBaseReleasePublicationBody'

1 change: 1 addition & 0 deletions .github/scripts/Resolve-UnityEditorPath.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,4 @@ exit /b %ERRORLEVEL%
Write-Host "Unity watchdog proxy: $proxyCommandPath"
Write-Host "Unity watchdog target: $normalizedPath"
Write-Output $proxyCommandPath

8 changes: 4 additions & 4 deletions .github/scripts/Test-RepositoryLineEndings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function Invoke-RepositoryGitBytes {
}
throw "$diagnostic)."
}
return ,$stdout.ToArray()
return , $stdout.ToArray()
}
finally {
$process.Dispose()
Expand Down Expand Up @@ -124,7 +124,7 @@ function Add-RepositoryViolation {
)

$Violations.Add([pscustomobject]@{
Path = $Path
Path = $Path
Reason = $Reason
})
}
Expand All @@ -143,7 +143,7 @@ function Read-RepositoryIndexBlobs {

$blobs = [Collections.Generic.Dictionary[string, byte[]]]::new([StringComparer]::OrdinalIgnoreCase)
if ($ObjectIds.Count -eq 0) {
return ,$blobs
return , $blobs
}
$batchInput = [Text.Encoding]::ASCII.GetBytes((($ObjectIds -join "`n") + "`n"))
$output = Invoke-RepositoryGitBytes -Root $Root -Arguments @('cat-file', '--batch') -StandardInputBytes $batchInput
Expand Down Expand Up @@ -318,4 +318,4 @@ try {
catch {
Write-Output "repository: $($_.Exception.Message)"
exit 1
}
}
1 change: 1 addition & 0 deletions .github/scripts/UnityWatchdogProxy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,4 @@ catch {
finally {
$process.Dispose()
}

2 changes: 1 addition & 1 deletion .github/tests/Export-PureBaseValidationZip.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ Describe 'Validated package exporter contracts' {
{ & $exporterPath @invalidArguments } | Should -Throw "*$Name must be valid*"
Test-Path -LiteralPath (Join-Path $validationRoot 'validated-package') | Should -BeFalse
}
}
}
Loading