Skip to content
Latchkey

CI workflow (shenweichen/DeepMatch)

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

B

CI health: B - good

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

What it does

This is the CI workflow from the shenweichen/DeepMatch 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:
    paths:
      - 'deepmatch/**'
      - 'tests/**'
      - 'setup.py'
      - '.github/workflows/**'
  pull_request:
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
  cancel-in-progress: true

jobs:
  build:
    runs-on: ubuntu-22.04
    timeout-minutes: 240
    strategy:
      fail-fast: false
      matrix:
        include:
          - python-version: "3.7"
            tf-version: "1.15.5"
            protobuf-version: "3.19.0"
            run-examples: "false"
          - python-version: "3.10"
            tf-version: "2.10.0"
            protobuf-version: ""
            run-examples: "true"
          - python-version: "3.10"
            tf-version: "2.15.0"
            protobuf-version: ""
            run-examples: "false"
          - python-version: "3.11"
            tf-version: "2.15.0"
            protobuf-version: ""
            run-examples: "false"

    steps:
      - uses: actions/checkout@v5

      - name: Detect code-related changes
        id: filter
        uses: dorny/paths-filter@v3
        with:
          filters: |
            code_related:
              - 'deepmatch/**'
              - 'tests/**'
              - 'setup.py'
              - '.github/workflows/**'

      - name: Docs-only PR fast-path
        if: ${{ github.event_name == 'pull_request' && steps.filter.outputs.code_related != 'true' }}
        run: echo "Docs-only PR detected; skipping heavy CI steps."

      - name: Setup python environment
        if: ${{ github.event_name != 'pull_request' || steps.filter.outputs.code_related == 'true' }}
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install dependencies
        if: ${{ github.event_name != 'pull_request' || steps.filter.outputs.code_related == 'true' }}
        run: |
          python -m pip install -q --upgrade pip setuptools wheel
          python -m pip install -q "numpy<2"
          python -m pip install -q tensorflow==${{ matrix.tf-version }}
          python -m pip install -q pytest pytest-cov
          python -m pip install -e .

      - name: Install TF1 protobuf pin
        if: ${{ (github.event_name != 'pull_request' || steps.filter.outputs.code_related == 'true') && matrix.protobuf-version != '' }}
        run: |
          python -m pip install -q protobuf==${{ matrix.protobuf-version }}

      - name: Dependency check
        if: ${{ github.event_name != 'pull_request' || steps.filter.outputs.code_related == 'true' }}
        run: |
          python -m pip check

      - name: Test with pytest
        if: ${{ github.event_name != 'pull_request' || steps.filter.outputs.code_related == 'true' }}
        timeout-minutes: 240
        run: |
          pytest --cov=deepmatch --cov-report=xml --cov-report=term-missing:skip-covered

      - name: Install example runtime dependencies
        if: ${{ (github.event_name != 'pull_request' || steps.filter.outputs.code_related == 'true') && matrix.run-examples == 'true' }}
        run: |
          python -m pip install -q pandas scikit-learn tqdm

      - name: Smoke test examples
        if: ${{ (github.event_name != 'pull_request' || steps.filter.outputs.code_related == 'true') && matrix.run-examples == 'true' }}
        timeout-minutes: 60
        working-directory: examples
        env:
          DEEPMATCH_EXAMPLE_FAST: "1"
        run: |
          python run_youtubednn.py
          python run_dssm_inbatchsoftmax.py
          python run_dssm_negsampling.py
          python run_sdm.py
          python run_ncf.py

      - name: Upload coverage to Codecov
        if: ${{ github.event_name != 'pull_request' || steps.filter.outputs.code_related == 'true' }}
        uses: codecov/codecov-action@v6
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: ./coverage.xml
          flags: pytest
          name: py${{ matrix.python-version }}-tf${{ matrix.tf-version }}

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:
    paths:
      - 'deepmatch/**'
      - 'tests/**'
      - 'setup.py'
      - '.github/workflows/**'
  pull_request:
  workflow_dispatch:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
  cancel-in-progress: true
 
jobs:
  build:
    runs-on: latchkey-small
    timeout-minutes: 240
    strategy:
      fail-fast: false
      matrix:
        include:
          - python-version: "3.7"
            tf-version: "1.15.5"
            protobuf-version: "3.19.0"
            run-examples: "false"
          - python-version: "3.10"
            tf-version: "2.10.0"
            protobuf-version: ""
            run-examples: "true"
          - python-version: "3.10"
            tf-version: "2.15.0"
            protobuf-version: ""
            run-examples: "false"
          - python-version: "3.11"
            tf-version: "2.15.0"
            protobuf-version: ""
            run-examples: "false"
 
    steps:
      - uses: actions/checkout@v5
 
      - name: Detect code-related changes
        id: filter
        uses: dorny/paths-filter@v3
        with:
          filters: |
            code_related:
              - 'deepmatch/**'
              - 'tests/**'
              - 'setup.py'
              - '.github/workflows/**'
 
      - name: Docs-only PR fast-path
        if: ${{ github.event_name == 'pull_request' && steps.filter.outputs.code_related != 'true' }}
        run: echo "Docs-only PR detected; skipping heavy CI steps."
 
      - name: Setup python environment
        if: ${{ github.event_name != 'pull_request' || steps.filter.outputs.code_related == 'true' }}
        uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: ${{ matrix.python-version }}
 
      - name: Install dependencies
        if: ${{ github.event_name != 'pull_request' || steps.filter.outputs.code_related == 'true' }}
        run: |
          python -m pip install -q --upgrade pip setuptools wheel
          python -m pip install -q "numpy<2"
          python -m pip install -q tensorflow==${{ matrix.tf-version }}
          python -m pip install -q pytest pytest-cov
          python -m pip install -e .
 
      - name: Install TF1 protobuf pin
        if: ${{ (github.event_name != 'pull_request' || steps.filter.outputs.code_related == 'true') && matrix.protobuf-version != '' }}
        run: |
          python -m pip install -q protobuf==${{ matrix.protobuf-version }}
 
      - name: Dependency check
        if: ${{ github.event_name != 'pull_request' || steps.filter.outputs.code_related == 'true' }}
        run: |
          python -m pip check
 
      - name: Test with pytest
        if: ${{ github.event_name != 'pull_request' || steps.filter.outputs.code_related == 'true' }}
        timeout-minutes: 240
        run: |
          pytest --cov=deepmatch --cov-report=xml --cov-report=term-missing:skip-covered
 
      - name: Install example runtime dependencies
        if: ${{ (github.event_name != 'pull_request' || steps.filter.outputs.code_related == 'true') && matrix.run-examples == 'true' }}
        run: |
          python -m pip install -q pandas scikit-learn tqdm
 
      - name: Smoke test examples
        if: ${{ (github.event_name != 'pull_request' || steps.filter.outputs.code_related == 'true') && matrix.run-examples == 'true' }}
        timeout-minutes: 60
        working-directory: examples
        env:
          DEEPMATCH_EXAMPLE_FAST: "1"
        run: |
          python run_youtubednn.py
          python run_dssm_inbatchsoftmax.py
          python run_dssm_negsampling.py
          python run_sdm.py
          python run_ncf.py
 
      - name: Upload coverage to Codecov
        if: ${{ github.event_name != 'pull_request' || steps.filter.outputs.code_related == 'true' }}
        uses: codecov/codecov-action@v6
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: ./coverage.xml
          flags: pytest
          name: py${{ matrix.python-version }}-tf${{ matrix.tf-version }}
 

What changed

2 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 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow