Repository navigation
Conversation
|
@DatMitro What is the proposed interface to use snapshots? E.g Would we have snapshot committed with github actions checks present? |
dce4021 to
f08bd17
Compare
…ctors - collector: honor IPA_COLLECTOR_FILE for the output path - scripts/ipa-snapshot.js: lint a spec and write sorted findings.json plus collector.json multiset counts - scripts/ipa-snapshot-compare.js: per-rule added/removed between two snapshots, exit 1 on any difference
ipa-snapshot-compare.js takes --spec and --base (and optionally --head) and does what had to be done by hand: it checks each ref out into a temporary worktree, lints the spec with that ref's ruleset, compares, and removes the worktree and snapshots. The scripts and the spec come from this checkout, so the base ref does not need to contain them. The two-directory form is unchanged. Adds the usage to the IPA CONTRIBUTING guide.
f08bd17 to
ba120df
Compare
Right now it's a manual dev tool, with no committed snapshots and no CI check. You run ipa-snapshot.js on the base and on the change, then ipa-snapshot-compare.js on the two outputdirs. I wouldn't commit snapshots: the collector one is ~166 MB on v2.json, and both are cheap to regenerate from any ref. A CI job that snapshots base and head is possible, but it would fail on every intentional rule change. I can make a follow-up item to add the changes as a non-blocking comment on PRs |
|
@DatMitro how exactly do you plan to use these scripts in the future subtasks of https://jira.mongodb.org/browse/CLOUDP-453870 ? |
@maks-m-mongo-leaf I will run it after every change to ensure no classification differences were made during the refactor. In future migrations/fixes as well. I already ran it on the other open PR as it's stacked. |
Proposed changes
Adds two dev scripts for checking that a change to the IPA ruleset does not change its results:
ipa-snapshot.jslints a spec and writes the findings and the collector entries (violations, adoptions, exceptions) as sorted JSON.ipa-snapshot-compare.jscompares two snapshots per rule, or this checkout against a git ref, and exits 1 on any difference, so a refactor can be shown to be behavior-neutral.The collector log path can now be set with
IPA_COLLECTOR_FILE, so a snapshot does not overwrite the log in the working directory.Usage. These are manual dev scripts. Nothing is committed and no CI check is added. To check that a change does not alter results, compare this checkout against a git ref:
node tools/spectral/ipa/scripts/ipa-snapshot-compare.js --spec openapi/v2.json --base origin/main # add --verbose for the entriesThe ref is checked out into a temporary worktree (nothing to build) and removed afterwards, the head is this checkout including uncommitted changes (or
--head <git-ref>), and the scripts and spec come from your checkout, so the base ref does not need to contain them. A run onopenapi/v2.jsontakes about 15 seconds. To keep snapshots, write them withipa-snapshot.js --spec <file> --out <dir>and compare two directories withipa-snapshot-compare.js <base-dir> <head-dir>; they are large (the collector one is about 166 MB onv2.json, mostly one adoption entry per component per rule), so they are not meant to be committed. Also documented in the IPA CONTRIBUTING guide.Jira ticket: CLOUDP-453871
Checklist
Changes to Spectral
Further comments
Used by the later sub-tasks of CLOUDP-453870. Nothing in the lint run changes: only the collector file name is read from an environment variable.