Format + Docs Workflow workflow (starship/starship)
The Format + Docs Workflow workflow from starship/starship, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Format + Docs Workflow workflow from the starship/starship repository, a real project running GitHub Actions. It is shown here with attribution under its ISC license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Format + Docs Workflow
on:
push:
paths: ["docs/**", "**.md", "**.toml", "**.js", "**.json", "**.ts"]
pull_request:
paths: ["docs/**", "**.md", "**.toml", "**.js", "**.json", "**.ts"]
jobs:
# Run the dprint code formatter for documentation
dprint:
name: Dprint [Docs Formatter]
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Docs | Format
uses: dprint/check@9cb3a2b17a8e606d37aae341e49df3654933fc23 # v2.3
# Validate preset files
taplo:
name: Taplo [Preset schema validation]
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install | Taplo
uses: taiki-e/install-action@b8cecb83565409bcc297b2df6e77f030b2a468d5 # v2.82.0
with:
tool: taplo-cli@0.10.0
- name: Presets | Validate with schema
run: taplo lint --schema "file://${GITHUB_WORKSPACE}/.github/config-schema.json" docs/public/presets/toml/*.toml
# If this is not a Crowdin PR, block changes to translated documentation
block-crowdin:
name: Block Translated Changes
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref != 'i18n_master' }}
steps:
- name: Setup | Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Prevent File Change
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const { execSync } = require('child_process');
const pattern = /^docs\/[a-z][a-z][a-z]?-[A-Z][A-Z]?\/.*$/;
const base = context.payload.pull_request.base.sha;
const head = context.payload.pull_request.head.sha;
const result = execSync(`git diff --name-only ${base} ${head}`).toString().split('\n');
for (const file of result) {
if (pattern.test(file)) {
core.setFailed(`To avoid conflicts, changes to the translated documentation are only allowed via Crowdin at https://translate.starship.rs.`);
break;
}
}
# Vitepress build
vitepress:
name: Vitepress [Build]
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup | Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24.18.0
cache: 'npm'
cache-dependency-path: docs/package-lock.json
- name: Setup | Install dependencies
run: npm install
working-directory: docs
- name: Build | Build docs site
run: npm run build
working-directory: docs
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Format + Docs Workflow on: push: paths: ["docs/**", "**.md", "**.toml", "**.js", "**.json", "**.ts"] pull_request: paths: ["docs/**", "**.md", "**.toml", "**.js", "**.json", "**.ts"] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: # Run the dprint code formatter for documentation dprint: timeout-minutes: 30 name: Dprint [Docs Formatter] runs-on: latchkey-small steps: - name: Setup | Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - name: Docs | Format uses: dprint/check@9cb3a2b17a8e606d37aae341e49df3654933fc23 # v2.3 # Validate preset files taplo: timeout-minutes: 30 name: Taplo [Preset schema validation] runs-on: latchkey-small steps: - name: Setup | Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - name: Install | Taplo uses: taiki-e/install-action@b8cecb83565409bcc297b2df6e77f030b2a468d5 # v2.82.0 with: tool: taplo-cli@0.10.0 - name: Presets | Validate with schema run: taplo lint --schema "file://${GITHUB_WORKSPACE}/.github/config-schema.json" docs/public/presets/toml/*.toml # If this is not a Crowdin PR, block changes to translated documentation block-crowdin: timeout-minutes: 30 name: Block Translated Changes runs-on: latchkey-small if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref != 'i18n_master' }} steps: - name: Setup | Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: fetch-depth: 0 - name: Prevent File Change uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 with: script: | const { execSync } = require('child_process'); const pattern = /^docs\/[a-z][a-z][a-z]?-[A-Z][A-Z]?\/.*$/; const base = context.payload.pull_request.base.sha; const head = context.payload.pull_request.head.sha; const result = execSync(`git diff --name-only ${base} ${head}`).toString().split('\n'); for (const file of result) { if (pattern.test(file)) { core.setFailed(`To avoid conflicts, changes to the translated documentation are only allowed via Crowdin at https://translate.starship.rs.`); break; } } # Vitepress build vitepress: timeout-minutes: 30 name: Vitepress [Build] runs-on: latchkey-small steps: - name: Setup | Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - name: Setup | Node uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version: 24.18.0 cache: 'npm' cache-dependency-path: docs/package-lock.json - name: Setup | Install dependencies run: npm install working-directory: docs - name: Build | Build docs site run: npm run build working-directory: docs
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. - Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
This workflow runs 4 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.