Skip to content

fix: run the backfill post step unless the job was cancelled - #13

Merged
nWidart merged 2 commits into
mainfrom
fix/backfill-post-if-cancelled
Nov 28, 2026
Merged

nWidart merged 2 commits into
mainfrom
fix/backfill-post-if-cancelled

Conversation

@nWidart

@nWidart nWidart commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #12.

Owner review: this changes when a step that reads MORTISE_TOKEN runs (the backfill post step now also runs after a failed step), and it leads to the v1.1.1 release.

What changes

  • action.yml: post-if: success() becomes post-if: '!cancelled()', as decided on The backfill post step is skipped when a step of the job fails #12. The post step runs after a failed step, and not when the job is cancelled.
  • README.md: the sentence "a failed step before it means no backfill on that run" is replaced: the backfill also runs after a failed step, not on a cancelled job, and does nothing when the action did not install mortise. When mortise push failed or did not run, the backfill still sends the past weeks and the next push sends the checked-out commit.
  • tests/post.test.js: a test that pins the condition. A test runs main.js against a fake release served from file:// that fails half way: no release, a wrong SHA-256, and a binary that prints another version. It checks each error, that GITHUB_STATE stays empty, and that the post step then prints nothing. It runs on Linux, macOS and Windows. A third test, which skips on Windows, shows that a good fake release writes the state the post step reads.
  • post.js, main.js and setup.sh do not change.

Why a half-way failure does nothing

setup.sh writes the state (mortise= and version=) in its last lines, after the download, the SHA-256 check, the unpack and the --version check. Every failure before that exits through fail first. post.js returns without a word when either state value is missing. A failed input check in main.js exits before setup.sh runs. When a step before setup-mortise failed (such as the checkout), the main step never ran, so the runner has no post step for it at all.

The cases the old condition hid

In every case the post step exits 0, so it never changes the result of the job, and it does nothing on a pull request, on another branch or without a token, as before. post.js never prints the token; mortise hides it in every message it prints from the service.

  1. The check step failed (the case of The backfill post step is skipped when a step of the job fails #12). The push of HEAD arrived. The backfill fills the past weeks, as on a job that passed.
  2. The mortise push step failed.
    • A wrong token: the backfill asks the service with the same token and gets 401. mortise backfill says the token was refused and exits non-zero; the post step prints one warning. The job had already failed.
    • The service refused for the plan or billing (402, 403): the backfill sends nothing, says why and exits 0.
    • The service is out of reach: the backfill says so and exits 0.
    • The service refused the document of HEAD (422): the backfill asks which weeks to fill and sends them. A past document the service refuses too stops the backfill with a warning.
  3. A step after setup-mortise and before mortise push failed (such as the tests), so the service has no snapshot of HEAD. The backfill sends the past weeks (it never sends HEAD itself). This does no harm: the service knows the app from its token, a past commit never replaces a live push, does not count as the first snapshot of the app, and does not move the current state of the app. The next push sends HEAD. The past weeks only arrive before the current one.
  4. The job was cancelled (by hand, by a timeout, or by fail-fast of a matrix): no backfill, as before.

Proof

  • Unit tests: node --test tests/post.test.js, 13 pass locally; CI runs them on Linux, macOS and Windows.
  • A real run on this branch, with a temporary workflow that is no longer in the pull request: a job ran uses: ./ with backfill: true and a fake token, then a step that fails on purpose. Run https://github.com/mortise-dev/setup-mortise/actions/runs/46168878540: "Fail on purpose: failure", then "Post Run ./: success" (with post-if: success() it was "skipped", as in the run cited on The backfill post step is skipped when a step of the job fails #12). On a pull request the post step prints nothing, so this proves the step runs, not what it sends.
  • After the merge, v1.1.1 gets the same check with the exact generated workflow in mortise-check, whose check step fails on purpose, before v1 moves.

A failed step before the post step, such as mortise check on a problem of
the app, skipped the backfill. The post step now runs unless the job was
cancelled. It still does nothing when the main step did not install mortise.
@nWidart
nWidart force-pushed the fix/backfill-post-if-cancelled branch from 5065ec3 to 80fdc9d Compare November 28, 2026 17:09
@nWidart nWidart self-assigned this Nov 28, 2026
@nWidart
nWidart marked this pull request as ready for review November 28, 2026 17:09
@nWidart nWidart added request-sol-review PR bot: ask GPT-6.2 Sol for a review review-sol-started PR bot: sol review started and removed request-sol-review PR bot: ask GPT-6.2 Sol for a review labels Nov 28, 2026

@nWidart nWidart left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT-6.2 Sol with OCR review of 80fdc9d

Verdict: CHANGES · Review effort: 2/5

Security: None found.

Tests: All 12 tests passed on Linux with the default temp path. The tests pin the metadata and cover the missing-state guard, but CI does not exercise post-step scheduling on a cancelled job or an actual backfill after a failed default-branch job.

Coverage: 2 of 2 files reviewed in OCR delegation mode, 1 excluded by OCR.

# Severity Finding Where
1 Medium Handle CRLF checkouts tests/post.test.js:176, inline
2 Medium Encode the fixture URL tests/post.test.js:197, inline

Comment thread tests/post.test.js Resolved
Comment thread tests/post.test.js Resolved
@nWidart nWidart added review-sol-ended PR bot: sol review ended and removed review-sol-started PR bot: sol review started labels Nov 28, 2026
@nWidart
nWidart merged commit 4ed8fae into main Nov 28, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-sol-ended PR bot: sol review ended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The backfill post step is skipped when a step of the job fails

1 participant