Merge pull request #148 from Max-Health-Inc/develop #63
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
| name: Pipeline Parity Test | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'src/**' | |
| - 'packages/**' | |
| - 'scripts/**' | |
| - '.github/workflows/**' | |
| workflow_dispatch: | |
| inputs: | |
| packages: | |
| description: 'Packages to test (comma-separated or "all")' | |
| required: false | |
| default: 'all' | |
| validator_version: | |
| description: 'HL7 Validator version' | |
| required: false | |
| default: 'latest' | |
| # @max-health-inc/config is installed from GitHub Packages (see .npmrc), which needs a token | |
| # even though the package is public. Set at workflow level so every `npm ci` below is covered. | |
| # An unset secret expands to an EMPTY string and fails with a 401 identical to a bad token. | |
| # Nothing in this workflow publishes, so a workflow-wide NODE_AUTH_TOKEN is safe here. | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GH_PACKAGES_TOKEN }} | |
| jobs: | |
| # ── Run both validators in parallel (reusable workflow) ──────────────────── | |
| parity-tests: | |
| uses: ./.github/workflows/_parity-tests.yml | |
| # Required: the reusable workflow's `npm ci` needs GH_PACKAGES_TOKEN to fetch | |
| # @max-health-inc/config, and a called workflow sees NO secrets without this. | |
| secrets: inherit | |
| with: | |
| packages: ${{ github.event.inputs.packages || 'all' }} | |
| validator_version: ${{ github.event.inputs.validator_version || 'latest' }} | |
| # ── Deploy results to GitHub Pages ─────────────────────────────────────────── | |
| deploy: | |
| needs: parity-tests | |
| if: always() && needs.parity-tests.result != 'skipped' | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: gh-pages-deploy | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v7 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Download Firely reports | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: firely-reports | |
| path: main-reports/firely | |
| continue-on-error: true | |
| - name: Download HL7 reports | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: hl7-reports | |
| path: main-reports/hl7 | |
| continue-on-error: true | |
| - name: Download internal reports | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: internal-reports | |
| path: main-reports/internal | |
| continue-on-error: true | |
| - name: Prepare deploy directory | |
| run: | | |
| DEPLOY_DIR=$(mktemp -d) | |
| echo "DEPLOY_DIR=$DEPLOY_DIR" >> $GITHUB_ENV | |
| # Checkout existing gh-pages content | |
| git fetch origin gh-pages:gh-pages 2>/dev/null || true | |
| if git show-ref --verify --quiet refs/heads/gh-pages; then | |
| git worktree add "$DEPLOY_DIR" gh-pages | |
| else | |
| git worktree add --orphan "$DEPLOY_DIR" gh-pages 2>/dev/null || { | |
| git worktree add "$DEPLOY_DIR" --detach | |
| git -C "$DEPLOY_DIR" checkout --orphan gh-pages | |
| git -C "$DEPLOY_DIR" rm -rf . 2>/dev/null || true | |
| } | |
| fi | |
| mkdir -p "$DEPLOY_DIR/badges" | |
| - name: Clear stale data | |
| run: | | |
| # Remove old data so failed runs don't show stale results | |
| rm -f "$DEPLOY_DIR"/parity-data.json | |
| rm -f "$DEPLOY_DIR"/parity-data-hl7.json | |
| rm -f "$DEPLOY_DIR"/parity-data-internal.json | |
| rm -f "$DEPLOY_DIR"/SUMMARY-*.md | |
| rm -f "$DEPLOY_DIR"/*-DETAIL*.md | |
| - name: Copy Firely data to gh-pages | |
| run: | | |
| if [ -d "main-reports/firely" ]; then | |
| cp main-reports/firely/parity-data.json "$DEPLOY_DIR/" 2>/dev/null || true | |
| cp main-reports/firely/badge-*.json "$DEPLOY_DIR/badges/" 2>/dev/null || true | |
| cp main-reports/firely/*-DETAIL-firely.md "$DEPLOY_DIR/" 2>/dev/null || true | |
| cp main-reports/firely/SUMMARY.md "$DEPLOY_DIR/SUMMARY-firely.md" 2>/dev/null || true | |
| fi | |
| - name: Copy HL7 data to gh-pages | |
| run: | | |
| if [ -d "main-reports/hl7" ]; then | |
| cp main-reports/hl7/parity-data-hl7.json "$DEPLOY_DIR/" 2>/dev/null || true | |
| cp main-reports/hl7/badge-hl7-*.json "$DEPLOY_DIR/badges/" 2>/dev/null || true | |
| cp main-reports/hl7/*-DETAIL-hl7.md "$DEPLOY_DIR/" 2>/dev/null || true | |
| cp main-reports/hl7/SUMMARY.md "$DEPLOY_DIR/SUMMARY-hl7.md" 2>/dev/null || true | |
| fi | |
| - name: Copy internal data to gh-pages | |
| run: | | |
| if [ -d "main-reports/internal" ]; then | |
| cp main-reports/internal/parity-data-internal.json "$DEPLOY_DIR/" 2>/dev/null || true | |
| cp main-reports/internal/badge-internal-*.json "$DEPLOY_DIR/badges/" 2>/dev/null || true | |
| cp main-reports/internal/*-DETAIL-internal.md "$DEPLOY_DIR/" 2>/dev/null || true | |
| cp main-reports/internal/SUMMARY.md "$DEPLOY_DIR/SUMMARY-internal.md" 2>/dev/null || true | |
| fi | |
| - name: Patch stable version from latest release tag | |
| run: | | |
| git fetch --tags origin | |
| LATEST_TAG=$(git tag --sort=-v:refname --list 'v*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1) | |
| if [ -n "$LATEST_TAG" ]; then | |
| VERSION="${LATEST_TAG#v}" | |
| for f in "$DEPLOY_DIR"/parity-data.json "$DEPLOY_DIR"/parity-data-hl7.json "$DEPLOY_DIR"/parity-data-internal.json; do | |
| if [ -f "$f" ]; then | |
| jq --arg v "$VERSION" '.babelfhirVersion = $v' "$f" > "${f}.tmp" && mv "${f}.tmp" "$f" | |
| fi | |
| done | |
| echo "Patched stable version to $LATEST_TAG" | |
| else | |
| echo "No release tag found — using version from parity data" | |
| fi | |
| # Append this release's parity result to history-stable.json. | |
| # | |
| # update-history.js has supported --stable since it was written, but nothing | |
| # ever called it that way: the only invocation is in pipeline-parity-develop | |
| # without the flag, which writes the pre-release history.json. So | |
| # history-stable.json had been frozen at 1.2.1 (2026-04-07) while every | |
| # release since shipped unrecorded. | |
| # | |
| # This is now a load-bearing artifact, not just a trend chart: it is the | |
| # public, per-release record of which babelfhir-ts version passed stable | |
| # parity, and Max-Health-Inc/fhir-igs reads it to decide which release is | |
| # safe to publish IG packages with. Runs BEFORE the report page, which reads | |
| # the history to draw trends. | |
| # | |
| # A hard parity failure leaves no parity-data*.json to copy, so | |
| # update-history.js finds no data and records nothing — absence of an entry | |
| # is itself the "did not pass" signal. | |
| - name: Record stable parity history for this release | |
| run: node scripts/update-history.js "$DEPLOY_DIR" --stable | |
| - name: Regenerate report page | |
| run: | | |
| node scripts/generate-report-page.js "$DEPLOY_DIR" "$DEPLOY_DIR" | |
| node scripts/generate-report-downloads.js "$DEPLOY_DIR" | |
| - name: Ensure .nojekyll exists | |
| run: touch "$DEPLOY_DIR/.nojekyll" | |
| - name: Commit and push to gh-pages | |
| run: | | |
| cd "$DEPLOY_DIR" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git config user.name "github-actions[bot]" | |
| git add -A | |
| if git diff --cached --quiet; then | |
| echo "No changes to deploy" | |
| else | |
| git commit -m "Update parity report (main) [skip ci]" | |
| git push origin gh-pages | |
| echo "Deployed results to GitHub Pages" | |
| fi | |
| - name: Cleanup worktree | |
| if: always() | |
| run: | | |
| cd "${{ github.workspace }}" | |
| git worktree remove "$DEPLOY_DIR" --force 2>/dev/null || true |