Test workflow (remoteinterview/zero)
The Test workflow from remoteinterview/zero, explained and optimized by Latchkey.
CI health: C - fair
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the Test workflow from the remoteinterview/zero repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
on: [push, pull_request]
name: Test
jobs:
npmInstall:
name: ${{ matrix.os }} + node ${{ matrix.node }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-18.04, macOS-latest]
node: [8, 10, 12, 13]
steps:
- uses: actions/checkout@master
- uses: actions/setup-python@v1
- name: npm install
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm install
- name: bootstrap
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm run bootstrap
- name: test
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
python-version: 3.7
- run: npm test
env:
PARCEL_WORKERS: 1
ZERO_LIMIT_BUNDLERS: 3
HMRWAITTIME: 60000
NODE_OPTIONS: --max-old-space-size=8192
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.
on: [push, pull_request] name: Test concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: npmInstall: name: ${{ matrix.os }} + node ${{ matrix.node }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [windows-latest, ubuntu-18.04, macOS-latest] node: [8, 10, 12, 13] steps: - uses: actions/checkout@master - uses: actions/setup-python@v1 - name: npm install uses: actions/setup-node@v1 with: cache: 'npm' node-version: ${{ matrix.node }} - run: npm install - name: bootstrap uses: actions/setup-node@v1 with: cache: 'npm' node-version: ${{ matrix.node }} - run: npm run bootstrap - name: test uses: actions/setup-node@v1 with: cache: 'npm' node-version: ${{ matrix.node }} python-version: 3.7 - run: npm test env: PARCEL_WORKERS: 1 ZERO_LIMIT_BUNDLERS: 3 HMRWAITTIME: 60000 NODE_OPTIONS: --max-old-space-size=8192
What changed
- 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.
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 1 job (12 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.