name: Check on: push: branches: [windows] pull_request: branches: [windows] permissions: contents: write jobs: format: name: Format & Lint runs-on: windows-latest steps: - name: Checkout uses: actions/checkout@v4 with: ref: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.head_ref) || github.ref }} token: ${{ secrets.GITHUB_TOKEN }} - name: Set up Go uses: actions/setup-go@v5 with: go-version: '1.24.6' - name: Install Go tools run: | go install golang.org/x/tools/cmd/goimports@latest go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - name: Format Go code run: | $env:PATH = "$(go env GOPATH)\bin;$env:PATH" Get-ChildItem -Path cmd -Recurse -Filter "*.go" | ForEach-Object { goimports -w $_.FullName } shell: pwsh - name: Run golangci-lint run: | $env:PATH = "$(go env GOPATH)\bin;$env:PATH" cd cmd/analyze golangci-lint run --timeout 5m cd ../status golangci-lint run --timeout 5m shell: pwsh continue-on-error: true - name: Check PowerShell syntax run: | $hasErrors = $false $scripts = Get-ChildItem -Path . -Recurse -Include "*.ps1" -Exclude "*.Tests.ps1" foreach ($script in $scripts) { $errors = $null $null = [System.Management.Automation.Language.Parser]::ParseFile($script.FullName, [ref]$null, [ref]$errors) if ($errors.Count -gt 0) { Write-Host "Syntax errors in $($script.Name):" -ForegroundColor Red $errors | ForEach-Object { Write-Host " $_" } $hasErrors = $true } } if ($hasErrors) { exit 1 } Write-Host "All PowerShell scripts have valid syntax" -ForegroundColor Green shell: pwsh - name: Commit formatting changes if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" $changes = git status --porcelain if ($changes) { git add . git commit -m "chore: auto format code" git push Write-Host "Formatting changes committed" } else { Write-Host "No formatting changes needed" } shell: pwsh