Skip to content
Latchkey

CI workflow (Nozbe/WatermelonDB)

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

F

CI health: F - at risk

Point runs-on at Latchkey and get caching, 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: Nozbe/WatermelonDB.github/workflows/ci.ymlLicense MITView source

What it does

This is the CI workflow from the Nozbe/WatermelonDB 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:
  pull_request:
  push:
    branches: master

jobs:
  ci-check:
    runs-on: ubuntu-22.04
    name: JavaScript tests
    strategy:
      matrix:
        node-version: ['18.x', '20.x', '22.x', '23.x']
    steps:
      - uses: actions/checkout@v3
      - name: Set Node.js version
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
      - uses: actions/cache@v3
        with:
          path: 'node_modules'
          key: ${{ runner.os }}-node-${{ matrix.node-version }}-modules-${{ hashFiles('**/yarn.lock') }}
      - run: yarn
      - run: yarn ci:check
      - name: Gradle Wrapper Validation
        uses: gradle/wrapper-validation-action@v1.0.6
      - name: Check docs build
        run: cd docs-website && yarn install && cd .. && yarn docs:build
  ios:
    runs-on: macos-15
    name: iOS tests
    steps:
      - uses: actions/checkout@v3
      - name: Set Node.js version
        uses: actions/setup-node@v3
        with:
          node-version: 22.x
      - name: Set Xcode version
        uses: maxim-lobanov/setup-xcode@v1.2.1
        with:
          xcode-version: 16.2
      - name: ccache
        uses: hendrikmuhs/ccache-action@v1
      - name: cache node_modules
        uses: actions/cache@v3
        with:
          path: 'node_modules'
          key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
      - run: yarn
      - name: cache Pods
        uses: actions/cache@v3
        id: pods-cache
        with:
          path: native/iosTest/Pods
          key: ${{ runner.os }}-pods-cache-${{ hashFiles('**/Podfile.lock') }}
      - run: bundle install
      - name: 'pod install'
        if: true # steps.pods-cache.outputs.cache-hit != 'true'
        run: yarn cocoapods
      - run: yarn test:ios
  android:
    runs-on: ubuntu-24.04
    name: Android tests
    steps:
      - uses: actions/checkout@v4
      - name: Enable KVM
        run: |
          echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
          sudo udevadm control --reload-rules
          sudo udevadm trigger --name-match=kvm
      - uses: actions/setup-java@v4
        with:
          distribution: 'adopt'
          java-version: '17'
      - name: Set Node.js version
        uses: actions/setup-node@v4
        with:
          node-version: 22.x
      - uses: actions/cache@v4
        with:
          path: 'node_modules'
          key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
      - run: yarn
      - run: yarn dev:native &
      - uses: gradle/actions/setup-gradle@v3
      # See: https://github.com/android/compose-samples/actions/runs/27015993/workflow for ideas for caching
      - name: run tests
        uses: reactivecircus/android-emulator-runner@v2.33.0
        with:
          api-level: 29
          working-directory: ./native/androidTest
          script: ./gradlew connectedAndroidTest
      - run: yarn ktlint
  windows:
    # FIXME: Windows port is unmaintained. If you're interested in sponsoring continued maintenance,
    # please email me!
    if: false
    runs-on: windows-2022
    name: Windows tests
    steps:
      - uses: actions/checkout@v3
      - name: Set Node.js version
        uses: actions/setup-node@v3
        with:
          node-version: 22.x
      - uses: actions/cache@v3
        with:
          path: 'node_modules'
          key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
      - run: yarn --network-timeout 100000
      # FIXME: concurrently seems broken on windows
      # - run: yarn ci
      - run: yarn test
      - run: yarn eslint
      - run: yarn flow
      # FIXME: TS broken on Windows?
      # - run: yarn test:typescript
      # Build WatermelonTester and run in background
      - run: yarn test:windows
      # Give it some time to bundle
      - run: sleep 90
      # Start E2E runner to capture integration test results
      - run: cd native/windowsE2E && yarn
      - run: yarn test:windows:ci

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:
  pull_request:
  push:
    branches: master
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  ci-check:
    timeout-minutes: 30
    runs-on: latchkey-small
    name: JavaScript tests
    strategy:
      matrix:
        node-version: ['18.x', '20.x', '22.x', '23.x']
    steps:
      - uses: actions/checkout@v3
      - name: Set Node.js version
        uses: actions/setup-node@v3
        with:
          cache: 'npm'
          node-version: ${{ matrix.node-version }}
      - uses: actions/cache@v3
        with:
          path: 'node_modules'
          key: ${{ runner.os }}-node-${{ matrix.node-version }}-modules-${{ hashFiles('**/yarn.lock') }}
      - run: yarn
      - run: yarn ci:check
      - name: Gradle Wrapper Validation
        uses: gradle/wrapper-validation-action@v1.0.6
      - name: Check docs build
        run: cd docs-website && yarn install && cd .. && yarn docs:build
  ios:
    timeout-minutes: 30
    runs-on: macos-15
    name: iOS tests
    steps:
      - uses: actions/checkout@v3
      - name: Set Node.js version
        uses: actions/setup-node@v3
        with:
          cache: 'npm'
          node-version: 22.x
      - name: Set Xcode version
        uses: maxim-lobanov/setup-xcode@v1.2.1
        with:
          xcode-version: 16.2
      - name: ccache
        uses: hendrikmuhs/ccache-action@v1
      - name: cache node_modules
        uses: actions/cache@v3
        with:
          path: 'node_modules'
          key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
      - run: yarn
      - name: cache Pods
        uses: actions/cache@v3
        id: pods-cache
        with:
          path: native/iosTest/Pods
          key: ${{ runner.os }}-pods-cache-${{ hashFiles('**/Podfile.lock') }}
      - run: bundle install
      - name: 'pod install'
        if: true # steps.pods-cache.outputs.cache-hit != 'true'
        run: yarn cocoapods
      - run: yarn test:ios
  android:
    timeout-minutes: 30
    runs-on: latchkey-small
    name: Android tests
    steps:
      - uses: actions/checkout@v4
      - name: Enable KVM
        run: |
          echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
          sudo udevadm control --reload-rules
          sudo udevadm trigger --name-match=kvm
      - uses: actions/setup-java@v4
        with:
          distribution: 'adopt'
          java-version: '17'
      - name: Set Node.js version
        uses: actions/setup-node@v4
        with:
          cache: 'npm'
          node-version: 22.x
      - uses: actions/cache@v4
        with:
          path: 'node_modules'
          key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
      - run: yarn
      - run: yarn dev:native &
      - uses: gradle/actions/setup-gradle@v3
      # See: https://github.com/android/compose-samples/actions/runs/27015993/workflow for ideas for caching
      - name: run tests
        uses: reactivecircus/android-emulator-runner@v2.33.0
        with:
          api-level: 29
          working-directory: ./native/androidTest
          script: ./gradlew connectedAndroidTest
      - run: yarn ktlint
  windows:
    timeout-minutes: 30
    # FIXME: Windows port is unmaintained. If you're interested in sponsoring continued maintenance,
    # please email me!
    if: false
    runs-on: windows-2022
    name: Windows tests
    steps:
      - uses: actions/checkout@v3
      - name: Set Node.js version
        uses: actions/setup-node@v3
        with:
          cache: 'npm'
          node-version: 22.x
      - uses: actions/cache@v3
        with:
          path: 'node_modules'
          key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
      - run: yarn --network-timeout 100000
      # FIXME: concurrently seems broken on windows
      # - run: yarn ci
      - run: yarn test
      - run: yarn eslint
      - run: yarn flow
      # FIXME: TS broken on Windows?
      # - run: yarn test:typescript
      # Build WatermelonTester and run in background
      - run: yarn test:windows
      # Give it some time to bundle
      - run: sleep 90
      # Start E2E runner to capture integration test results
      - run: cd native/windowsE2E && yarn
      - run: yarn test:windows:ci
 

What changed

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