/
githubmirror
/
servo
Обзор
Документация
Войти
/
githubmirror
/
servo
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
.github/workflows/try-label.yml
170 строк
6 KB
eri
ci: Run devtools tests in CI (#45579)
12 июн 2026, 21:50
Не верифицирован
12 июн 2026, 21:50
1755c71
Код
Авторство
О чём код?
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@v6 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 }} devtools-tests: ${{ matrix.devtools_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 }} capi: ${{ matrix.capi }} 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}"