Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 73 additions & 8 deletions .github/workflows/jest-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,23 @@ name: "@keploy/jest publish"
# try to publish that package under this tag's name. jest/README.md,
# "Releasing", says the same.
#
# On a pull request the same package is published as a dry run, with no
# token, so a package that would ship without its build shows before a tag.
# The package is built and packed once, and that tarball is checked and then
# published, so what ships is what was checked. The license check
# (scripts/license-gate.mjs, as in sdk-publish.yml) installs the tarball as a
# user's `npm install` does and refuses it when anything it installs names a
# license outside its allow-list. test/workflows.test.mjs holds this
# workflow to that, and both of its jobs run those rows first.
#
# On a pull request the same tarball is packed, checked and published as a
# dry run, with no token, so a package that would ship without its build, or
# with a license it may not carry, shows before a tag.
on:
push:
tags: ["jest-v*"]
pull_request:
paths:
- "jest/**"
- "scripts/license-gate.mjs"
- ".github/workflows/jest-publish.yml"
- ".github/workflows/jest-sdk.yml"

Expand All @@ -41,6 +50,7 @@ jobs:
if: github.event_name == 'push'
needs: rows
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
id-token: write # npm --provenance signs the package with this run's identity
Expand All @@ -57,6 +67,15 @@ jobs:
# scope to it (@keploy:registry), in the runner's own npmrc.
registry-url: https://registry.npmjs.org
scope: "@keploy"
- name: Workflow rows
# test/workflows.test.mjs, from the repository's root, so that every
# tag and pull request this workflow runs on checks that it still
# publishes only the tarball its Licenses step passed. The root's
# install, with no scripts, is only for the rows' YAML parser.
working-directory: .
run: |
npm ci --ignore-scripts
node --test test/workflows.test.mjs
- name: The tag names package.json's version
run: node scripts/release-version.mjs "$GITHUB_REF_NAME"
- name: The npm token is set
Expand All @@ -71,22 +90,43 @@ jobs:
got=$(npm config get @keploy:registry)
test "$got" = https://registry.npmjs.org/ || { echo "::error::@keploy:registry is '$got', not https://registry.npmjs.org/; refusing to publish"; exit 1; }
- run: npm ci
- name: Build
run: npm run build
- name: Pack
id: pack
run: |
name=$(npm pack --pack-destination "$RUNNER_TEMP" | tail -n 1)
test -f "$RUNNER_TEMP/$name" || { echo "::error::npm pack wrote no $name"; exit 1; }
echo "tarball=$RUNNER_TEMP/$name" >> "$GITHUB_OUTPUT"
- name: The package carries its build
env:
TARBALL: ${{ steps.pack.outputs.tarball }}
run: |
tar -tzf "$TARBALL" > "$RUNNER_TEMP/files.txt"
for f in dist/index.js dist/index.d.ts package.json README.md; do
grep -qx "package/$f" "$RUNNER_TEMP/files.txt" || { echo "::error::the package would ship without $f"; exit 1; }
done
- name: Licenses
env:
TARBALL: ${{ steps.pack.outputs.tarball }}
run: node ../scripts/license-gate.mjs "$TARBALL"
- name: The token authenticates
# Fails here, named, on a token that is expired, revoked or pasted
# with a stray character, before anything is uploaded.
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm whoami --registry https://registry.npmjs.org/
- name: Publish
# prepublishOnly builds dist/ first.
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public --provenance
TARBALL: ${{ steps.pack.outputs.tarball }}
run: npm publish "$TARBALL" --access public --provenance

dry-run:
name: publish dry run
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
shell: bash # -eo pipefail: a failed command before a pipe fails the step
Expand All @@ -96,12 +136,37 @@ jobs:
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22
- name: Workflow rows
# test/workflows.test.mjs, from the repository's root, so that every
# tag and pull request this workflow runs on checks that it still
# publishes only the tarball its Licenses step passed. The root's
# install, with no scripts, is only for the rows' YAML parser.
working-directory: .
run: |
npm ci --ignore-scripts
node --test test/workflows.test.mjs
- run: npm ci
- name: Publish, dry run
run: npm publish --dry-run --access public 2>&1 | tee "$RUNNER_TEMP/publish.log"
- name: Build
run: npm run build
- name: Pack
id: pack
run: |
name=$(npm pack --pack-destination "$RUNNER_TEMP" | tail -n 1)
test -f "$RUNNER_TEMP/$name" || { echo "::error::npm pack wrote no $name"; exit 1; }
echo "tarball=$RUNNER_TEMP/$name" >> "$GITHUB_OUTPUT"
- name: The package carries its build
# A fresh checkout has no dist/; only prepublishOnly puts it there.
env:
TARBALL: ${{ steps.pack.outputs.tarball }}
run: |
tar -tzf "$TARBALL" > "$RUNNER_TEMP/files.txt"
for f in dist/index.js dist/index.d.ts package.json README.md; do
grep -qE "npm notice [0-9.]+[kMG]?B +$f\$" "$RUNNER_TEMP/publish.log" || { echo "::error::the package would ship without $f"; exit 1; }
grep -qx "package/$f" "$RUNNER_TEMP/files.txt" || { echo "::error::the package would ship without $f"; exit 1; }
done
- name: Licenses
env:
TARBALL: ${{ steps.pack.outputs.tarball }}
run: node ../scripts/license-gate.mjs "$TARBALL"
- name: Publish, dry run
env:
TARBALL: ${{ steps.pack.outputs.tarball }}
run: npm publish "$TARBALL" --dry-run --access public
2 changes: 2 additions & 0 deletions .github/workflows/jest-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
rows:
name: build and rows (Node ${{ matrix.node }}, Jest ${{ matrix.jest }})
runs-on: ubuntu-latest
# A leg takes a few minutes, npm installs included: one past 30 is a hang.
timeout-minutes: 30
strategy:
# One leg failing must not cancel the others: each leg's result is its
# own.
Expand Down
93 changes: 80 additions & 13 deletions .github/workflows/playwright-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,33 @@ name: "@keploy/playwright publish"
# playwright-vX.Y.Z on that commit. The rows run on the tagged commit first;
# the publish runs only when every leg passes, and refuses a tag that does not
# name package.json's version (scripts/release-version.mjs). npm itself
# refuses a version it already has.
# refuses a version it already has. Every action the publish and dry-run
# jobs run is pinned by commit: the publish job holds the npm token and
# signs the package's provenance.
#
# Push playwright-vX.Y.Z as a plain git tag, never as a GitHub release: a
# published GitHub release also starts any workflow of this repository that
# runs on releases (the root @keploy/sdk release workflow, #117), which would
# try to publish that package under this tag's name. playwright/README.md,
# "Releasing", says the same.
#
# On a pull request the same package is published as a dry run, with no
# token, so a package that would ship without its build shows before a tag.
# The package is built and packed once, and that tarball is checked and then
# published, so what ships is what was checked. The license check
# (scripts/license-gate.mjs, as in sdk-publish.yml) installs the tarball as a
# user's `npm install` does and refuses it when anything it installs names a
# license outside its allow-list. test/workflows.test.mjs holds this
# workflow to that, and both of its jobs run those rows first.
#
# On a pull request the same tarball is packed, checked and published as a
# dry run, with no token, so a package that would ship without its build, or
# with a license it may not carry, shows before a tag.
on:
push:
tags: ["playwright-v*"]
pull_request:
paths:
- "playwright/**"
- "scripts/license-gate.mjs"
- ".github/workflows/playwright-publish.yml"
- ".github/workflows/playwright-sdk.yml"

Expand All @@ -39,6 +50,7 @@ jobs:
if: github.event_name == 'push'
needs: rows
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
id-token: write # npm --provenance signs the package with this run's identity
Expand All @@ -47,14 +59,23 @@ jobs:
shell: bash # -eo pipefail: a failed command before a pipe fails the step
working-directory: playwright
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22
# Writes the token line for registry.npmjs.org and pins the @keploy
# scope to it (@keploy:registry), in the runner's own npmrc.
registry-url: https://registry.npmjs.org
scope: "@keploy"
- name: Workflow rows
# test/workflows.test.mjs, from the repository's root, so that every
# tag and pull request this workflow runs on checks that it still
# publishes only the tarball its Licenses step passed. The root's
# install, with no scripts, is only for the rows' YAML parser.
working-directory: .
run: |
npm ci --ignore-scripts
node --test test/workflows.test.mjs
- name: The tag names package.json's version
run: node scripts/release-version.mjs "$GITHUB_REF_NAME"
- name: The npm token is set
Expand All @@ -69,37 +90,83 @@ jobs:
got=$(npm config get @keploy:registry)
test "$got" = https://registry.npmjs.org/ || { echo "::error::@keploy:registry is '$got', not https://registry.npmjs.org/; refusing to publish"; exit 1; }
- run: npm ci
- name: Build
run: npm run build
- name: Pack
id: pack
run: |
name=$(npm pack --pack-destination "$RUNNER_TEMP" | tail -n 1)
test -f "$RUNNER_TEMP/$name" || { echo "::error::npm pack wrote no $name"; exit 1; }
echo "tarball=$RUNNER_TEMP/$name" >> "$GITHUB_OUTPUT"
- name: The package carries its build
env:
TARBALL: ${{ steps.pack.outputs.tarball }}
run: |
tar -tzf "$TARBALL" > "$RUNNER_TEMP/files.txt"
for f in dist/index.js dist/index.d.ts package.json README.md; do
grep -qx "package/$f" "$RUNNER_TEMP/files.txt" || { echo "::error::the package would ship without $f"; exit 1; }
done
- name: Licenses
env:
TARBALL: ${{ steps.pack.outputs.tarball }}
run: node ../scripts/license-gate.mjs "$TARBALL"
- name: The token authenticates
# Fails here, named, on a token that is expired, revoked or pasted
# with a stray character, before anything is uploaded.
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm whoami --registry https://registry.npmjs.org/
- name: Publish
# prepublishOnly builds dist/ first.
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public --provenance
TARBALL: ${{ steps.pack.outputs.tarball }}
run: npm publish "$TARBALL" --access public --provenance

dry-run:
name: publish dry run
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
shell: bash # -eo pipefail: a failed command before a pipe fails the step
working-directory: playwright
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22
- name: Workflow rows
# test/workflows.test.mjs, from the repository's root, so that every
# tag and pull request this workflow runs on checks that it still
# publishes only the tarball its Licenses step passed. The root's
# install, with no scripts, is only for the rows' YAML parser.
working-directory: .
run: |
npm ci --ignore-scripts
node --test test/workflows.test.mjs
- run: npm ci
- name: Publish, dry run
run: npm publish --dry-run --access public 2>&1 | tee "$RUNNER_TEMP/publish.log"
- name: Build
run: npm run build
- name: Pack
id: pack
run: |
name=$(npm pack --pack-destination "$RUNNER_TEMP" | tail -n 1)
test -f "$RUNNER_TEMP/$name" || { echo "::error::npm pack wrote no $name"; exit 1; }
echo "tarball=$RUNNER_TEMP/$name" >> "$GITHUB_OUTPUT"
- name: The package carries its build
# A fresh checkout has no dist/; only prepublishOnly puts it there.
env:
TARBALL: ${{ steps.pack.outputs.tarball }}
run: |
tar -tzf "$TARBALL" > "$RUNNER_TEMP/files.txt"
for f in dist/index.js dist/index.d.ts package.json README.md; do
grep -qE "npm notice [0-9.]+[kMG]?B +$f\$" "$RUNNER_TEMP/publish.log" || { echo "::error::the package would ship without $f"; exit 1; }
grep -qx "package/$f" "$RUNNER_TEMP/files.txt" || { echo "::error::the package would ship without $f"; exit 1; }
done
- name: Licenses
env:
TARBALL: ${{ steps.pack.outputs.tarball }}
run: node ../scripts/license-gate.mjs "$TARBALL"
- name: Publish, dry run
env:
TARBALL: ${{ steps.pack.outputs.tarball }}
run: npm publish "$TARBALL" --dry-run --access public
2 changes: 2 additions & 0 deletions .github/workflows/playwright-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
rows:
name: build and rows (Node ${{ matrix.node }})
runs-on: ubuntu-latest
# A leg takes a few minutes, npm installs included: one past 30 is a hang.
timeout-minutes: 30
strategy:
# One leg failing must not cancel the others: each Node version's
# result is its own.
Expand Down
Loading
Loading