CI workflow (stylus/stylus)
The CI workflow from stylus/stylus, explained and optimized by Latchkey.
CI health: F - at risk
Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the CI workflow from the stylus/stylus repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
# Github actions workflow name
name: CI
# Triggers the workflow on push or pull request events
on:
push:
branches: [main, dev, master]
tags: ['**']
pull_request:
jobs:
node_tests:
name: 'Test stylus on ${{matrix.os}} with node${{matrix.node}}'
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [22]
runs-on: ${{ matrix.os }}
steps:
# Pull repo to test machine
- uses: actions/checkout@v4
# Configures the node version used on GitHub-hosted runners
- uses: actions/setup-node@v4
with:
# The Node.js version to configure
node-version: ${{matrix.node}}
- name: Install npm dependencies
run: npm install
- name: Print node & npm version
# Output useful info for debugging.
run: node --version && npm --version
- name: Run Test
run: npm run test
compat_node_tests:
name: 'Compat test stylus on ${{matrix.os}} with node${{matrix.node}}'
strategy:
matrix:
os: [ubuntu-latest]
node: [16, 18, 20, 23]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install npm dependencies
run: npm install
- name: Print put node & npm version
run: node --version && npm --version
- name: Run Test
run: npm run test
benchmark:
name: 'Run stylus benchmark with node20'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install npm dependencies
run: npm install
- name: Print put node & npm version
run: node --version && npm --version
- name: Run Benchmark
run: node ./bm.js
yarn-regression:
name: 'yarn exec stylus regression test'
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Print put node & npm version
run: node --version && npm --version
- name: Install yarn global
run: npm install -g yarn
- name: open a new folder
run: cd ./test/yarn
- name: Run Yarn
run: yarn install && yarn add stylus@latest && yarn run stylus --version
coverage:
name: 'Run nyc for code coverage'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Print put node & npm version
run: node --version && npm --version
- name: Install npm dependencies
run: npm install
- name: Run nyc
run: npx nyc@latest npm run test
deno_tests:
name: 'Test stylus on ${{matrix.os}} with latest stable deno'
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
# Pull repo to test machine
- uses: actions/checkout@v4
# Configures the deno version used on GitHub-hosted runners
- uses: denoland/setup-deno@v2
with:
# Run with latest stable Deno
deno-version: v1.x
- name: Print deno version
# Output useful info for debugging.
run: deno --version
- name: Run Test
run: deno run -A deno/test.ts
The same workflow, on Latchkey
Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.
# Github actions workflow name name: CI # Triggers the workflow on push or pull request events on: push: branches: [main, dev, master] tags: ['**'] pull_request: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: node_tests: timeout-minutes: 30 name: 'Test stylus on ${{matrix.os}} with node${{matrix.node}}' strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] node: [22] runs-on: ${{ matrix.os }} steps: # Pull repo to test machine - uses: actions/checkout@v4 # Configures the node version used on GitHub-hosted runners - uses: actions/setup-node@v4 with: cache: 'npm' # The Node.js version to configure node-version: ${{matrix.node}} - name: Install npm dependencies run: npm install - name: Print node & npm version # Output useful info for debugging. run: node --version && npm --version - name: Run Test run: npm run test compat_node_tests: timeout-minutes: 30 name: 'Compat test stylus on ${{matrix.os}} with node${{matrix.node}}' strategy: matrix: os: [ubuntu-latest] node: [16, 18, 20, 23] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: cache: 'npm' node-version: ${{ matrix.node }} - name: Install npm dependencies run: npm install - name: Print put node & npm version run: node --version && npm --version - name: Run Test run: npm run test benchmark: timeout-minutes: 30 name: 'Run stylus benchmark with node20' runs-on: latchkey-small steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: cache: 'npm' node-version: '22' - name: Install npm dependencies run: npm install - name: Print put node & npm version run: node --version && npm --version - name: Run Benchmark run: node ./bm.js yarn-regression: timeout-minutes: 30 name: 'yarn exec stylus regression test' runs-on: macos-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: cache: 'npm' node-version: '22' - name: Print put node & npm version run: node --version && npm --version - name: Install yarn global run: npm install -g yarn - name: open a new folder run: cd ./test/yarn - name: Run Yarn run: yarn install && yarn add stylus@latest && yarn run stylus --version coverage: timeout-minutes: 30 name: 'Run nyc for code coverage' runs-on: latchkey-small steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: cache: 'npm' node-version: '22' - name: Print put node & npm version run: node --version && npm --version - name: Install npm dependencies run: npm install - name: Run nyc run: npx nyc@latest npm run test deno_tests: timeout-minutes: 30 name: 'Test stylus on ${{matrix.os}} with latest stable deno' strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: # Pull repo to test machine - uses: actions/checkout@v4 # Configures the deno version used on GitHub-hosted runners - uses: denoland/setup-deno@v2 with: # Run with latest stable Deno deno-version: v1.x - name: Print deno version # Output useful info for debugging. run: deno --version - name: Run Test run: deno run -A deno/test.ts
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.
- Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
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 6 jobs (13 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.