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
21 changes: 16 additions & 5 deletions bin/live
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
// scripts/live.sh with the token on stdin, records the pass in docs/dev/live-checks.txt and, when the branch has an
// open pull request, commits the record, pushes it and adds its line to the pull request's Conformance section.
//
// bin/live <keyring account> [arguments for scripts/live.sh, such as the test page's link]
// bin/live <keyring account> [--again] [arguments for scripts/live.sh, such as the test page's link]
//
// Linux only: it reads the keyring with secret-tool and runs scripts/live.sh with bash.
// The token is the keyring entry `service clidev-app-live account <keyring account>`, stored once with
// secret-tool store --label="clidev live check" service clidev-app-live account <keyring account>
// It stays in this process and reaches scripts/live.sh on stdin only: never an argument, the environment or the
// screen. A version whose shipped code already has a record is not checked again.
// screen. A version whose shipped code already has a record is not checked again, and it says so; --again runs the
// check anyway, as after a change to scripts/live.sh alone, which the record does not cover.
import { execFileSync, spawnSync } from "node:child_process"
import { existsSync, readFileSync, realpathSync } from "node:fs"
import { join, resolve } from "node:path"
Expand Down Expand Up @@ -105,16 +106,26 @@ const check = async (account, version, args) => {
}

const main = async () => {
const [account, ...args] = process.argv.slice(2)
const [account, ...rest] = process.argv.slice(2)
const again = rest.includes("--again")
const args = rest.filter((arg) => arg !== "--again")
if (!account || account === "--help" || account === "-h") {
process.stdout.write(`Usage: ${join(ROOT, "bin/live")} <keyring account> [arguments for scripts/live.sh]\n`)
const usage = "<keyring account> [--again] [arguments for scripts/live.sh]"
process.stdout.write(`Usage: ${join(ROOT, "bin/live")} ${usage}\n`)
process.exitCode = account ? 0 : 2
return
}
if (existsSync(KIT)) fail("this is cli-template itself, which has no service to check")
const { version } = JSON.parse(readFileSync(PACKAGE_JSON, "utf8"))
const current = run("pnpm", ["exec", "cli-dev", "live", "check", "--version", version], { stdio: "ignore" })
const record = current.status === 0 ? recordOf(version) : await check(account, version, args)
const checked = current.status === 0 && !again
if (checked) {
process.stdout.write(
`Not run: ${version}'s shipped code already passed. Run with --again to check it anyway, as after a change to ` +
"scripts/live.sh alone.\n",
)
}
const record = checked ? recordOf(version) : await check(account, version, args)
if (!record) fail(`no record for ${version} in ${RECORDS}`)

const view = run("gh", ["pr", "view", "--json", "url,state,body"], { stdio: ["ignore", "pipe", "ignore"] })
Expand Down
5 changes: 5 additions & 0 deletions changes/feat-live-again.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Fixed

- `bin/live` says when it does not run the check because the version's shipped code already passed, and `--again`
runs it anyway. A change to `scripts/live.sh` alone is not part of the record, so before this the new steps were
silently skipped and the old record was reported as a pass.
3 changes: 2 additions & 1 deletion kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ The steps run the owner's scripts the CLI gets, each one readable file that prin
- `bin/live <keyring account>` runs `scripts/live.sh` against a test account. It prints the script's `# Needs:`
lines, reads the token from the keyring entry `service <app>-live account <keyring account>` and passes it on
stdin, records the pass, and on a release branch commits the record and adds it to the pull request's Conformance
section (WC-REL-17).
section (WC-REL-17). A version whose shipped code already passed is not run again; `--again` runs it anyway, as
after a change to `scripts/live.sh` alone.

With `--spec` other than `none`, `new` also builds the `api` group from the service's API description: one command
per operation through cli-core's `serviceApiCommand`, its permissions, its tests against cli-base's `fakeApi`, and the
Expand Down
Loading