Sync Boatstack from Intelligence Flow Labs @ 76a1339c3bfb (#93) #186
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Boatstack-owned control plane. | |
| name: Verify Boatstack distribution | |
| on: | |
| pull_request: | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Verify upstream sync contract | |
| shell: bash | |
| run: | | |
| workflow=".github/workflows/sync-upstream.yml" | |
| current="labs/12-product-engineering-loop" | |
| retired="examples/12-product-engineering-loop" | |
| count="$(grep -cF "$current" "$workflow")" | |
| if [[ "$count" != "2" ]]; then | |
| echo "Expected exactly two sync references to $current; found $count." >&2 | |
| exit 1 | |
| fi | |
| if grep -Fq "$retired" "$workflow"; then | |
| echo "Sync workflow still references retired path $retired." >&2 | |
| exit 1 | |
| fi | |
| title='Sync Boatstack from Intelligence Flow Labs @ $short' | |
| title_count="$(grep -cF "$title" "$workflow")" | |
| if [[ "$title_count" != "2" ]]; then | |
| echo "Expected commit and PR titles to use $title; found $title_count." >&2 | |
| exit 1 | |
| fi | |
| - name: Detect projected runtime | |
| id: runtime | |
| shell: bash | |
| run: | | |
| if [[ -f boatstack/go.mod ]]; then | |
| echo "go=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "go=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| # Windows `go test`/`go build` is dominated by Microsoft Defender scanning | |
| # the many small files the Go toolchain emits during compile/link. Excluding | |
| # the Go caches, the workspace, and go.exe is the single biggest wall-clock | |
| # lever (this job dropped from ~10m to a couple of minutes upstream). | |
| - name: Exclude Go caches from Microsoft Defender (Windows) | |
| if: steps.runtime.outputs.go == 'true' && runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| $targets = @( | |
| "$env:LOCALAPPDATA\go-build", # GOCACHE (build cache) | |
| "$env:USERPROFILE\go", # GOPATH incl. pkg\mod (GOMODCACHE) | |
| $env:GITHUB_WORKSPACE, # sources + compiled test binaries | |
| $env:RUNNER_TEMP | |
| ) | Where-Object { $_ -and $_.Trim() -ne '' } | Select-Object -Unique | |
| foreach ($t in $targets) { | |
| try { | |
| Add-MpPreference -ExclusionPath $t -ErrorAction Stop | |
| Write-Host "Defender exclusion added: $t" | |
| } catch { | |
| Write-Host "::warning::Defender exclusion failed for $t : $($_.Exception.Message)" | |
| } | |
| } | |
| try { Add-MpPreference -ExclusionProcess 'go.exe' -ErrorAction Stop } catch {} | |
| - uses: actions/setup-go@v5 | |
| if: steps.runtime.outputs.go == 'true' | |
| with: | |
| go-version-file: boatstack/go.mod | |
| cache-dependency-path: boatstack/go.mod | |
| - run: go test ./... | |
| if: steps.runtime.outputs.go == 'true' | |
| working-directory: boatstack | |
| - run: go build ./cmd/boatstack-helper | |
| if: steps.runtime.outputs.go == 'true' | |
| working-directory: boatstack | |
| - uses: actions/setup-python@v5 | |
| if: steps.runtime.outputs.go != 'true' | |
| with: | |
| python-version: "3.11" | |
| - name: Verify legacy projection during migration | |
| if: steps.runtime.outputs.go != 'true' | |
| env: | |
| PYTHONUTF8: "1" | |
| run: python3 -m unittest discover -s tests -v | |
| - name: Compile legacy projection during migration | |
| if: steps.runtime.outputs.go != 'true' | |
| env: | |
| PYTHONUTF8: "1" | |
| run: python3 -m compileall -q boatstack | |
| - name: Validate Bash installer | |
| if: steps.runtime.outputs.go == 'true' && runner.os != 'Windows' | |
| shell: bash | |
| run: bash -n install.sh | |
| - name: Validate PowerShell installer | |
| if: steps.runtime.outputs.go == 'true' && runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| $tokens = $null | |
| $errors = $null | |
| [System.Management.Automation.Language.Parser]::ParseFile((Resolve-Path install.ps1), [ref]$tokens, [ref]$errors) > $null | |
| if ($errors.Count -gt 0) { | |
| $errors | ForEach-Object { Write-Error $_ } | |
| exit 1 | |
| } | |
| auto-merge-sync: | |
| if: >- | |
| github.event_name == 'pull_request' && | |
| github.event.pull_request.head.repo.full_name == github.repository && | |
| startsWith(github.head_ref, 'sync/intelligence-flow-') | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Create repository automation token | |
| id: app-token | |
| uses: actions/create-github-app-token@v3 | |
| with: | |
| client-id: ${{ vars.BOATSTACK_APP_CLIENT_ID }} | |
| private-key: ${{ secrets.BOATSTACK_APP_PRIVATE_KEY }} | |
| owner: operatorstack | |
| repositories: boatstack | |
| permission-contents: write | |
| permission-pull-requests: write | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - name: Verify generated projection provenance | |
| env: | |
| APP_SLUG: ${{ steps.app-token.outputs.app-slug }} | |
| HEAD_BRANCH: ${{ github.head_ref }} | |
| PR_AUTHOR: ${{ github.event.pull_request.user.login }} | |
| shell: bash | |
| run: | | |
| source_repo="$(jq -r '.source.repository' UPSTREAM.json)" | |
| source_commit="$(jq -r '.source.commit' UPSTREAM.json)" | |
| short="${source_commit:0:12}" | |
| [[ "$PR_AUTHOR" == "${APP_SLUG}[bot]" ]] | |
| [[ "$source_repo" == "operatorstack/intelligence-flow" ]] | |
| [[ "$HEAD_BRANCH" == "sync/intelligence-flow-$short" ]] | |
| - name: Merge verified generated PR | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| PR_URL: ${{ github.event.pull_request.html_url }} | |
| run: gh pr merge "$PR_URL" --squash |