API Surface Comment workflow (sebastianbergmann/phpunit)
The API Surface Comment workflow from sebastianbergmann/phpunit, explained and optimized by Latchkey.
CI health: A - excellent
Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the API Surface Comment workflow from the sebastianbergmann/phpunit repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
# https://github.com/marketplace/actions/api-surface-check-for-php
on:
# zizmor: ignore[dangerous-triggers] workflow_run is required to comment on
# PRs from forks; this workflow only runs a pinned action and does not check
# out PR-controlled code.
workflow_run:
workflows: ["API Surface Check"]
types: [completed]
name: "API Surface Comment"
permissions:
contents: read
concurrency:
group: api-surface-comment-${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}
cancel-in-progress: true
jobs:
check-api-surface:
name: Check API Surface
runs-on: ubuntu-latest
permissions:
pull-requests: write # required to post the API surface diff comment on the PR
steps:
- uses: composer/api-surface-check@bba9f1cb940df6e02271b1b6158679ac0b3f39d3 # 1.0.1
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
# https://github.com/marketplace/actions/api-surface-check-for-php on: # zizmor: ignore[dangerous-triggers] workflow_run is required to comment on # PRs from forks; this workflow only runs a pinned action and does not check # out PR-controlled code. workflow_run: workflows: ["API Surface Check"] types: [completed] name: "API Surface Comment" permissions: contents: read concurrency: group: api-surface-comment-${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }} cancel-in-progress: true jobs: check-api-surface: timeout-minutes: 30 name: Check API Surface runs-on: latchkey-small permissions: pull-requests: write # required to post the API surface diff comment on the PR steps: - uses: composer/api-surface-check@bba9f1cb940df6e02271b1b6158679ac0b3f39d3 # 1.0.1
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.