Skip to content

re-instate _json field naming #147

re-instate _json field naming

re-instate _json field naming #147

name: Release build (EXE + dists) & MkDocs deploy
on:
push:
branches: [main]
tags: ['v*.*.*']
# manual + UI Release publish
workflow_dispatch:
inputs:
ref:
description: 'Tag or branch to build'
required: false
default: ''
release:
types: [published]
permissions:
contents: write
pages: write
id-token: write
jobs:
# Release build (Windows), runs on tag push, manual run, or Release publish
release-build:
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' || github.event_name == 'release'
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# build correct ref for each trigger type
ref: ${{ inputs.ref != '' && inputs.ref
|| github.event_name == 'release' && github.event.release.tag_name
|| github.ref }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: |
pyproject.toml
- name: Install build deps
run: |
python -m pip install --upgrade pip
python -m pip install build twine pyinstaller
pip install .
- name: Clean previous build (PowerShell)
shell: pwsh
run: |
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue dist, build
Get-ChildItem -Path . -Filter *.spec -File -Recurse -ErrorAction SilentlyContinue | Remove-Item -Force
# Build Python dists first
- name: Build sdist & wheel
run: python -m build --sdist --wheel --outdir dist
- name: Check metadata (twine)
run: twine check dist\*.whl dist\*.tar.gz
# Build Windows EXE
- name: Build EXE with PyInstaller
run: pyinstaller api_pipeline\entry_point.py --onefile --name csc_api_pipeline --console
- name: CLI smoke test EXE on Git runner with --help
shell: pwsh
run: |
$p = 'dist\csc_api_pipeline.exe'
if (-not (Test-Path $p)) { Write-Error "exe not found at $p"; exit 1 }
$out = & $p --help 2>&1
$code = $LASTEXITCODE
Write-Host $out
if ($code -ne 0) { Write-Error "non zero exit $code"; exit $code }
# Pass if at least 1 output line contains any of these markers
# If no lines match pattern, treat as failure
if (-not ($out -match '(Usage|CSC API Pipeline|Commands:)')) {
Write-Error "help text missing expected markers"
exit 1
}
- name: Generate SHA256 checksums
shell: pwsh
run: |
Remove-Item -ErrorAction SilentlyContinue dist\SHA256SUMS.txt
Get-ChildItem -Path dist -File | ForEach-Object {
$h = Get-FileHash -Path $_.FullName -Algorithm SHA256
'{0} {1}' -f $h.Hash, $_.Name | Add-Content -Path dist\SHA256SUMS.txt -Encoding Ascii
}
Get-Content -Path dist\SHA256SUMS.txt
- name: Preflight, required files exist
shell: pwsh
run: |
$required = @(
"dist\csc_api_pipeline.exe",
"README.md",
"api_pipeline\.env.example",
"api_pipeline\pshell\api_payload_sender.ps1",
"pre_flight_checks\api_credentials_smoke_test.ps1",
"sql_json_query\populate_ssd_api_data_staging_2012.sql",
"sql_json_query\populate_ssd_api_data_staging_2016.sql",
"pre_flight_checks\ssd_vw_csc_api_schema_checks.sql"
)
$missing = @()
foreach ($p in $required) { if (-not (Test-Path $p)) { $missing += $p } }
if ($missing.Count -gt 0) {
Write-Error ("Missing required files: " + ($missing -join ", "))
exit 1
}
# # parked assets from release bundle
# Copy-Item dist\csc_api_pipeline.exe -Destination release_bundle\
- name: Assemble release bundle
shell: pwsh
run: |
New-Item -ItemType Directory -Path release_bundle | Out-Null
New-Item -ItemType Directory -Path release_bundle\notebooks | Out-Null
Copy-Item README.md -Destination release_bundle\
Copy-Item api_pipeline\.env.example -Destination release_bundle\
# PowerShell scripts
Copy-Item api_pipeline\pshell\api_payload_sender.ps1 -Destination release_bundle\
# SQL files, legacy and current
Copy-Item sql_json_query\populate_ssd_api_data_staging_2012.sql -Destination release_bundle\
Copy-Item sql_json_query\populate_ssd_api_data_staging_2016.sql -Destination release_bundle\
Copy-Item sql_json_query\populate_ssd_api_data_staging_postgres.sql -Destination release_bundle\
# Notebooks
Copy-Item api_pipeline\notebooks\* -Destination release_bundle\notebooks\ -Recurse -Force
Compress-Archive -Path release_bundle\* -DestinationPath release.zip -Force
- name: Package pre_flight_checks.zip
shell: pwsh
run: |
if (-not (Test-Path pre_flight_checks)) {
Write-Error "pre_flight_checks folder not found"
exit 1
}
if (-not (Get-ChildItem pre_flight_checks -File -ErrorAction SilentlyContinue)) {
Write-Error "pre_flight_checks is empty"
exit 1
}
Compress-Archive -Path pre_flight_checks\* -DestinationPath pre_flight_checks.zip -Force
- name: Show assets to be uploaded
shell: pwsh
run: |
Write-Host "Zips in repo root and bundle:"
Get-ChildItem -Path . -Filter *.zip -File | Format-Table Length, Name
Write-Host "Python dists:"
Get-ChildItem -Path dist -File | Format-Table Length, Name
# # parked from published assets list
# api_pipeline/pshell/api_payload_sender.ps1
# pre_flight_checks/api_credentials_smoke_test.ps1
# sql_json_query/populate_ssd_api_data_staging_2012.sql
# sql_json_query/populate_ssd_api_data_staging_2016.sql
# sql_json_query/populate_ssd_api_data_staging_postgres.sql
# pre_flight_checks/ssd_vw_csc_api_schema_checks.sql
# README.md
# api_pipeline/.env.example
- name: Upload Release Artifacts to Git
uses: softprops/action-gh-release@v2
with:
files: |
pre_flight_checks.zip
dist/csc_api_pipeline.exe
release.zip
dist/*.whl
dist/*.tar.gz
dist/SHA256SUMS.txt
fail_on_unmatched_files: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# MkDocs build (Linux) on main
docs-build:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: |
pyproject.toml
mkdocs.yml
- name: Install dependencies
run: |
pip install mkdocs mkdocs-material mkdocs-mermaid2-plugin mkdocs-with-pdf
- name: Build site
run: mkdocs build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: site/
# MkDocs deploy (Pages)
pages-deploy:
if: github.ref == 'refs/heads/main'
needs: docs-build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write
id-token: write
concurrency:
group: pages-${{ github.repository }}
cancel-in-progress: true
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4