Skip to content
Latchkey

CI workflow (chartjs/Chart.js)

The CI workflow from chartjs/Chart.js, 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: chartjs/Chart.js.github/workflows/ci.ymlLicense MITView source

What it does

This is the CI workflow from the chartjs/Chart.js 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
      - "2.9"
  pull_request:
    branches:
      - master
      - "2.9"
  workflow_dispatch:
permissions:
  contents: read

jobs:
  build:
    permissions:
      checks: write  # for coverallsapp/github-action to create new checks
      contents: read  # for dorny/paths-filter to fetch a list of changed files
      pull-requests: read  # for dorny/paths-filter to read pull requests
    runs-on: ${{ matrix.os }}

    outputs:
      coveralls: ${{ steps.changes.outputs.src }}

    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
      fail-fast: false

    steps:
      - uses: actions/checkout@v6
      - uses: pnpm/action-setup@v4.2.0
      - name: Use Node.js
        uses: actions/setup-node@v6
        with:
          node-version: 16
          cache: pnpm
      - uses: dorny/paths-filter@v3
        id: changes
        with:
          filters: |
            docs:
              - 'docs/**'
              - 'package.json'
              - 'tsconfig.json'
            src:
              - 'src/**'
              - 'package.json'
            test:
              - 'test/**'
              - 'karma.conf.js'
              - 'package.json'
            types:
              - 'package.json'
              - 'tsconfig.json'
      - name: Install
        run: pnpm install
      - name: Lint
        run: pnpm run lint
      - name: Build
        run: pnpm run build
      - name: Test
        if: |
          (steps.changes.outputs.src == 'true' ||
          steps.changes.outputs.test == 'true') &&
          runner.os != 'Windows'
        run: |
          pnpm run build
          if [ "${{ runner.os }}" == "macOS" ]; then
            pnpm run test-ci --browsers chrome,safari
          else
            xvfb-run --auto-servernum pnpm run test-ci
          fi
        shell: bash
      - name: Package
        if: steps.changes.outputs.docs == 'true'
        run: |
          pnpm run docs
          pnpm pack
      - name: Coveralls Parallel - Chrome
        if: |
          steps.changes.outputs.src == 'true' &&
          runner.os != 'Windows'
        uses: coverallsapp/github-action@master
        with:
          github-token: ${{ secrets.github_token }}
          path-to-lcov: './coverage/chrome/lcov.info'
          flag-name: ${{ matrix.os }}-chrome
          parallel: true
      - name: Coveralls Parallel - Firefox
        if: |
          steps.changes.outputs.src == 'true' &&
          runner.os != 'Windows'
        uses: coverallsapp/github-action@master
        with:
          github-token: ${{ secrets.github_token }}
          path-to-lcov: './coverage/firefox/lcov.info'
          flag-name: ${{ matrix.os }}-firefox
          parallel: true

  finish:
    permissions:
      checks: write  # for coverallsapp/github-action to create new checks
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Coveralls Finished
        if: needs.build.outputs.coveralls == 'true'
        uses: coverallsapp/github-action@master
        with:
          github-token: ${{ secrets.github_token }}
          parallel-finished: true

The same workflow, on Latchkey

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

name: CI
 
on:
  push:
    branches:
      - master
      - "2.9"
  pull_request:
    branches:
      - master
      - "2.9"
  workflow_dispatch:
permissions:
  contents: read
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    timeout-minutes: 30
    permissions:
      checks: write  # for coverallsapp/github-action to create new checks
      contents: read  # for dorny/paths-filter to fetch a list of changed files
      pull-requests: read  # for dorny/paths-filter to read pull requests
    runs-on: ${{ matrix.os }}
 
    outputs:
      coveralls: ${{ steps.changes.outputs.src }}
 
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
      fail-fast: false
 
    steps:
      - uses: actions/checkout@v6
      - uses: pnpm/action-setup@v4.2.0
      - name: Use Node.js
        uses: actions/setup-node@v6
        with:
          node-version: 16
          cache: pnpm
      - uses: dorny/paths-filter@v3
        id: changes
        with:
          filters: |
            docs:
              - 'docs/**'
              - 'package.json'
              - 'tsconfig.json'
            src:
              - 'src/**'
              - 'package.json'
            test:
              - 'test/**'
              - 'karma.conf.js'
              - 'package.json'
            types:
              - 'package.json'
              - 'tsconfig.json'
      - name: Install
        run: pnpm install
      - name: Lint
        run: pnpm run lint
      - name: Build
        run: pnpm run build
      - name: Test
        if: |
          (steps.changes.outputs.src == 'true' ||
          steps.changes.outputs.test == 'true') &&
          runner.os != 'Windows'
        run: |
          pnpm run build
          if [ "${{ runner.os }}" == "macOS" ]; then
            pnpm run test-ci --browsers chrome,safari
          else
            xvfb-run --auto-servernum pnpm run test-ci
          fi
        shell: bash
      - name: Package
        if: steps.changes.outputs.docs == 'true'
        run: |
          pnpm run docs
          pnpm pack
      - name: Coveralls Parallel - Chrome
        if: |
          steps.changes.outputs.src == 'true' &&
          runner.os != 'Windows'
        uses: coverallsapp/github-action@master
        with:
          github-token: ${{ secrets.github_token }}
          path-to-lcov: './coverage/chrome/lcov.info'
          flag-name: ${{ matrix.os }}-chrome
          parallel: true
      - name: Coveralls Parallel - Firefox
        if: |
          steps.changes.outputs.src == 'true' &&
          runner.os != 'Windows'
        uses: coverallsapp/github-action@master
        with:
          github-token: ${{ secrets.github_token }}
          path-to-lcov: './coverage/firefox/lcov.info'
          flag-name: ${{ matrix.os }}-firefox
          parallel: true
 
  finish:
    timeout-minutes: 30
    permissions:
      checks: write  # for coverallsapp/github-action to create new checks
    needs: build
    runs-on: latchkey-small
    steps:
      - name: Coveralls Finished
        if: needs.build.outputs.coveralls == 'true'
        uses: coverallsapp/github-action@master
        with:
          github-token: ${{ secrets.github_token }}
          parallel-finished: true
 

What changed

3 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.

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 2 jobs (3 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