Skip to content
Latchkey

Formatter workflow (dequelabs/axe-core)

The Formatter workflow from dequelabs/axe-core, explained and optimized by Latchkey.

A

CI health: A - excellent

Point runs-on at Latchkey and get run de-duplication, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: dequelabs/axe-core.github/workflows/format.ymlLicense MPL-2.0View source

What it does

This is the Formatter workflow from the dequelabs/axe-core repository, a real project running GitHub Actions. It is shown here with attribution under its MPL-2.0 license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Formatter

on:
  pull_request:
    branches:
      - develop

jobs:
  prettier:
    # This conditional prevents running the job on PRs from forks; won't
    # have permissions to commit changes, so the job would fail if it ran.
    # PRs from forks will instead rely on failing the fmt_check job in test.yml
    if: github.event.pull_request.head.repo.full_name == github.repository
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v6
        with:
          ref: ${{ github.event.pull_request.head.ref }}
      - name: Install dependencies
        run: npm ci
      - uses: actions/setup-node@v6
        with:
          node-version-file: .nvmrc
          cache: 'npm'
      # Workflows are not allowed to edit workflows. As result, we need to prevent Prettier from formatting them.
      - name: Prevent workflows from being formatted
        run: echo ".github" >> .prettierignore && cat .prettierignore
      - run: npm run fmt
      # Prevent the prettierignore change from being committed.
      - run: git checkout .prettierignore
      - uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # tag=v5
        with:
          commit_message: ':robot: Automated formatting fixes'

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Formatter
 
on:
  pull_request:
    branches:
      - develop
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  prettier:
    # This conditional prevents running the job on PRs from forks; won't
    # have permissions to commit changes, so the job would fail if it ran.
    # PRs from forks will instead rely on failing the fmt_check job in test.yml
    if: github.event.pull_request.head.repo.full_name == github.repository
    runs-on: latchkey-small
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v6
        with:
          ref: ${{ github.event.pull_request.head.ref }}
      - name: Install dependencies
        run: npm ci
      - uses: actions/setup-node@v6
        with:
          node-version-file: .nvmrc
          cache: 'npm'
      # Workflows are not allowed to edit workflows. As result, we need to prevent Prettier from formatting them.
      - name: Prevent workflows from being formatted
        run: echo ".github" >> .prettierignore && cat .prettierignore
      - run: npm run fmt
      # Prevent the prettierignore change from being committed.
      - run: git checkout .prettierignore
      - uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # tag=v5
        with:
          commit_message: ':robot: Automated formatting fixes'
 

What changed

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:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow