Skip to content
Latchkey

CI workflow (workalendar/workalendar)

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

D

CI health: D - needs work

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

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

What it does

This is the CI workflow from the workalendar/workalendar 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:
      - '*'
    tags:
      - '*'
  # Empty pull request argument means "all pull-requests"
  pull_request:

jobs:
  # 1. linters
  check-lint:
    strategy:
      matrix:
        include:
          - name: flake8
            tox-env: flake8
          - name: pyupgrade
            tox-env: pyupgrade

    name: Check ${{ matrix.name }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.x
      - name: Install dependencies
        run: |
          set -xeu
          python --version
          pip install tox
      - name: Check ${{ matrix.name }}
        run: tox -e ${{ matrix.tox-env }}

  # 2. Unit tests
  tests:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        python-version: [3.7, 3.8, 3.9, '3.10', 3.11]
        include:
          - python-version: 3.7
            tox-env: py37
          - python-version: 3.8
            tox-env: py38
          - python-version: 3.9
            tox-env: py39
          - python-version: '3.10'
            tox-env: py310
          - python-version: 3.11
            tox-env: py311

    name: Test (python ${{ matrix.python-version }}/${{ matrix.os }})
    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v2
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
      - name: Cache pip
        uses: actions/cache@v2
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}
          restore-keys: |
            ${{ runner.os }}-pip-
      - name: Install dependencies
        run: |
          python --version
          pip install tox coverage
      - name: Run tox targets for ${{ matrix.python-version }}
        run: tox -e ${{ matrix.tox-env }}

  report-status:
    name: success
    runs-on: ubuntu-latest
    needs:
      - check-lint
      - tests
    steps:
      - name: Report success
        run: echo 'Success !'

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.

name: CI
 
on:
  push:
    branches:
      - '*'
    tags:
      - '*'
  # Empty pull request argument means "all pull-requests"
  pull_request:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  # 1. linters
  check-lint:
    timeout-minutes: 30
    strategy:
      matrix:
        include:
          - name: flake8
            tox-env: flake8
          - name: pyupgrade
            tox-env: pyupgrade
 
    name: Check ${{ matrix.name }}
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          cache: 'pip'
          python-version: 3.x
      - name: Install dependencies
        run: |
          set -xeu
          python --version
          pip install tox
      - name: Check ${{ matrix.name }}
        run: tox -e ${{ matrix.tox-env }}
 
  # 2. Unit tests
  tests:
    timeout-minutes: 30
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        python-version: [3.7, 3.8, 3.9, '3.10', 3.11]
        include:
          - python-version: 3.7
            tox-env: py37
          - python-version: 3.8
            tox-env: py38
          - python-version: 3.9
            tox-env: py39
          - python-version: '3.10'
            tox-env: py310
          - python-version: 3.11
            tox-env: py311
 
    name: Test (python ${{ matrix.python-version }}/${{ matrix.os }})
    runs-on: ${{ matrix.os }}
 
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          cache: 'pip'
          python-version: ${{ matrix.python-version }}
      - name: Cache pip
        uses: actions/cache@v2
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}
          restore-keys: |
            ${{ runner.os }}-pip-
      - name: Install dependencies
        run: |
          python --version
          pip install tox coverage
      - name: Run tox targets for ${{ matrix.python-version }}
        run: tox -e ${{ matrix.tox-env }}
 
  report-status:
    timeout-minutes: 30
    name: success
    runs-on: latchkey-small
    needs:
      - check-lint
      - tests
    steps:
      - name: Report success
        run: echo 'Success !'
 

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