-
-
Notifications
You must be signed in to change notification settings - Fork 349
ci: init pr.yml
and merge-queue.yml
workflows
#3628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
name: lint | ||
|
||
on: | ||
pull_request: | ||
paths-ignore: | ||
- "**.md" | ||
- "**.svg" | ||
- ".gitignore" | ||
- "LICENSE" | ||
- "flake.lock" | ||
workflow_call: | ||
inputs: | ||
ref: | ||
required: true | ||
type: string | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
treefmt: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
|
||
- name: Install Nix | ||
uses: cachix/install-nix-action@v31 | ||
with: | ||
extra_nix_config: | | ||
extra-substituters = https://nix-community.cachix.org | ||
extra-trusted-public-keys = nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= | ||
|
||
- name: Run treefmt check | ||
run: nix build .#checks.x86_64-linux.treefmt --accept-flake-config | ||
run: nix build .#checks.x86_64-linux.treefmt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Merge Queue | ||
|
||
on: | ||
merge_group: | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
lint: | ||
uses: ./.github/workflows/lint.yml | ||
with: | ||
ref: ${{ github.event.merge_group.head_sha }} | ||
|
||
# This job posts the "Required Status Checks" to satisfy our ruleset. | ||
required-checks: | ||
# It "needs" all the jobs that should block the Merge Queue. | ||
# Modify this list to add or remove jobs from required status checks. | ||
needs: | ||
- lint | ||
|
||
name: Required checks | ||
runs-on: ubuntu-24.04-arm | ||
permissions: | ||
statuses: write | ||
steps: | ||
- uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const { serverUrl, repo, runId, payload } = context | ||
await github.rest.repos.createCommitStatus({ | ||
...repo, | ||
sha: payload.merge_group.head_sha, | ||
target_url: `${serverUrl}/${repo.owner}/${repo.repo}/actions/runs/${runId}`, | ||
// WARNING: | ||
// Do NOT change the context name or it will not match the ruleset. | ||
// This would prevent all PRs from merging. | ||
context: 'PR checks successful', | ||
state: 'success', | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: PR | ||
|
||
on: | ||
pull_request_target: | ||
Comment on lines
+3
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One downside of going with the Overall, it might be simpler to use the non-javascript-status approach here with the old "skipped vs failed job" approach. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, this is frustrating. Maybe I should consider adding a "testing"
I'm of two minds here:
I like the idea of the better impl because we can choose a saner name for the required check from the start. It's also less confusing for contributors if we have a green check, rather than a grey one. |
||
|
||
concurrency: | ||
group: pr-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
lint: | ||
uses: ./.github/workflows/lint.yml | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
# This job posts the "Required Status Checks" to satisfy our ruleset. | ||
required-checks: | ||
# It "needs" all the jobs that should block merging a PR. | ||
# Modify this list to add or remove jobs from required status checks. | ||
needs: | ||
- lint | ||
|
||
name: Required checks | ||
runs-on: ubuntu-24.04-arm | ||
permissions: | ||
statuses: write | ||
steps: | ||
- uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const { serverUrl, repo, runId, payload } = context | ||
await github.rest.repos.createCommitStatus({ | ||
...repo, | ||
sha: payload.pull_request.head.sha, | ||
target_url: `${serverUrl}/${repo.owner}/${repo.repo}/actions/runs/${runId}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you leave out the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. I copied this from your |
||
// WARNING: | ||
// Do NOT change the context name or it will not match the ruleset. | ||
// This would prevent all PRs from merging. | ||
context: 'PR checks successful', | ||
state: 'success', | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optionally, we could combine
pr.yml
andmerge-queue.yml
into a single workflow.We'd need to do things like
${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
and it'd be more difficult to specify different checks for PRs vs the Queue.But it would remove a lot of duplication.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes a lot of sense to re-use the same file when you can. It looks like this should be easily possible here.
You could even change the
run-name
so you don't get "PR" for both.