willfire 0.1.26 → 0.1.27
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.
- package/dist/predict/predict.js +21 -7
- package/package.json +1 -1
package/dist/predict/predict.js
CHANGED
|
@@ -35,10 +35,18 @@ export async function predict(github, repo, prNumber, opts = {}) {
|
|
|
35
35
|
};
|
|
36
36
|
const headSha = pr.head.sha;
|
|
37
37
|
/**
|
|
38
|
-
* The PR's own repo at the head commit —
|
|
39
|
-
* a commit id, so its `ref` and `sha` are the same
|
|
38
|
+
* The PR's own repo at the head commit — the surface the skip instruction is
|
|
39
|
+
* read from, and already a commit id, so its `ref` and `sha` are the same
|
|
40
|
+
* string.
|
|
40
41
|
*/
|
|
41
42
|
const headSource = { owner, repo: name, ref: headSha, sha: headSha };
|
|
43
|
+
/**
|
|
44
|
+
* GitHub evaluates a `pull_request` at the test merge, not the head (#105).
|
|
45
|
+
* Null when it has none: a conflict, or a merge not computed yet.
|
|
46
|
+
*/
|
|
47
|
+
const mergeSha = pr.merge_commit_sha;
|
|
48
|
+
const readSource = mergeSha === null ? headSource : { owner, repo: name, ref: mergeSha, sha: mergeSha };
|
|
49
|
+
const readLabel = readSource.sha === headSha ? "head" : "the test merge commit";
|
|
42
50
|
// Provenance for the answer, filled as expansion reaches each source. The head
|
|
43
51
|
// is in from the start: it is read even on the skip path, where the commit
|
|
44
52
|
// message is what decides the verdict.
|
|
@@ -51,6 +59,7 @@ export async function predict(github, repo, prNumber, opts = {}) {
|
|
|
51
59
|
if (SKIP_RE.test(headMsg) || SKIP_TRAILER_RE.test(headMsg)) {
|
|
52
60
|
return finalizePrediction([], "head commit message contains a skip instruction", sources);
|
|
53
61
|
}
|
|
62
|
+
sources.set(sourceKey(readSource), readSource);
|
|
54
63
|
// A `uses:` naming a tag is the same lookup from every caller that writes it,
|
|
55
64
|
// so resolve each `owner/repo@ref` once. Misses are cached too: a ref that
|
|
56
65
|
// cannot be resolved will not start resolving on the second ask.
|
|
@@ -115,7 +124,7 @@ export async function predict(github, repo, prNumber, opts = {}) {
|
|
|
115
124
|
const reader = { fetchWorkflow, resolveRef };
|
|
116
125
|
// Execution is on by default and costs nothing until a workflow needs it.
|
|
117
126
|
const executor = opts.executor === undefined
|
|
118
|
-
? makeLiveExecutor(github,
|
|
127
|
+
? makeLiveExecutor(github, readSource, resolveRef)
|
|
119
128
|
: (opts.executor ?? undefined);
|
|
120
129
|
const workflows = await github.paginate(github.rest.actions.listRepoWorkflows, {
|
|
121
130
|
...base,
|
|
@@ -134,13 +143,18 @@ export async function predict(github, repo, prNumber, opts = {}) {
|
|
|
134
143
|
{ workflow: path, job: "*", status: "no-dispatch", reason: `workflow state: ${state}` },
|
|
135
144
|
];
|
|
136
145
|
}
|
|
137
|
-
const content = await fetchWorkflow(path,
|
|
146
|
+
const content = await fetchWorkflow(path, readSource);
|
|
138
147
|
if (content === null) {
|
|
139
148
|
// The Actions API keeps listing a workflow as `active` after its file is
|
|
140
|
-
// deleted. There is no file
|
|
149
|
+
// deleted. There is no file to evaluate, so there is nothing to dispatch —
|
|
141
150
|
// the same verdict as the disabled case above, reached a different way.
|
|
142
151
|
return [
|
|
143
|
-
{
|
|
152
|
+
{
|
|
153
|
+
workflow: path,
|
|
154
|
+
job: "*",
|
|
155
|
+
status: "no-dispatch",
|
|
156
|
+
reason: `no workflow file at ${readLabel}`,
|
|
157
|
+
},
|
|
144
158
|
];
|
|
145
159
|
}
|
|
146
160
|
let wf;
|
|
@@ -157,7 +171,7 @@ export async function predict(github, repo, prNumber, opts = {}) {
|
|
|
157
171
|
if (!dispatches) {
|
|
158
172
|
return [{ workflow: path, job: "*", status: "no-dispatch", reason }];
|
|
159
173
|
}
|
|
160
|
-
const jobs = await expandJobs(wf, ctx, reader,
|
|
174
|
+
const jobs = await expandJobs(wf, ctx, reader, readSource, 0, "", true, prFacts, executor);
|
|
161
175
|
return jobs.map((j) => ({
|
|
162
176
|
workflow: path,
|
|
163
177
|
job: jobName(j.job),
|