Skip to content
Latchkey

Tests and Linters πŸ§ͺ workflow (instadeepai/mlip)

The Tests and Linters πŸ§ͺ workflow from instadeepai/mlip, 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: instadeepai/mlip.github/workflows/tests_and_linters.yamlLicense Apache-2.0View source

What it does

This is the Tests and Linters πŸ§ͺ workflow from the instadeepai/mlip 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: Tests and Linters πŸ§ͺ

on:
  push:
    branches: [main]
  pull_request:

jobs:
  linters:
    runs-on: ubuntu-latest
    container:
       image: python:3.12-slim
    steps:
      - name: setup
        run: |
          apt-get update && apt-get install -y \
          coreutils \
          gcc \
          git
          git config --system --add safe.directory $GITHUB_WORKSPACE

      - name: checkout code πŸ“¦
        uses: actions/checkout@v5

      - name: install uv
        uses: astral-sh/setup-uv@v7

      - name: setup env
        run: uv sync --only-dev

      - name: run linters πŸ–ŒοΈ
        run: |
          git init
          uv run --no-sync pre-commit run --all-files --verbose

  tests:
    runs-on: ubuntu-latest
    container:
       image: python:3.12-slim

    env:
      # Shares the XLA compile cache across CI runs. Also read natively by JAX.
      JAX_COMPILATION_CACHE_DIR: ${{ github.workspace }}/.cache/jax_compilation_cache

    steps:
      - name: checkout code πŸ“‚
        uses: actions/checkout@v5

      - name: setup
        run: |
          apt-get update && apt-get install -y \
          coreutils \
          git

      - name: install uv
        uses: astral-sh/setup-uv@v7

      - name: setup env
        run: uv sync

      - name: Restore JAX compilation cache πŸ—„οΈ
        uses: actions/cache@v4
        with:
          path: ${{ env.JAX_COMPILATION_CACHE_DIR }}
          key: jax-cache-${{ runner.os }}-${{ hashFiles('uv.lock') }}
          restore-keys: |
            jax-cache-${{ runner.os }}-

      - name: run tests πŸ§ͺ
        run: |
          uv run --no-sync pytest --ignore tests/experiments --verbose \
                                  --cov-report xml:coverage.xml \
                                  --cov-report term-missing \
                                  --junitxml=pytest.xml \
                                  --cov=mlip tests/

      - name: pytest coverage comment
        id: coverageComment
        uses: MishaKav/pytest-coverage-comment@287292879eaaff04116f36d3eb1a670f6e5df1a4
        with:
          pytest-xml-coverage-path: ./coverage.xml
          junitxml-path: ./pytest.xml

      - name: Create the Badge
        uses: schneegans/dynamic-badges-action@e9a478b16159b4d31420099ba146cdc50f134483
        with:
          auth: ${{ secrets.BOT_ACCESS_TOKEN }}
          gistID: b6e4bf384215e60775699a83c3c00aef
          filename: pytest-coverage-comment.json
          label: Test Coverage
          message: ${{ steps.coverageComment.outputs.coverage }}
          color: ${{ steps.coverageComment.outputs.color }}
          namedLogo: python

The same workflow, on Latchkey

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

name: Tests and Linters πŸ§ͺ
 
on:
  push:
    branches: [main]
  pull_request:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  linters:
    timeout-minutes: 30
    runs-on: latchkey-small
    container:
       image: python:3.12-slim
    steps:
      - name: setup
        run: |
          apt-get update && apt-get install -y \
          coreutils \
          gcc \
          git
          git config --system --add safe.directory $GITHUB_WORKSPACE
 
      - name: checkout code πŸ“¦
        uses: actions/checkout@v5
 
      - name: install uv
        uses: astral-sh/setup-uv@v7
 
      - name: setup env
        run: uv sync --only-dev
 
      - name: run linters πŸ–ŒοΈ
        run: |
          git init
          uv run --no-sync pre-commit run --all-files --verbose
 
  tests:
    timeout-minutes: 30
    runs-on: latchkey-small
    container:
       image: python:3.12-slim
 
    env:
      # Shares the XLA compile cache across CI runs. Also read natively by JAX.
      JAX_COMPILATION_CACHE_DIR: ${{ github.workspace }}/.cache/jax_compilation_cache
 
    steps:
      - name: checkout code πŸ“‚
        uses: actions/checkout@v5
 
      - name: setup
        run: |
          apt-get update && apt-get install -y \
          coreutils \
          git
 
      - name: install uv
        uses: astral-sh/setup-uv@v7
 
      - name: setup env
        run: uv sync
 
      - name: Restore JAX compilation cache πŸ—„οΈ
        uses: actions/cache@v4
        with:
          path: ${{ env.JAX_COMPILATION_CACHE_DIR }}
          key: jax-cache-${{ runner.os }}-${{ hashFiles('uv.lock') }}
          restore-keys: |
            jax-cache-${{ runner.os }}-
 
      - name: run tests πŸ§ͺ
        run: |
          uv run --no-sync pytest --ignore tests/experiments --verbose \
                                  --cov-report xml:coverage.xml \
                                  --cov-report term-missing \
                                  --junitxml=pytest.xml \
                                  --cov=mlip tests/
 
      - name: pytest coverage comment
        id: coverageComment
        uses: MishaKav/pytest-coverage-comment@287292879eaaff04116f36d3eb1a670f6e5df1a4
        with:
          pytest-xml-coverage-path: ./coverage.xml
          junitxml-path: ./pytest.xml
 
      - name: Create the Badge
        uses: schneegans/dynamic-badges-action@e9a478b16159b4d31420099ba146cdc50f134483
        with:
          auth: ${{ secrets.BOT_ACCESS_TOKEN }}
          gistID: b6e4bf384215e60775699a83c3c00aef
          filename: pytest-coverage-comment.json
          label: Test Coverage
          message: ${{ steps.coverageComment.outputs.coverage }}
          color: ${{ steps.coverageComment.outputs.color }}
          namedLogo: python
 

What changed

1 third-party action is referenced by a movable tag. Pin it 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 per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow