Files
pipdock/scripts/check-tauri-lockstep.mjs
T
poli0981andClaude Opus 5.5 12bf723daa ci: failures reach someone, audits run on what is merged, releases are attested
- notify-ci-failure.yml lists its workflows by name. `workflows: ['*']` is not a wildcard to
  workflow_run: it matched nothing, so `main` was red from 2026-09-23 with no one told.
- cargo audit runs a prebuilt cargo-audit (taiki-e/install-action, pinned by commit) with
  `--deny warnings`, replacing rustsec/audit-check@v2 - Node 20, a check-run write token, and on a
  pull request a failure only for "critical", which is how September's advisories passed every PR.
  .cargo/audit.toml's contract (a new informational advisory fails CI) is now what runs.
- security-scan.yml: both audits daily against `main`, so an advisory against something already
  merged is reported the day it is published, not at the next PR.
- cargo deny (licences, sources, bans) with deny.toml: the licence allowlist makes "every bundled
  licence is GPL-3.0-compatible" a test. The workspace declares `publish = false`, which it never
  had - and without which cargo-deny judged the app crates as published ones.
- CodeQL analyses rust and actions as well as javascript-typescript. The comment saying CodeQL had
  no Rust support stopped being true in 2025.
- ci-node.yml: Pages and id-token write move from the workflow to the one job that needs them
  (Sonar S8233); the audit installs with --ignore-scripts (S6505); a new `tauri lockstep` job
  fails when a Tauri crate and its npm package drift apart on Cargo.lock and package-lock.json.
- release.yml: build (read-only token, no persisted credentials) and publish (attest + draft) are
  separate jobs; the tag must match all five version fields; SHA256SUMS.txt is LF, which
  `sha256sum -c` elsewhere needs; actions/attest-build-provenance attests the .exe and .msi;
  softprops/action-gh-release is pinned by commit; `workflow_dispatch` with `dry_run` builds any
  ref without attesting or drafting.
- ci-integration.yml also runs for the CLI, exec, audit, release metadata, errors, store, index,
  Cargo.lock and rust-toolchain.toml - every one of which its end-to-end steps run through.
- dependabot.yml: cooldowns, a group per ecosystem for Tauri packages and for actions and pip,
  TypeScript held below 6.1 (typescript-eslint's peer range), and the rust-toolchain ecosystem.
  A multi-ecosystem group would put both Tauri halves in one PR, but what it does to dependencies
  outside its patterns is undocumented; the lockstep job covers the gap instead.
- Sonar: NOSONAR with reasons on the dev scripts' argv and PATH lookups; bundle-cli.mjs no longer
  claims to run from beforeBuildCommand. The dev CSP moves out of index.html into a Vite plugin
  that reads devCsp from tauri.conf.json, so a release build carries one policy, the strict one
  (S7039); checked in the dev server, where React Refresh's preamble still runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 00:55:27 +07:00

60 lines
2.2 KiB
JavaScript

/**
* Fail when the Tauri crates and the `@tauri-apps/*` packages are on different minors.
*
* Tauri checks this itself and refuses to start — at runtime, on the user's machine — when the
* `tauri` crate and `@tauri-apps/api` disagree on major.minor. Dependabot bumps Cargo and npm in
* separate pull requests, each green on its own, so merging one of them alone ships a build that
* compiles and does not open. This reads both lockfiles, so it checks what is built rather than
* what the manifests ask for.
*
* Plugins move independently of the core (`tauri-plugin-dialog` 2.8 sits beside `tauri` 2.12), so
* each plugin crate is compared with its own npm package, not with `tauri`.
*/
import { readFileSync } from 'node:fs'
const PAIRS = [
['tauri', '@tauri-apps/api'],
['tauri-plugin-dialog', '@tauri-apps/plugin-dialog'],
['tauri-plugin-opener', '@tauri-apps/plugin-opener'],
['tauri-plugin-clipboard-manager', '@tauri-apps/plugin-clipboard-manager'],
]
/** Every `name = "…" / version = "…"` pair in Cargo.lock. */
function crateVersions() {
const lock = readFileSync('Cargo.lock', 'utf8')
const out = new Map()
for (const block of lock.split('[[package]]')) {
const name = /^name = "([^"]+)"$/m.exec(block)?.[1]
const version = /^version = "([^"]+)"$/m.exec(block)?.[1]
if (name !== undefined && version !== undefined) out.set(name, version)
}
return out
}
function npmVersion(name) {
const lock = JSON.parse(readFileSync('package-lock.json', 'utf8'))
return lock.packages?.[`node_modules/${name}`]?.version
}
const minor = (v) => v.split('.').slice(0, 2).join('.')
const crates = crateVersions()
let failed = false
for (const [crate, pkg] of PAIRS) {
const rust = crates.get(crate)
const js = npmVersion(pkg)
if (rust === undefined || js === undefined) {
console.error(`missing: ${crate} ${rust ?? '(not in Cargo.lock)'} / ${pkg} ${js ?? '(not in package-lock.json)'}`)
failed = true
continue
}
const ok = minor(rust) === minor(js)
console.log(`${ok ? 'ok ' : 'FAIL'} ${crate} ${rust} ${pkg} ${js}`)
if (!ok) failed = true
}
if (failed) {
console.error('Bump the crate and its npm package together; Tauri will not start otherwise.')
process.exit(1)
}