Skip to content
Latchkey

CI workflow (NCAR/wrf-python)

The CI workflow from NCAR/wrf-python, explained and optimized by Latchkey.

A

CI health: A - excellent

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: NCAR/wrf-python.github/workflows/ci.ymlLicense Apache-2.0View source

What it does

This is the CI workflow from the NCAR/wrf-python 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:
      - main
      - develop
  pull_request:
  workflow_dispatch:
  schedule:
    - cron: '0 0 * * *' # Daily “At 00:00”

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    name: Python ${{ matrix.python-version }}, ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    defaults:
      run:
        shell: bash -l {0}
    strategy:
      fail-fast: false
      matrix:
        os: [ "ubuntu-latest", "macos-latest", "macos-14" ]
        python-version: [ "3.10", "3.11", "3.12", "3.13" ]
    steps:
      - name: checkout
        uses: actions/checkout@v6
      - name: environment setup
        uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
        with:
          python-version: ${{ matrix.python-version }}
          channels: conda-forge
          environment-file: build_envs/environment.yml
      - name: build WRF-Python
        run: |
          python -m pip install build
          python -m build .
          python -m pip install dist/wrf*.whl
      - name: run tests
        run: |
          cd test/ci_tests
          python utests.py
      - name: check import
        if: failure()
        run: |
          python -m pip show wrf-python
          python -m pip show --files wrf-python
          prefix="$(python -m pip show --files wrf-python | grep Location: | cut -f2 -d" ")"
          echo "Site-packages directory is ${prefix}"
          cd "${prefix}"
          installed_files="$(python -m pip show --files wrf-python | grep -v -E -e '^[-a-zA-Z]+:')"
          ls -l ${installed_files}
          file ${installed_files}
          python -vvv -dd -c "import wrf"
          ldd $(echo ${installed_files} | grep -F -v -e ".py" -e ".dist-info")

The same workflow, on Latchkey

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

name: CI
on:
  push:
    branches:
      - main
      - develop
  pull_request:
  workflow_dispatch:
  schedule:
    - cron: '0 0 * * *' # Daily “At 00:00”
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    timeout-minutes: 30
    name: Python ${{ matrix.python-version }}, ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    defaults:
      run:
        shell: bash -l {0}
    strategy:
      fail-fast: false
      matrix:
        os: [ "ubuntu-latest", "macos-latest", "macos-14" ]
        python-version: [ "3.10", "3.11", "3.12", "3.13" ]
    steps:
      - name: checkout
        uses: actions/checkout@v6
      - name: environment setup
        uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
        with:
          python-version: ${{ matrix.python-version }}
          channels: conda-forge
          environment-file: build_envs/environment.yml
      - name: build WRF-Python
        run: |
          python -m pip install build
          python -m build .
          python -m pip install dist/wrf*.whl
      - name: run tests
        run: |
          cd test/ci_tests
          python utests.py
      - name: check import
        if: failure()
        run: |
          python -m pip show wrf-python
          python -m pip show --files wrf-python
          prefix="$(python -m pip show --files wrf-python | grep Location: | cut -f2 -d" ")"
          echo "Site-packages directory is ${prefix}"
          cd "${prefix}"
          installed_files="$(python -m pip show --files wrf-python | grep -v -E -e '^[-a-zA-Z]+:')"
          ls -l ${installed_files}
          file ${installed_files}
          python -vvv -dd -c "import wrf"
          ldd $(echo ${installed_files} | grep -F -v -e ".py" -e ".dist-info")
 

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