116 lines
4.6 KiB
YAML
116 lines
4.6 KiB
YAML
name: Windows CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: reims-windows-ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
REIMS_CI_WORKSPACE: D:/RgCI/${{ github.run_id }}-${{ github.run_attempt }}
|
|
GOCACHE: D:/RgCI/${{ github.run_id }}-${{ github.run_attempt }}/.debug/cache/go-build
|
|
|
|
jobs:
|
|
verify:
|
|
runs-on: reims-windows-x64
|
|
timeout-minutes: 30
|
|
steps:
|
|
- name: Check out the triggering commit
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
$PSNativeCommandUseErrorActionPreference = $true
|
|
if (Test-Path -LiteralPath $env:REIMS_CI_WORKSPACE) { throw 'The CI checkout directory already exists' }
|
|
New-Item -ItemType Directory -Path $env:REIMS_CI_WORKSPACE -Force | Out-Null
|
|
Set-Location -LiteralPath $env:REIMS_CI_WORKSPACE
|
|
git init .
|
|
git remote add origin "$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY.git"
|
|
git fetch --depth=1 origin $env:GITHUB_SHA
|
|
git checkout --detach FETCH_HEAD
|
|
if ((git rev-parse HEAD) -ne $env:GITHUB_SHA) { throw 'Unexpected checkout commit' }
|
|
|
|
- name: Verify installed build tools
|
|
working-directory: ${{ env.REIMS_CI_WORKSPACE }}
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
$PSNativeCommandUseErrorActionPreference = $true
|
|
git --version
|
|
go version
|
|
node --version
|
|
pnpm --version
|
|
|
|
- name: Verify CHANGELOG.md matches current version
|
|
working-directory: ${{ env.REIMS_CI_WORKSPACE }}
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
node scripts/changelog.mjs check
|
|
if ($LASTEXITCODE -ne 0) { throw 'Changelog validation failed' }
|
|
$verFile = Get-Content -Raw -LiteralPath 'internal/version/version.go'
|
|
if ($verFile -notmatch 'var\s+Version\s*=\s*"(v[^"]+)"') {
|
|
throw 'Could not parse Version from internal/version/version.go'
|
|
}
|
|
$ver = $Matches[1]
|
|
New-Item -ItemType Directory -Force -Path .debug/runs/ci | Out-Null
|
|
$tmp = Join-Path $PWD ".debug/runs/ci/release-notes-$ver.md"
|
|
& ./scripts/build-release-notes.ps1 -Tag $ver -OutFile $tmp
|
|
"REIMS_APP_VERSION=$ver" >> $env:GITHUB_ENV
|
|
Write-Host "PASS CHANGELOG.md contains valid release notes for $ver ($((Get-Item -LiteralPath $tmp).Length) bytes)"
|
|
|
|
- name: Workspace hygiene
|
|
working-directory: ${{ env.REIMS_CI_WORKSPACE }}
|
|
shell: pwsh
|
|
run: node scripts/debug/check.mjs
|
|
|
|
- name: Install frontend dependencies
|
|
working-directory: ${{ env.REIMS_CI_WORKSPACE }}
|
|
shell: pwsh
|
|
run: pnpm --dir frontend install --frozen-lockfile
|
|
|
|
- name: CI tests
|
|
working-directory: ${{ env.REIMS_CI_WORKSPACE }}
|
|
shell: pwsh
|
|
run: node scripts/test.mjs ci
|
|
|
|
- name: Bundle frontend
|
|
working-directory: ${{ env.REIMS_CI_WORKSPACE }}
|
|
shell: pwsh
|
|
run: pnpm --dir frontend bundle
|
|
|
|
- name: Build reims-go.exe (window + command-line mode)
|
|
working-directory: ${{ env.REIMS_CI_WORKSPACE }}
|
|
shell: pwsh
|
|
run: |
|
|
$env:GOTMPDIR = (Resolve-Path .debug/runs/ci).Path
|
|
$exe = '.debug/runs/ci/reims-go.exe'
|
|
go vet -tags desktop,production .
|
|
if ($LASTEXITCODE -ne 0) { throw 'Go desktop vet failed' }
|
|
go build -trimpath -tags desktop,production -ldflags "-H windowsgui" -o $exe .
|
|
if ($LASTEXITCODE -ne 0) { throw 'Go desktop build failed' }
|
|
./scripts/check-release-artifact.ps1 -Executable $exe -Version $env:REIMS_APP_VERSION
|
|
|
|
- name: WebView2 first-launch smoke
|
|
working-directory: ${{ env.REIMS_CI_WORKSPACE }}
|
|
timeout-minutes: 3
|
|
run: node scripts/test.mjs webview2 .debug/runs/ci/reims-go.exe
|
|
|
|
- name: Remove the CI checkout
|
|
if: always()
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
if (!(Test-Path -LiteralPath $env:REIMS_CI_WORKSPACE)) { return }
|
|
$checkout = Get-Item -LiteralPath $env:REIMS_CI_WORKSPACE
|
|
$parent = Get-Item -LiteralPath 'D:/RgCI'
|
|
if ($checkout.Parent.FullName -ne $parent.FullName -or
|
|
$checkout.Name -notmatch '^[0-9]+-[0-9]+$' -or
|
|
($checkout.Attributes -band [IO.FileAttributes]::ReparsePoint) -or
|
|
($parent.Attributes -band [IO.FileAttributes]::ReparsePoint)) {
|
|
throw 'Refusing to remove an unexpected CI checkout path'
|
|
}
|
|
Remove-Item -LiteralPath $checkout.FullName -Recurse -Force
|