Skip to content
Latchkey

CI workflow (jondot/hygen)

The CI workflow from jondot/hygen, explained and optimized by Latchkey.

C

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 →
Source: jondot/hygen.github/workflows/ci.ymlLicense MITView source

What it does

This is the CI workflow from the jondot/hygen 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: CI

on:
  push:
    branches:
      - master
    tags-ignore:
    - 'v[0-9]+.[0-9]+.[0-9]+' # these will trigger this w/ workflow_call
    - 'docs-[0-9]+'
  pull_request:
  schedule:
    - cron: '0 14 3 * *' # Monthly at 2pm on the 3rd

  workflow_call:

jobs:
  build:
    runs-on: ${{matrix.os}}
    strategy:
      matrix:
        node-version: [14.x, 17.x]
        os: [ubuntu-latest, windows-latest]
    steps:
    - name: Set git to use LF
      run: |
        git config --global core.autocrlf false
        git config --global core.eol lf
      if: matrix.os == 'windows-latest'

    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'yarn'
    - run: yarn install
    - run: yarn build
    - run: yarn hygen:build -- init self

    - run: yarn test
      if: matrix.os == 'ubuntu-latest'
    - run: yarn test:win32
      if: matrix.os == 'windows-latest'

The same workflow, on Latchkey

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

name: CI
 
on:
  push:
    branches:
      - master
    tags-ignore:
    - 'v[0-9]+.[0-9]+.[0-9]+' # these will trigger this w/ workflow_call
    - 'docs-[0-9]+'
  pull_request:
  schedule:
    - cron: '0 14 3 * *' # Monthly at 2pm on the 3rd
 
  workflow_call:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    timeout-minutes: 30
    runs-on: ${{matrix.os}}
    strategy:
      matrix:
        node-version: [14.x, 17.x]
        os: [ubuntu-latest, windows-latest]
    steps:
    - name: Set git to use LF
      run: |
        git config --global core.autocrlf false
        git config --global core.eol lf
      if: matrix.os == 'windows-latest'
 
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'yarn'
    - run: yarn install
    - run: yarn build
    - run: yarn hygen:build -- init self
 
    - run: yarn test
      if: matrix.os == 'ubuntu-latest'
    - run: yarn test:win32
      if: matrix.os == 'windows-latest'
 

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 (4 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