Skip to content
Latchkey

Tests: node.js workflow (enzymejs/enzyme)

The Tests: node.js workflow from enzymejs/enzyme, explained and optimized by Latchkey.

C

CI health: C - fair

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

Grade your own workflow free or run it on Latchkey →
Source: enzymejs/enzyme.github/workflows/node.ymlLicense MITView source

What it does

This is the Tests: node.js workflow from the enzymejs/enzyme 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

workflow (.yml)
name: 'Tests: node.js'

on: [pull_request, push]

jobs:
  build:
    name: 'install deps and build'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: ljharb/actions/node/install@main
        with:
          skip-ls-check: true
      - run: npx lerna bootstrap
      - run: npm run build
      - uses: actions/cache@v3
        with:
          path: |
            packages/*/build
            node_modules
            packages/*/node_modules
          key: enzyme-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}

  karma-matrix:
    needs: [build]
    name: 'karma tests'
    runs-on: ubuntu-latest
    continue-on-error: true
    strategy:
      fail-fast: false
      matrix:
        react:
          - '16'
          - '16.3'
          - '16.2'
          - '16.1'
          - '15'
          - '15.4'
          - '0.14'
          - '0.13'
    steps:
      - uses: actions/checkout@v3
      - uses: actions/cache@v3
        with:
          path: |
            packages/*/build
            node_modules
            packages/*/node_modules
          key: enzyme-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
      - run: sudo chmod -R a+w .
      - uses: ljharb/actions/node/install@main
        with:
          node-version: 'lts/*'
          skip-install: true
          after_install: '(nvm install node && REACT=${{ matrix.react }} TRAVIS=1 sh install-relevant-react.sh)'
          skip-ls-check: true
      - run: npm run test:karma -- --single-run
        continue-on-error: true
        env:
          CHROME_BIN: chromium-browser
          DISPLAY: 99.0
      - run: echo 'karma tests expected to fail'

  tests:
    needs: [build]
    name: 'tests'
    runs-on: ubuntu-latest
    continue-on-error: ${{ matrix.continue-on-error == 'true' }}

    strategy:
      fail-fast: false
      matrix:
        node-version:
          - '18'
          - '4'
        react:
          - '16.14'
          - '16.13'
          - '16.12'
          - '16.11'
          - '16.10'
          - '16.9'
          - '16.8'
          - '16.7'
          - '16.6'
          - '16.5'
          - '16.4'
          - '16.3'
          - '16.2'
          - '16.1'
          - '16.0'
          - '15.5'
          - '15.4'
          - '15.3'
          - '15.2'
          - '15.1'
          - '15.0'
          - '0.14'
          - '0.13'
        include:
          - node-version: '16'
            react: '16'
          - node-version: '14'
            react: '16'
          - node-version: '12'
            react: '16'
          - node-version: '10'
            react: '16'
          - node-version: '8'
            react: '16'
          - node-version: '6'
            react: '16'
          - node-version: 'lts/*'
            react: '16.8.3'
          - node-version: 'lts/*'
            react: '16.8.5'
            env:
              RENDERER: '16.8.5'
          - node-version: 'lts/*'
            react: '16.8.5'
            env:
              RENDERER: '16.8.3'
          - node-version: 'lts/*'
            react: '16.3'
            env:
              ADAPTER: '16'
          - node-version: 'lts/*'
            react: '16.8'
            env:
              RENDERER: '16.7'
          - node-version: 'lts/*'
            react: '16.7'
            env:
              RENDERER: '16.8'
          - node-version: 'lts/*'
            react: '16.7'
            env:
              RENDERER: '16.7'

    steps:
      - uses: actions/checkout@v3
      - uses: actions/cache@v3
        with:
          path: |
            packages/*/build
            node_modules
            packages/*/node_modules
          key: enzyme-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
      - run: sudo chmod -R a+w .
      - uses: ljharb/actions/node/install@main
        with:
          node-version: ${{ matrix.node-version || 'lts/* '}}
          skip-install: true
          after_install: '(nvm install node && sh install-relevant-react.sh)'
          skip-ls-check: true
        env:
          REACT: ${{ matrix.react }}
      - run: npm run travis
      - uses: codecov/codecov-action@v3

  node:
    name: 'node + react'
    needs: [tests]
    runs-on: ubuntu-latest
    steps:
      - run: 'echo tests completed'
  
  karma:
    name: 'node + react + karma'
    needs: [karma-matrix]
    runs-on: ubuntu-latest
    steps:
      - run: 'echo tests completed'

The same workflow, on Latchkey

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

name: 'Tests: node.js'
 
on: [pull_request, push]
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    timeout-minutes: 30
    name: 'install deps and build'
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v3
      - uses: ljharb/actions/node/install@main
        with:
          skip-ls-check: true
      - run: npx lerna bootstrap
      - run: npm run build
      - uses: actions/cache@v3
        with:
          path: |
            packages/*/build
            node_modules
            packages/*/node_modules
          key: enzyme-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
 
  karma-matrix:
    timeout-minutes: 30
    needs: [build]
    name: 'karma tests'
    runs-on: latchkey-small
    continue-on-error: true
    strategy:
      fail-fast: false
      matrix:
        react:
          - '16'
          - '16.3'
          - '16.2'
          - '16.1'
          - '15'
          - '15.4'
          - '0.14'
          - '0.13'
    steps:
      - uses: actions/checkout@v3
      - uses: actions/cache@v3
        with:
          path: |
            packages/*/build
            node_modules
            packages/*/node_modules
          key: enzyme-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
      - run: sudo chmod -R a+w .
      - uses: ljharb/actions/node/install@main
        with:
          node-version: 'lts/*'
          skip-install: true
          after_install: '(nvm install node && REACT=${{ matrix.react }} TRAVIS=1 sh install-relevant-react.sh)'
          skip-ls-check: true
      - run: npm run test:karma -- --single-run
        continue-on-error: true
        env:
          CHROME_BIN: chromium-browser
          DISPLAY: 99.0
      - run: echo 'karma tests expected to fail'
 
  tests:
    timeout-minutes: 30
    needs: [build]
    name: 'tests'
    runs-on: latchkey-small
    continue-on-error: ${{ matrix.continue-on-error == 'true' }}
 
    strategy:
      fail-fast: false
      matrix:
        node-version:
          - '18'
          - '4'
        react:
          - '16.14'
          - '16.13'
          - '16.12'
          - '16.11'
          - '16.10'
          - '16.9'
          - '16.8'
          - '16.7'
          - '16.6'
          - '16.5'
          - '16.4'
          - '16.3'
          - '16.2'
          - '16.1'
          - '16.0'
          - '15.5'
          - '15.4'
          - '15.3'
          - '15.2'
          - '15.1'
          - '15.0'
          - '0.14'
          - '0.13'
        include:
          - node-version: '16'
            react: '16'
          - node-version: '14'
            react: '16'
          - node-version: '12'
            react: '16'
          - node-version: '10'
            react: '16'
          - node-version: '8'
            react: '16'
          - node-version: '6'
            react: '16'
          - node-version: 'lts/*'
            react: '16.8.3'
          - node-version: 'lts/*'
            react: '16.8.5'
            env:
              RENDERER: '16.8.5'
          - node-version: 'lts/*'
            react: '16.8.5'
            env:
              RENDERER: '16.8.3'
          - node-version: 'lts/*'
            react: '16.3'
            env:
              ADAPTER: '16'
          - node-version: 'lts/*'
            react: '16.8'
            env:
              RENDERER: '16.7'
          - node-version: 'lts/*'
            react: '16.7'
            env:
              RENDERER: '16.8'
          - node-version: 'lts/*'
            react: '16.7'
            env:
              RENDERER: '16.7'
 
    steps:
      - uses: actions/checkout@v3
      - uses: actions/cache@v3
        with:
          path: |
            packages/*/build
            node_modules
            packages/*/node_modules
          key: enzyme-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
      - run: sudo chmod -R a+w .
      - uses: ljharb/actions/node/install@main
        with:
          node-version: ${{ matrix.node-version || 'lts/* '}}
          skip-install: true
          after_install: '(nvm install node && sh install-relevant-react.sh)'
          skip-ls-check: true
        env:
          REACT: ${{ matrix.react }}
      - run: npm run travis
      - uses: codecov/codecov-action@v3
 
  node:
    timeout-minutes: 30
    name: 'node + react'
    needs: [tests]
    runs-on: latchkey-small
    steps:
      - run: 'echo tests completed'
  
  karma:
    timeout-minutes: 30
    name: 'node + react + karma'
    needs: [karma-matrix]
    runs-on: latchkey-small
    steps:
      - run: 'echo tests completed'
 

What changed

2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

This workflow runs 5 jobs (57 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow