Remove support for triggering try from comments (#30712)

Triggering from labels means that we have less actions running and less
false job failures spamming project members. Plus, we have more
flexibility with labels rather than the backward compatibility we have
set up for bors comments.
This commit is contained in:
Martin Robinson 2023-11-09 11:31:49 +01:00 committed by GitHub
parent c529bfa49e
commit fe7bdb7e4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 66 deletions

View file

@ -30,15 +30,15 @@ jobs:
chunk_id: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] chunk_id: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
if: github.event_name != 'issue_comment' && github.event_name != 'pull_request_target' if: github.event_name != 'pull_request_target'
with: with:
fetch-depth: 2 fetch-depth: 2
# This is necessary to checkout the pull request if this run was triggered # This is necessary to checkout the pull request if this run was triggered via a
# via an `issue_comment` action on a pull request. # `pull_request_target` event.
- uses: actions/checkout@v3 - uses: actions/checkout@v3
if: github.event_name == 'issue_comment' || github.event_name == 'pull_request_target' if: github.event_name == 'pull_request_target'
with: with:
ref: refs/pull/${{ github.event.issue.number || github.event.number }}/head ref: refs/pull/${{ github.event.number }}/head
fetch-depth: 2 fetch-depth: 2
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v3
with: with:

View file

@ -65,15 +65,15 @@ jobs:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
if: github.event_name != 'issue_comment' && github.event_name != 'pull_request_target' if: github.event_name != 'pull_request_target'
with: with:
fetch-depth: 2 fetch-depth: 2
# This is necessary to checkout the pull request if this run was triggered # This is necessary to checkout the pull request if this run was triggered via a
# via an `issue_comment` action on a pull request. # `pull_request_target` event.
- uses: actions/checkout@v3 - uses: actions/checkout@v3
if: github.event_name == 'issue_comment' || github.event_name == 'pull_request_target' if: github.event_name == 'pull_request_target'
with: with:
ref: refs/pull/${{ github.event.issue.number || github.event.number }}/head ref: refs/pull/${{ github.event.number }}/head
fetch-depth: 2 fetch-depth: 2
- name: Run sccache-cache - name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3 uses: mozilla-actions/sccache-action@v0.0.3

View file

@ -28,15 +28,15 @@ jobs:
chunk_id: [1, 2, 3, 4, 5] chunk_id: [1, 2, 3, 4, 5]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
if: github.event_name != 'issue_comment' && github.event_name != 'pull_request_target' if: github.event_name != 'pull_request_target'
with: with:
fetch-depth: 2 fetch-depth: 2
# This is necessary to checkout the pull request if this run was triggered # This is necessary to checkout the pull request if this run was triggered via a
# via an `issue_comment` action on a pull request. # `pull_request_target` event.
- uses: actions/checkout@v3 - uses: actions/checkout@v3
if: github.event_name == 'issue_comment' || github.event_name == 'pull_request_target' if: github.event_name == 'pull_request_target'
with: with:
ref: refs/pull/${{ github.event.issue.number || github.event.number }}/head ref: refs/pull/${{ github.event.number }}/head
fetch-depth: 2 fetch-depth: 2
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v3
with: with:

View file

@ -58,15 +58,15 @@ jobs:
runs-on: macos-13 runs-on: macos-13
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
if: github.event_name != 'issue_comment' && github.event_name != 'pull_request_target' if: github.event_name != 'pull_request_target'
with: with:
fetch-depth: 2 fetch-depth: 2
# This is necessary to checkout the pull request if this run was triggered # This is necessary to checkout the pull request if this run was triggered via a
# via an `issue_comment` action on a pull request. # `pull_request_target` event.
- uses: actions/checkout@v3 - uses: actions/checkout@v3
if: github.event_name == 'issue_comment' || github.event_name == 'pull_request_target' if: github.event_name == 'pull_request_target'
with: with:
ref: refs/pull/${{ github.event.issue.number || github.event.number }}/head ref: refs/pull/${{ github.event.number }}/head
fetch-depth: 2 fetch-depth: 2
- name: Run sccache-cache - name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3 uses: mozilla-actions/sccache-action@v0.0.3

View file

@ -3,13 +3,10 @@ name: Try
on: on:
pull_request_target: pull_request_target:
types: [labeled] types: [labeled]
issue_comment:
types: [created]
jobs: jobs:
parse-comment: parse-comment:
name: Trigger Try (${{ github.event.name }}) name: Trigger Try
if: ${{ github.event_name == 'pull_request_target' || github.event.issue.pull_request }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
configuration: ${{ steps.configuration.outputs.result }} configuration: ${{ steps.configuration.outputs.result }}
@ -87,45 +84,28 @@ jobs:
unit_tests: false, unit_tests: false,
}; };
if (context.eventName == "pull_request_target") { let try_labels = [];
let try_labels = []; for (const label of context.payload.pull_request.labels) {
for (const label of context.payload.pull_request.labels) { if (!label.name.startsWith("T-")) {
if (!label.name.startsWith("T-")) { continue;
continue;
}
// Try to remove the label. If that fails, it's likely that another
// workflow has already processed it or a user has removed it.
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: label.name,
});
} catch (exception) {
console.log("Assuming '" + label.name + "' is already removed: " + exception);
continue;
}
console.log("Found label: " + label.name);
updateConfigurationFromString(label.name, configuration);
}
} else {
let tokens = context.payload.comment.body.split(/\s+/);
let tagIndex = tokens.indexOf("@bors-servo");
if (tagIndex == -1 || tagIndex + 1 >= tokens.length) {
return { platforms: [] };
} }
// Try to remove the label. If that fails, it's likely that another
let tryString = tokens[tagIndex + 1]; // workflow has already processed it or a user has removed it.
console.log("Found try string: '" + tryString + "'"); try {
if (tryString == "try") { await github.rest.issues.removeLabel({
updateConfigurationFromString("full", configuration); owner: context.repo.owner,
} else { repo: context.repo.repo,
updateConfigurationFromString(tryString, configuration); issue_number: context.issue.number,
name: label.name,
});
} catch (exception) {
console.log("Assuming '" + label.name + "' is already removed: " + exception);
continue;
} }
console.log("Found label: " + label.name);
updateConfigurationFromString(label.name, configuration);
} }
console.log(JSON.stringify(configuration)); console.log(JSON.stringify(configuration));
@ -167,7 +147,7 @@ jobs:
name: Results name: Results
needs: ["parse-comment", "run-try"] needs: ["parse-comment", "run-try"]
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ always() && fromJson(needs.parse-comment.outputs.configuration).try}} if: ${{ always() && fromJson(needs.parse-comment.outputs.configuration).platforms[0] != null }}
steps: steps:
- name: Success - name: Success
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}

View file

@ -51,15 +51,15 @@ jobs:
runs-on: windows-2019 runs-on: windows-2019
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
if: github.event_name != 'issue_comment' && github.event_name != 'pull_request_target' if: github.event_name != 'pull_request_target'
with: with:
fetch-depth: 2 fetch-depth: 2
# This is necessary to checkout the pull request if this run was triggered # This is necessary to checkout the pull request if this run was triggered via a
# via an `issue_comment` action on a pull request. # `pull_request_target` event.
- uses: actions/checkout@v3 - uses: actions/checkout@v3
if: github.event_name == 'issue_comment' || github.event_name == 'pull_request_target' if: github.event_name == 'pull_request_target'
with: with:
ref: refs/pull/${{ github.event.issue.number || github.event.number }}/head ref: refs/pull/${{ github.event.number }}/head
fetch-depth: 2 fetch-depth: 2
- name: ccache - name: ccache
uses: hendrikmuhs/ccache-action@v1.2 uses: hendrikmuhs/ccache-action@v1.2