Skip to content

npm: add discovery keywords for the ReScript packages index (#59) #103

npm: add discovery keywords for the ReScript packages index (#59)

npm: add discovery keywords for the ReScript packages index (#59) #103

Workflow file for this run

name: CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test (smoke + golden snapshot)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
# Smoke test + golden snapshot diff (generated output vs committed goldens).
# Deterministic and offline — blocking. See docs/TYPE_MAPPING.md.
- name: Smoke + golden snapshot
run: npm test
# Publish an ephemeral pkg.pr.new preview of the tool ITSELF on every PR / push to main, so
# the exact build can be `npm i`-ed and tested in another project without cutting a release.
# Requires the pkg-pr-new GitHub App (https://github.com/apps/pkg-pr-new) installed on the repo.
preview:
name: Publish preview to pkg.pr.new
runs-on: ubuntu-latest
needs: test # only publish a preview once the smoke + golden tests pass
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
# Packs the package per its `files` allowlist, publishes a commit-SHA-pinned build, and posts
# a sticky PR comment: npm i https://pkg.pr.new/@juspay/rescript-bindgen@<sha>
- name: Publish preview
run: npx pkg-pr-new publish
# Compile every golden fixture's output on ReScript 12 — proves the bindings are
# valid, not just shape-matched. Deterministic and offline — blocking.
compile:
name: Golden compile (ReScript 12)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- name: Install ReScript sandbox deps
run: npm --prefix test/sandbox ci || npm --prefix test/sandbox install
- name: Compile goldens
run: npm run test:compile
# Maintenance-loop guard (issue #14): a mapping change is not done until its golden
# fixture and TYPE_MAPPING.md row land in the SAME PR (see CLAUDE.md). Pure refactors
# can opt out with the `no-fixture-needed` label.
fixture-guard:
name: Fixture guard (new cases need test cases)
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'no-fixture-needed')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Mapping changes must ship with fixtures
run: |
BASE="origin/${{ github.event.pull_request.base.ref }}"
CHANGED=$(git diff --name-only "$BASE"...HEAD)
echo "$CHANGED"
if echo "$CHANGED" | grep -qE '^src/(extract|emit|resolve)\.mjs$' \
&& ! echo "$CHANGED" | grep -qE '^(test/golden/cases/|docs/TYPE_MAPPING\.md)'; then
echo '::error::This PR changes the mapping pipeline (src/extract|emit|resolve.mjs) but adds/updates no golden case and no docs/TYPE_MAPPING.md row.'
echo '::error::Per CLAUDE.md, a mapping change is not done until all three land together: TYPE_MAPPING.md row + fixture under test/golden/cases/ + regenerated golden (npm run test:golden:update). Pure refactors: add the `no-fixture-needed` label.'
exit 1
fi
echo "✅ fixture guard passed"