mirror of
https://github.com/Facepunch/sbox-public.git
synced 2025-12-23 22:48:07 -05:00
PR triage requires checks to pass (#3503)
* Add formatting workflow to git filter-repo path rename * Verify checks pass before triaging
This commit is contained in:
58
.github/workflows/pull_request.yml
vendored
58
.github/workflows/pull_request.yml
vendored
@@ -8,10 +8,56 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.label.name == 'triaged'
|
||||
steps:
|
||||
- name: Repository Dispatch
|
||||
uses: peter-evans/repository-dispatch@v4
|
||||
- name: Ensure PR checks passed
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
token: ${{ secrets.SBOXBOT_TOKEN }}
|
||||
repository: Facepunch/sbox
|
||||
event-type: pr-triaged
|
||||
client-payload: '{"github": ${{ toJson(github) }}}'
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const requiredChecks = ['Tests', 'Formatting'];
|
||||
|
||||
const pr = context.payload.pull_request;
|
||||
if (!pr) {
|
||||
throw new Error('No pull request found in event payload.');
|
||||
}
|
||||
|
||||
const { data } = await github.rest.checks.listForRef({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
ref: pr.head.sha,
|
||||
per_page: 100
|
||||
});
|
||||
|
||||
const checkRuns = data.check_runs ?? [];
|
||||
for (const requiredCheck of requiredChecks) {
|
||||
const match = checkRuns.find(run => (run.name ?? '') === requiredCheck);
|
||||
|
||||
if (!match || match.conclusion !== 'success') {
|
||||
const status = match ? (match.conclusion ?? match.status ?? 'unknown') : 'missing';
|
||||
core.warning(`Required check '${requiredCheck}' did not pass (${status}). Removing triaged label.`);
|
||||
|
||||
await github.rest.issues.removeLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: pr.number,
|
||||
name: 'triaged'
|
||||
});
|
||||
|
||||
throw new Error('Cannot triage until required checks succeed.');
|
||||
}
|
||||
}
|
||||
|
||||
- name: Repository Dispatch
|
||||
uses: actions/github-script@v7
|
||||
env:
|
||||
DISPATCH_CONTEXT: ${{ toJson(github) }}
|
||||
with:
|
||||
github-token: ${{ secrets.SBOXBOT_TOKEN }}
|
||||
script: |
|
||||
const clientPayload = JSON.parse(process.env.DISPATCH_CONTEXT);
|
||||
|
||||
await github.rest.repos.createDispatchEvent({
|
||||
owner: 'Facepunch',
|
||||
repo: 'sbox',
|
||||
event_type: 'pr-triaged',
|
||||
client_payload: { github: clientPayload }
|
||||
});
|
||||
|
||||
2
.github/workflows/pull_request_checks.yml
vendored
2
.github/workflows/pull_request_checks.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Pull Request Checks
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
27
.github/workflows/pull_request_formatting.yml
vendored
Normal file
27
.github/workflows/pull_request_formatting.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
name: Formatting
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
format:
|
||||
runs-on: [ windows-latest ]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
clean: true
|
||||
fetch-depth: 1
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v5
|
||||
with:
|
||||
dotnet-version: '10.0.x'
|
||||
|
||||
- name: Format
|
||||
run: dotnet run --project .\engine\Tools\SboxBuild\SboxBuild.csproj -- format --verify
|
||||
Reference in New Issue
Block a user