Skip to content

Activate the test and publish workflows - #36

Merged
makriman merged 2 commits into
mainfrom
ci-ready
Dec 5, 2026
Merged

makriman merged 2 commits into
mainfrom
ci-ready

Conversation

@makriman

@makriman makriman commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

No workflow exists under .github/workflows/ on main, so nothing runs on a push or a pull request (#10). This PR adds the test workflow and the npm publish workflow, and removes ci/README.md, which described how to activate them.

Review of the first version found the publish path unsafe: the npm environment it names does not exist (GitHub creates a missing environment on first use with no protection, so there was no approval gate), a release on a tag pointing at any commit would publish, npm install -g npm@latest ran unpinned in the job that holds the publish identity, a prerelease would publish as latest, README Releasing step 0 pointed at the deleted ci/README.md, and the bats suite and the MCP bridge test never ran in CI.

Change

.github/workflows/publish.yml (runs only when a GitHub release is published):

  • First step: reads the npm environment through the API and fails unless it has a required reviewer, custom deployment rules, and a tag rule v*. A missing or auto-created environment has none of these, so nothing publishes until the owner has protected it.
  • Checks out with full history and no persisted credentials, and fails unless the tagged commit is an ancestor of origin/main.
  • Installs exactly npm@11.6.2 (Trusted Publishing needs 11.5.1 or newer) and checks the installed version.
  • Keeps the check that the tag matches package.json, the CLI and io.sh.
  • The GitHub prerelease flag must agree with the version: a prerelease needs a version with a - (for example 0.3.0-rc.1) and is published with --tag next; a full release with such a version, or a prerelease with a plain version, fails. A full release publishes as latest.
  • Runs the Node tests, then npm publish. Nothing else is installed in this job; the bats suite and the bridge test run in test.yml on every push to main, which the tagged commit must be on.

.github/workflows/test.yml:

  • Runs on pull requests and pushes to main only (it ran twice per PR push before), with a concurrency group.
  • Node 20, 22, 24: version strings agree, node --test test/*.test.mjs, then installs bats and runs bats test/ when test/*.bats exists. There is no bats file on main yet; test/io-sh.bats arrives with io.sh: a usage error from --limit or an on/off flag stops before the request (exit 2) #31, and the step runs it from then on.
  • npm pack --dry-run --json now asserts that the six expected files are in the package.
  • New mcp-bridge job: checks out the public IndianOpinion/mcp next to this repo, runs npm ci --omit=dev --ignore-scripts there, runs the MCP bridge test with IO_MCP_DIR, and fails unless it passed and was not skipped.

README Releasing: step 0 is gone. The one-time steps now require, in this order, the first manual publish, then the npm environment with at least one required reviewer and a v* tag rule (and no branch rule), and only then the Trusted Publisher settings on npmjs.com. Each release step says the tag must be on a main commit, that a reviewer approves the run, and how prereleases are tagged. The Tests section mentions the bats suite and the CI jobs.

No CHANGELOG line: nothing in the published package changes apart from the README text.

Testing

  • GitHub Actions run 47467639452 on this branch: test (20), test (22), test (24) and mcp-bridge pass. The mcp-bridge log shows # pass 1 and # skipped 0.
  • Locally (Node 22): node --test test/*.test.mjs: 32 tests, 31 pass, 1 skipped (the bridge test, no ../mcp), 0 fail. The bridge test against an npm ci --omit=dev --ignore-scripts export of mcp main: 1 pass, 0 skipped. The package file-list check passes.
  • bats test/ (Bats 1.14.0) on the io.sh: a usage error from --limit or an on/off flag stops before the request (exit 2) #31 branch: 6 of 6 pass, so the new step will pass once io.sh: a usage error from --limit or an on/off flag stops before the request (exit 2) #31 is in.
  • The dist-tag step, run under bash with the four combinations: 0.3.0 full release gives latest; 0.3.0-rc.1 prerelease gives next; 0.3.0 marked prerelease and 0.3.0-rc.1 as a full release both fail.
  • The environment checks' jq expressions against real API answers: an environment with a required reviewer but no custom deployment rule fails the second check; a policy list with a v* tag rule passes.
  • publish.yml itself has not run and cannot be run without a release. Both workflow files parse as YAML; actionlint is not installed here.

Review notes

  • The environment check uses GET /repos/{repo}/environments/npm and .../deployment-branch-policies with the job token (actions: read added to the publish job). If either call fails, the job fails closed.
  • Actions stay pinned to major versions; SHA pins for the publish job would be stronger.
  • The commit that first added the workflows (4e97c37) carries a different author identity from the rest of main's history; a squash merge records the merger instead.
  • There is no .github/dependabot.yml in this repo, so this PR does not turn on Dependabot updates for actions.
  • Publishing cannot happen today: the package does not exist on npm and Trusted Publishing is not configured. The npm name is unclaimed until the owner's first manual publish (npm package "indianopinion" is not published; the README's primary install path fails #1).

Owner decision

These are settings only the owner can make, and nothing here changes them:

  1. Create the npm environment (Settings, Environments) with at least one required reviewer and a deployment rule for tags v* only, before enabling Trusted Publishing on npm. Consider turning off "Allow administrators to bypass".
  2. Then configure the Trusted Publisher on npmjs.com (IndianOpinion, cli, publish.yml, environment npm) and set publishing access to require 2FA and disallow tokens.
  3. Do the first manual publish of indianopinion (npm package "indianopinion" is not published; the README's primary install path fails #1) to claim the name.

Fixes #10

root and others added 2 commits December 4, 2026 05:59
Move ci/workflows/ to .github/workflows/ and drop ci/README.md, as that
file described. Every step of test.yml passes locally against main.
publish.yml: refuse to publish unless the npm environment has a required
reviewer and a v* tag rule, check that the tagged commit is on main, pin
npm to 11.6.2, and publish a prerelease under the next dist-tag (the
GitHub prerelease flag must agree with the version). The checkout keeps
no credentials.

test.yml: run on pull requests and pushes to main only, with a
concurrency group; run the bats suite; assert the package file list;
add an mcp-bridge job that checks out IndianOpinion/mcp and fails if the
bridge test skips.

README: drop the step that pointed at the removed ci/README.md, and make
the protected npm environment a required step before Trusted Publishing.
@makriman

makriman commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Review by Grok Bot (Indian Opinion QA agent)

Tested at head 4e97c37. Verdict: works.

Fixes: #10. The workflow file is added and its first run on this PR passed.

What I checked

  • Files changed: .github/workflows/publish.yml, .github/workflows/test.yml, ci/README.md. Outside .github/ only ci/README.md changes (docs only).
  • actionlint 1.7.12 on the workflow: exit 0, no findings.
  • publish.yml: triggers release; token permissions {"contents": "read"}. test.yml: triggers push, pull_request; token permissions {"contents": "read"}.
  • publish.yml runs only when a release is published, so it hasn't run and I can't run it (it publishes to npm through Trusted Publishing). I ran its version-check step locally with GITHUB_REF_NAME=v0.2.2: package.json, const VERSION in bin/indianopinion.mjs and IO_SH_VERSION in io.sh all say 0.2.2, so the step passes for the current version. The job-level id-token: write sits only on the publish job, and there's no npm token in the repo, which matches the comment at the top of the file.
  • Matrix: node 20, node 22, node 24. package.json engines: node >=20.

Hosted run on this PR (GitHub Actions, read from the job logs)

Job Result PHP Test summary
test (20) success - TAP plan 1..32; tests 32; pass 31; fail 0; skipped 1
test (20) success - TAP plan 1..32; tests 32; pass 31; fail 0; skipped 1
test (22) success - TAP plan 1..32; tests 32; pass 31; fail 0; skipped 1
test (22) success - TAP plan 1..32; tests 32; pass 31; fail 0; skipped 1
test (24) success - tests 32; pass 31; fail 0; skipped 1
test (24) success - tests 32; pass 31; fail 0; skipped 1

Local run on this box (PHP 8.4.28 / Node 24.22.1), this head vs main

Command This PR main
npm ci exit 0 exit 0
npm test exit 0: ℹ tests 32; ℹ pass 31; ℹ fail 0 exit 0: ℹ tests 32; ℹ pass 31; ℹ fail 0
npm audit --omit=dev found 0 vulnerabilities found 0 vulnerabilities
actionlint 1.7.12 exit 0, no findings not run

Review

  • push has no branch filter, so a branch in this repo that has an open PR runs every job twice (once for the push, once for the PR). The hosted run shows this: each job name appears twice. Limiting push to branches: [main] would stop the duplicate runs.

Not tested: I didn't rerun the hosted jobs. The table above is read from this PR's own Actions logs.

I'm Grok Bot, the automated QA agent for Indian Opinion. This is a comment-only review. I don't approve, request changes or merge. Local stack: PHP 8.4.28, Composer 2.11.3, MariaDB 11.8.9, Node 24.22.1, WordPress 7.1.5.

@makriman

makriman commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up review by Grok Bot (Indian Opinion QA agent)

Retested at head d1c31f3 (my earlier review at 4e97c37: #36 (comment)). Verdict: works.

What changed since my last review

My one note is fixed. push is now limited to main, and the new head ran once (the pull_request event), not twice.

What I checked

  • actionlint 1.7.12 on both workflows: exit 0, no findings.

  • Hosted run on this head (d1c31f3, run 47467639452, read from the job logs):

    • test (20), test (22), test (24): success. Node 24 shows tests 32, pass 31, fail 0, skipped 1.
    • mcp-bridge: success, with ok 1 - mcp: stdio bridge to the Worker, stores the token from signup_verify, # pass 1, # skipped 0. The job checks out IndianOpinion/mcp and fails if the bridge test is skipped, so this test can no longer pass by skipping.
  • Local, PHP 8.4.28 / Node 24.22.1: npm ci exit 0, npm test exit 0 (tests 32, pass 31, fail 0), npm audit --omit=dev found 0 vulnerabilities.

  • publish.yml only runs on a published release, so I can't run it. I read the new guards:

    • the npm environment must have a required reviewer and a v* tag rule;
    • the tagged commit must be on main;
    • npm is pinned to 11.6.2 and the version is asserted;
    • a prerelease goes out under next, never latest.

    I did not exercise them.

Notes

  • The bats step is a no-op today. There are no *.bats files in this branch, and all three test jobs logged no bats files in test/. The README wording ("when present in test/") is accurate, but the commit title "run bats ... in CI" reads as more than the job does. Each job still spends time on apt-get install bats. I'd drop the step, or add the io.sh bats tests it is meant for.
  • For the owner: the repository currently has no environments (GET /repos/IndianOpinion/cli/environments lists none). So the first release will stop at "The npm environment is protected" until step 2 of the README's Releasing section is done. That is the intended behaviour, but it is a manual step to schedule before the next release.

I'm Grok Bot, the automated QA agent for Indian Opinion. This is a comment-only review. I don't approve, request changes or merge. Local stack: PHP 8.4.28, Composer 2.11.3, MariaDB 11.8.9, Node 24.22.1, WordPress 7.1.5.

@makriman
makriman marked this pull request as ready for review December 5, 2026 19:58
@makriman
makriman merged commit 1bc22e6 into main Dec 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI is not active: test and publish workflows sit in ci/workflows/, so no test, version check or publish ever runs

1 participant