@d-zero/release-automation 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,8 @@ export const BLOCKER_LABEL = 'release-blocker';
13
13
  export const VERIFY_CHECK = 'release-pr-verified';
14
14
  /** The file name of the Full CI workflow the Nightly dispatches. */
15
15
  export const FULL_CI_WORKFLOW = 'full-ci.yml';
16
+ /** The file name of the Nightly workflow, whose schedule starts the Full CI of each line. */
17
+ export const NIGHTLY_WORKFLOW = 'nightly.yml';
16
18
  /**
17
19
  * Reads an environment variable that must be set.
18
20
  * @param name - The variable
@@ -7,7 +7,7 @@ import { releaseContent } from '../release-content.js';
7
7
  import { DEFAULT_SECURITY_BATCH_MINUTES } from '../types.js';
8
8
  import { classifiedLines, ensureIssue, github, localGit, RELEASE_LABEL, REPLACED_LABEL, requireEnv, summary, } from './context.js';
9
9
  import { generateRelease } from './generate.js';
10
- import { nightlyRuns } from './runs.js';
10
+ import { nightlyAddedAt, nightlyRuns } from './runs.js';
11
11
  /** The label of a pull request that fixes a vulnerability. */
12
12
  export const SECURITY_LABEL = 'security';
13
13
  /**
@@ -83,9 +83,10 @@ export async function releasePrCommand(options) {
83
83
  }
84
84
  const prs = await gh.paginate('/repos/{repo}/pulls?state=all&sort=updated&direction=desc');
85
85
  const releasePrs = prs.filter((pr) => pr.labels.some(({ name }) => name === RELEASE_LABEL));
86
+ const nightlyAdded = await nightlyAddedAt(gh);
86
87
  for (const line of targets) {
87
88
  const runs = await nightlyRuns(gh, line.branch);
88
- if (isStale(runs, now)) {
89
+ if (isStale(runs, now, nightlyAdded)) {
89
90
  await ensureIssue(gh, {
90
91
  marker: `<!-- release-automation:nightly-stale:${line.branch} -->`,
91
92
  title: `The Nightly of ${line.branch} stopped running`,
@@ -1,4 +1,25 @@
1
- import { FULL_CI_WORKFLOW } from './context.js';
1
+ import { GitHubError } from '../io/github.js';
2
+ import { FULL_CI_WORKFLOW, NIGHTLY_WORKFLOW } from './context.js';
3
+ /**
4
+ * Reads when the Nightly workflow was added to the repository, which
5
+ * {@link isStale} counts from while a line has no finished run.
6
+ * @param gh - The client
7
+ * @returns The time, or undefined when the repository has no Nightly workflow
8
+ * @example
9
+ * isStale(runs, new Date(), await nightlyAddedAt(gh));
10
+ */
11
+ export async function nightlyAddedAt(gh) {
12
+ try {
13
+ const workflow = await gh.rest('GET', `/repos/{repo}/actions/workflows/${NIGHTLY_WORKFLOW}`);
14
+ return new Date(workflow.created_at);
15
+ }
16
+ catch (error) {
17
+ if (error instanceof GitHubError && error.status === 404) {
18
+ return undefined;
19
+ }
20
+ throw error;
21
+ }
22
+ }
2
23
  /**
3
24
  * Reads the finished Nightly runs of a line: the Full CI runs started by
4
25
  * `workflow_dispatch` on the line's branch, newest first. A run that was
package/dist/nightly.js CHANGED
@@ -31,18 +31,22 @@ export function isBlocked(runs) {
31
31
  /** How long without a finished Nightly before it counts as stopped. */
32
32
  export const NIGHTLY_STALE_MS = 2 * 24 * 60 * 60 * 1000;
33
33
  /**
34
- * Tells whether the Nightly of a line stopped running. GitHub disables the
35
- * schedule of a public repository after 60 days without activity, and a
36
- * stopped Nightly would leave the gate on stale results.
34
+ * Tells whether the Nightly of a line stopped running (rule 35). GitHub
35
+ * disables the schedule of a public repository after 60 days without
36
+ * activity, and a stopped Nightly would leave the gate on stale results.
37
+ * The time counts from the newest finished run; when the line has none, from
38
+ * when the Nightly workflow was added, so a Nightly set up a moment ago is not
39
+ * taken as stopped while one that never ran is.
37
40
  * @param runs - The finished runs of the line, newest first
38
41
  * @param now - The current time
39
- * @returns Whether the newest run is older than {@link NIGHTLY_STALE_MS}, or there is none
42
+ * @param since - When the Nightly workflow was added; without it, a line with no run counts as stopped
43
+ * @returns Whether more than {@link NIGHTLY_STALE_MS} passed since the newest run, or since `since` when there is no run
40
44
  * @example
41
- * isStale([], new Date()); // true
45
+ * isStale([], new Date('2026-11-27T12:00:00Z'), new Date('2026-11-27T00:00:00Z')); // false
42
46
  */
43
- export function isStale(runs, now) {
44
- const last = runs[0];
45
- return (last === undefined || now.getTime() - last.finishedAt.getTime() > NIGHTLY_STALE_MS);
47
+ export function isStale(runs, now, since) {
48
+ const from = runs[0]?.finishedAt ?? since;
49
+ return from === undefined || now.getTime() - from.getTime() > NIGHTLY_STALE_MS;
46
50
  }
47
51
  /**
48
52
  * The marker that identifies the `release-blocker` Issue of a line.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-zero/release-automation",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Release lines, Release PRs, nightly gates and publishing for D-ZERO repositories",
5
5
  "author": "D-ZERO",
6
6
  "license": "MIT",