Skip to content
Closed
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
28 changes: 28 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Source checks

on:
push:
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
checks:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: cmd/launcher/go.mod
cache: false
- name: Test launcher
working-directory: cmd/launcher
run: go test ./...
- name: Vet launcher
working-directory: cmd/launcher
run: go vet ./...
- name: Check PowerShell syntax
shell: pwsh
run: ./scripts/check-powershell-syntax.ps1
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ cd cmd/launcher
go test ./...
```

GitHub Actions runs launcher tests, `go vet`, and PowerShell syntax checks on
Windows for pushes and pull requests. These checks use source files only; they
do not download or package Firefox or uBlock Origin. Run the same syntax check
locally from the repository root:

```powershell
pwsh -File scripts/check-powershell-syntax.ps1
```

The syntax check parses scripts without executing their packaging operations.

## Licensing

The Nano Origin-original files in this repository are MIT licensed; see [LICENSE](LICENSE).
Expand Down
28 changes: 28 additions & 0 deletions scripts/check-powershell-syntax.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[CmdletBinding()]
param(
[string]$ScriptsPath = $PSScriptRoot
)

$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest

$scripts = @(Get-ChildItem -LiteralPath $ScriptsPath -Filter '*.ps1' -File -Recurse)
if ($scripts.Count -eq 0) { throw "No PowerShell scripts found in: $ScriptsPath" }

$invalid = 0
foreach ($script in $scripts) {
$tokens = $null
$parseErrors = $null
$null = [System.Management.Automation.Language.Parser]::ParseFile(
$script.FullName, [ref]$tokens, [ref]$parseErrors
)
foreach ($parseError in $parseErrors) {
$invalid++
Write-Host ('{0}:{1}:{2}: {3}' -f $script.FullName,
$parseError.Extent.StartLineNumber, $parseError.Extent.StartColumnNumber,
$parseError.Message)
}
}

if ($invalid -gt 0) { throw "Found $invalid PowerShell parse error(s)." }
Write-Host "PowerShell syntax passed for $($scripts.Count) scripts."
Loading