mirror of
https://github.com/servo/servo
synced 2026-04-25 17:15:48 +02:00
I got so many warnings about [Node 20 EOL](https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/) in the [try](https://github.com/servo/servo/actions/runs/22945103342): > The following actions are running on Node.js 20 and may not work as expected... We avoid touching those actions forked from web-platform-tests. Testing: If this can merge, it is successful. --------- Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
169 lines
6.2 KiB
YAML
169 lines
6.2 KiB
YAML
name: Try (Label)
|
|
|
|
on:
|
|
pull_request_target:
|
|
types: [labeled]
|
|
|
|
jobs:
|
|
parse-comment:
|
|
name: Trigger Try
|
|
runs-on: ubuntu-latest
|
|
concurrency:
|
|
group: try-${{ github.event.number }}
|
|
outputs:
|
|
configuration: ${{ steps.configuration.outputs.config }}
|
|
try_string: ${{ steps.try_string.outputs.result }}
|
|
steps:
|
|
- name: Collect Labels
|
|
uses: actions/github-script@v8
|
|
id: try_string
|
|
with:
|
|
result-encoding: string
|
|
script: |
|
|
function makeComment(body) {
|
|
console.log(body);
|
|
|
|
github.rest.issues.createComment({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body
|
|
})
|
|
}
|
|
|
|
let try_string = "";
|
|
|
|
for (let label of context.payload.pull_request.labels) {
|
|
if (!label.name.startsWith("T-")) {
|
|
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);
|
|
// Remove the "T-" prefix.
|
|
label = label.name.slice(2);
|
|
try_string += " " + label;
|
|
}
|
|
|
|
console.log(try_string);
|
|
|
|
// Exit early if the try string is empty (no try triggered).
|
|
if (!try_string.trim()) {
|
|
return "";
|
|
}
|
|
|
|
return try_string;
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
sparse-checkout: |
|
|
python/servo/try_parser.py
|
|
.github/actions/setup-python
|
|
.python-version
|
|
uv.lock
|
|
sparse-checkout-cone-mode: false
|
|
- name: Setup Python
|
|
uses: ./.github/actions/setup-python
|
|
- name: Parse Labels
|
|
if: ${{ steps.try_string.outputs.result }}
|
|
id: configuration
|
|
run: |
|
|
{
|
|
echo 'config<<EOF'
|
|
python ./python/servo/try_parser.py ${{ steps.try_string.outputs.result }}
|
|
echo EOF
|
|
} >> $GITHUB_OUTPUT
|
|
- name: Comment Run Start
|
|
if: ${{ steps.try_string.outputs.result }}
|
|
uses: actions/github-script@v8
|
|
with:
|
|
result-encoding: string
|
|
script: |
|
|
let config = ${{ steps.configuration.outputs.config }};
|
|
function makeComment(body) {
|
|
console.log(body);
|
|
|
|
github.rest.issues.createComment({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body
|
|
})
|
|
}
|
|
|
|
const url = context.serverUrl +
|
|
"/" + context.repo.owner +
|
|
"/" + context.repo.repo +
|
|
"/actions/runs/" + context.runId;
|
|
const formattedURL = "[#" + context.runId + "](" + url + ")";
|
|
makeComment("🔨 Triggering try run (" + formattedURL + ") for "
|
|
+ config.matrix.map(m => m.name).join(", "));
|
|
|
|
run-try:
|
|
if: ${{ needs.parse-comment.outputs.try_string }}
|
|
needs: ["parse-comment"]
|
|
name: ${{ matrix.name }}
|
|
strategy:
|
|
fail-fast: ${{ fromJson(needs.parse-comment.outputs.configuration).fail_fast }}
|
|
matrix:
|
|
include: ${{ fromJson(needs.parse-comment.outputs.configuration).matrix }}
|
|
# We need to use `dispatch-workflow.yml` because workflows do not support using: ${}.
|
|
uses: ./.github/workflows/dispatch-workflow.yml
|
|
secrets: inherit
|
|
with:
|
|
workflow: ${{ matrix.workflow }}
|
|
wpt: ${{ matrix.wpt }}
|
|
profile: ${{ matrix.profile }}
|
|
unit-tests: ${{ matrix.unit_tests }}
|
|
build-libservo: ${{ matrix.build_libservo }}
|
|
wpt-args: ${{ matrix.wpt_args }}
|
|
build-args: ${{ matrix.build_args }}
|
|
number-of-wpt-chunks: ${{ matrix.number_of_wpt_chunks }}
|
|
bencher: ${{ matrix.bencher }}
|
|
coverage: ${{ matrix.coverage }}
|
|
|
|
results:
|
|
name: Results
|
|
needs: ["parse-comment", "run-try"]
|
|
runs-on: ubuntu-latest
|
|
if: ${{ always() && needs.parse-comment.outputs.try_string }}
|
|
steps:
|
|
- name: Post PR Comment with results
|
|
env:
|
|
PR_NUMBER: ${{ github.event.number }}
|
|
ACTIONS_RUN_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
REQUIRED_MQ_JOBS_SUCCEEDED=${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
|
|
# Using `contains()` on the output object doesn't seem to work, so we convert to JSON and use
|
|
# jq at runtime to check the fields of the optional jobs.
|
|
OPTIONAL_JOB_STATUS_JSON="${{toJSON(needs.run-try.outputs.ohos_optional_job_status)}}"
|
|
OPTIONAL_JOBS_SUCCEEDED=$(echo "${OPTIONAL_JOB_STATUS_JSON}" | jq 'all(.[].result == "success"; .)')
|
|
# The variables expand to `true` or `false`, which can be directly run to evaluate the condition.
|
|
if ${REQUIRED_MQ_JOBS_SUCCEEDED} && ${OPTIONAL_JOBS_SUCCEEDED} ; then
|
|
RESULT_EMOJI="✨"
|
|
TRY_RESULT="succeeded."
|
|
elif ${REQUIRED_MQ_JOBS_SUCCEEDED} ; then
|
|
RESULT_EMOJI="⚠️"
|
|
TRY_RESULT="succeeded with failures of jobs that don't block the Merge Queue. Please check the workflow run for details."
|
|
elif ${{ contains(needs.*.result, 'failure') }} ; then
|
|
RESULT_EMOJI="⚠️"
|
|
TRY_RESULT="failed!"
|
|
else
|
|
RESULT_EMOJI="⚠️"
|
|
TRY_RESULT="cancelled."
|
|
fi
|
|
gh pr comment ${PR_NUMBER} --repo ${{ github.repository }} --body "${RESULT_EMOJI} Try run ([#${{ github.run_id }}](${ACTIONS_RUN_URL})) ${TRY_RESULT}"
|