ci(build): build pull requests merged into current main

This commit is contained in:
Dean Galvin committed 2026-10-09 23:00:01 +13:00
1 parent 43972e69a1
commit 5994806a8b
2 files changed
+11 -4

No files matched your search

+10 -3
View File
@@ -72,13 +72,20 @@ jobs:
if (!Number.isSafeInteger(pull_number) || pull_number < 1) {
throw new Error('Invalid pull request number');
}
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number });
let { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number });
for (let attempt = 0; pr.mergeable === null && attempt < 10; ++attempt) {
await new Promise((resolve) => setTimeout(resolve, 3000));
({ data: pr } = await github.rest.pulls.get({ owner, repo, pull_number }));
}
if (pr.state !== 'open' || pr.base.ref !== 'main') {
throw new Error('The pull request must be open and target main');
}
if (!manual && pr.head.sha !== context.payload.pull_request.head.sha) {
throw new Error('The pull request has newer commits; use the latest run');
}
if (pr.mergeable !== true || !pr.merge_commit_sha) {
throw new Error('The pull request does not merge cleanly into main; rebase it first');
}
let relinker = manual;
if (!manual) {
const { data: commits } = await github.rest.repos.listCommits({
@@ -86,11 +93,11 @@ jobs:
});
relinker = commits.length > 0;
}
core.setOutput('sha', pr.head.sha);
core.setOutput('sha', pr.merge_commit_sha);
core.setOutput('relinker', relinker);
core.setOutput('full', manual);
await core.summary.addRaw(
`PR #${pull_number} at ${pr.head.sha}: full builds ${manual ? 'enabled' : 'disabled'}, ` +
`PR #${pull_number} at ${pr.head.sha} merged into main as ${pr.merge_commit_sha}: full builds ${manual ? 'enabled' : 'disabled'}, ` +
`relinker ${relinker ? 'enabled' : 'skipped because the author has no commit in main'}`
).write();
+1 -1
View File
@@ -31,7 +31,7 @@ Python 3 is optional; without it some relinker tests are not registered.
Every push to `main`, including a merged pull request, automatically runs full Linux and Windows builds and tests and the relinker matrix on Linux, Windows and macOS, using the pushed commit without contributor checks.
For pull requests, full Linux and Windows builds and tests run only when a collaborator with write access selects Actions > Build > Run workflow on `main` and enters an open pull request number targeting `main`. This manual run also builds and tests the relinker on Linux, Windows and macOS, regardless of the author's previous contributions or the changed files. The relinker matrix also runs automatically when a pull request targeting `main` is opened, updated or reopened, if its author already has a commit in `main`; full builds never run automatically for pull requests. All build jobs use the selected pull request head commit. New commits require another manual run for full builds.
For pull requests, full Linux and Windows builds and tests run only when a collaborator with write access selects Actions > Build > Run workflow on `main` and enters an open pull request number targeting `main`. This manual run also builds and tests the relinker on Linux, Windows and macOS, regardless of the author's previous contributions or the changed files. The relinker matrix also runs automatically when a pull request targeting `main` is opened, updated or reopened, if its author already has a commit in `main`; full builds never run automatically for pull requests. All build jobs build the selected pull request merged into the current `main` (GitHub's merge commit), so a pull request that no longer merges cleanly must be rebased first. New commits require another manual run for full builds.
The Conventions check runs automatically for every contributor, including first-time contributors. It uses the base branch checker and reads pull request Git objects without executing pull request code. The Conventions check runs on every pull request and fails when a rule on this page is broken. It accepts code comments only when the pull request also changes [TechnicalDebt](docs/dev/TechnicalDebt.md), and only UTF-8 text files. Run it locally before pushing: