Build & Test workflow (docsifyjs/docsify)
The Build & Test workflow from docsifyjs/docsify, 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 Build & Test workflow from the docsifyjs/docsify 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
name: Build & Test
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['lts/*']
steps:
- uses: actions/checkout@v7
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Build
run: npm run build
- name: Lint
run: npm run lint
test-jest:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node-version: ['lts/*']
os: ['macos-latest', 'ubuntu-latest', 'windows-latest']
steps:
- uses: actions/checkout@v7
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Build
run: npm run build
- name: Unit Tests
run: npm run test:unit -- --ci --runInBand
- name: Integration Tests
run: npm run test:integration -- --ci --runInBand
- name: Consumption Tests
run: npm run test:consume-types
test-playwright:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['lts/*']
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Build
run: npm run build
- name: Install Playwright
run: npx playwright install --with-deps
- name: E2E Tests (Playwright)
run: npm run test:e2e
# In the interest of not having to modify GitHub settings to update required
# builds for passing, I stuck this test here.
- name: Test v4 build
run: |
git fetch --tags
npm run build:v4
# ensure v4 build files exist:
test -f lib/docsify.js
test -f themes/pure.css
# ensure no git changes after building v4:
git diff --exit-code
npm run clean:v4
# ensure v4 build files are removed:
test ! -f lib/docsify.js
test ! -f themes/pure.css
# ensure no git changes after cleaning v4:
git diff --exit-code
- name: Store artifacts
uses: actions/upload-artifact@v7
if: failure()
with:
name: ${{ matrix.os }}-${{ matrix.node-version }}-artifacts
path: |
_playwright-results/
_playwright-report/
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Build & Test on: push: branches: [main, develop] pull_request: branches: [main, develop] workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: lint: timeout-minutes: 30 runs-on: latchkey-small strategy: matrix: node-version: ['lts/*'] steps: - uses: actions/checkout@v7 - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} cache: 'npm' - name: Install dependencies run: npm ci --ignore-scripts - name: Build run: npm run build - name: Lint run: npm run lint test-jest: timeout-minutes: 30 runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: node-version: ['lts/*'] os: ['macos-latest', 'ubuntu-latest', 'windows-latest'] steps: - uses: actions/checkout@v7 - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} cache: 'npm' - name: Install dependencies run: npm ci --ignore-scripts - name: Build run: npm run build - name: Unit Tests run: npm run test:unit -- --ci --runInBand - name: Integration Tests run: npm run test:integration -- --ci --runInBand - name: Consumption Tests run: npm run test:consume-types test-playwright: runs-on: latchkey-small strategy: matrix: node-version: ['lts/*'] timeout-minutes: 30 steps: - uses: actions/checkout@v7 - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} cache: 'npm' - name: Install dependencies run: npm ci --ignore-scripts - name: Build run: npm run build - name: Install Playwright run: npx playwright install --with-deps - name: E2E Tests (Playwright) run: npm run test:e2e # In the interest of not having to modify GitHub settings to update required # builds for passing, I stuck this test here. - name: Test v4 build run: | git fetch --tags npm run build:v4 # ensure v4 build files exist: test -f lib/docsify.js test -f themes/pure.css # ensure no git changes after building v4: git diff --exit-code npm run clean:v4 # ensure v4 build files are removed: test ! -f lib/docsify.js test ! -f themes/pure.css # ensure no git changes after cleaning v4: git diff --exit-code - name: Store artifacts uses: actions/upload-artifact@v7 if: failure() with: name: ${{ matrix.os }}-${{ matrix.node-version }}-artifacts path: | _playwright-results/ _playwright-report/
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
- End-to-end and browser tests
This workflow runs 3 jobs (5 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.