Skip to content
Latchkey

ci workflow (moby/swarmkit)

The ci workflow from moby/swarmkit, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get 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: moby/swarmkit.github/workflows/ci.ymlLicense Apache-2.0View source

What it does

This is the ci workflow from the moby/swarmkit 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

workflow (.yml)
name: ci

on:
  push:
    branches:
      - master
      - main
  pull_request:

env:
  DOCKER_SWARMKIT_USE_CONTAINER: 1
  IMAGE_NAME: moby/swarmkit

permissions:
  contents: read

jobs:
  build-dev:
    runs-on: ubuntu-22.04
    steps:
      -
        name: Checkout
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
      -
        name: Build dev image
        uses: docker/bake-action@6614cfa25eff9a0b2b2697efb0b6159e7680d584 # v7.2.0
        with:
          targets: dev
          set: |
            *.cache-from=type=gha,scope=dev${{ matrix.mode }}
            *.cache-to=type=gha,scope=dev${{ matrix.mode }},mode=max
            *.output=type=cacheonly

  test:
    runs-on: ubuntu-22.04
    needs:
      - build-dev
    strategy:
      fail-fast: false
      matrix:
        target:
          - coverage
          - coverage-integration
          - swarmd-tests
    steps:
      -
        name: Checkout
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
        with:
          fetch-depth: 0
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
      -
        name: Build dev image
        uses: docker/bake-action@6614cfa25eff9a0b2b2697efb0b6159e7680d584 # v7.2.0
        with:
          targets: dev
          set: |
            *.cache-from=type=gha,scope=dev
      -
        name: Test
        run: |
          make IMAGE_NAME=$IMAGE_NAME ${{ matrix.target }}
      -
        if: ${{ startsWith(matrix.target, 'coverage') }}
        name: Send to Codecov
        uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
        with:
          env_vars: RUNNER_OS
          flags: ${{ matrix.target }}

The same workflow, on Latchkey

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

name: ci
 
on:
  push:
    branches:
      - master
      - main
  pull_request:
 
env:
  DOCKER_SWARMKIT_USE_CONTAINER: 1
  IMAGE_NAME: moby/swarmkit
 
permissions:
  contents: read
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build-dev:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      -
        name: Checkout
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
      -
        name: Build dev image
        uses: docker/bake-action@6614cfa25eff9a0b2b2697efb0b6159e7680d584 # v7.2.0
        with:
          targets: dev
          set: |
            *.cache-from=type=gha,scope=dev${{ matrix.mode }}
            *.cache-to=type=gha,scope=dev${{ matrix.mode }},mode=max
            *.output=type=cacheonly
 
  test:
    timeout-minutes: 30
    runs-on: latchkey-small
    needs:
      - build-dev
    strategy:
      fail-fast: false
      matrix:
        target:
          - coverage
          - coverage-integration
          - swarmd-tests
    steps:
      -
        name: Checkout
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
        with:
          fetch-depth: 0
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
      -
        name: Build dev image
        uses: docker/bake-action@6614cfa25eff9a0b2b2697efb0b6159e7680d584 # v7.2.0
        with:
          targets: dev
          set: |
            *.cache-from=type=gha,scope=dev
      -
        name: Test
        run: |
          make IMAGE_NAME=$IMAGE_NAME ${{ matrix.target }}
      -
        if: ${{ startsWith(matrix.target, 'coverage') }}
        name: Send to Codecov
        uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
        with:
          env_vars: RUNNER_OS
          flags: ${{ matrix.target }}
 

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