Skip to content
Latchkey

Continuous Integration workflow (Trusted-AI/AIF360)

The Continuous Integration workflow from Trusted-AI/AIF360, 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: Trusted-AI/AIF360.github/workflows/ci.ymlLicense Apache-2.0View source

What it does

This is the Continuous Integration workflow from the Trusted-AI/AIF360 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: Continuous Integration

# Controls when the action will run.
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
    paths-ignore:
      - '*.md'

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  build-py:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        python-version: ['3.10', 3.11, 3.12, 3.13]

    env:
      UCI_DB: "https://archive.ics.uci.edu/ml/machine-learning-databases"
      PROPUBLICA_GH: "https://raw.githubusercontent.com/propublica/compas-analysis/bafff5da3f2e45eca6c2d5055faad269defd135a"

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - name: Check out repo
        uses: actions/checkout@v6

      - name: Set up R
        uses: r-lib/actions/setup-r@v2

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install dependencies
        run: |
          sudo apt install libglpk-dev libxml2-dev
          python -m pip install --upgrade pip setuptools wheel
          pip install '.[all]' --extra-index-url https://download.pytorch.org/whl/cpu
          pip install flake8
          pip list
          python -m rpy2.situation

      - name: Download datasets
        run: |
          wget ${UCI_DB}/adult/adult.data -P aif360/data/raw/adult/
          wget ${UCI_DB}/adult/adult.test -P aif360/data/raw/adult/
          wget ${UCI_DB}/adult/adult.names -P aif360/data/raw/adult/
          wget ${UCI_DB}/statlog/german/german.data -P aif360/data/raw/german/
          wget ${UCI_DB}/statlog/german/german.doc -P aif360/data/raw/german/
          wget ${PROPUBLICA_GH}/compas-scores-two-years.csv -P aif360/data/raw/compas/
          wget ${UCI_DB}/00222/bank-additional.zip -P aif360/data/raw/bank/ && unzip -j aif360/data/raw/bank/bank-additional.zip -d aif360/data/raw/bank/ && rm aif360/data/raw/bank/bank-additional.zip
          (cd aif360/data/raw/meps;Rscript generate_data.R <<< y)

      - name: Lint with flake8
        run: |
          # stop the build if there are Python syntax errors or undefined names
          flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
          # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
          flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

      - name: Test with pytest
        run: pytest tests --cov=aif360 --cov-report=term-missing

  build-r:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        python-version: ['3.10', 3.11, 3.12, 3.13]

    steps:
      - name: Check out repo
        uses: actions/checkout@v6

      - name: Set up R
        uses: r-lib/actions/setup-r@v2

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install R dependencies
        run: install.packages(c("reticulate", "rstudioapi", "testthat"))
        shell: Rscript {0}

      - name: Install Python dependencies
        run: |
          python -m pip install --upgrade pip setuptools wheel
          pip install '.[all]'

      - name: Install R package
        run: R CMD INSTALL aif360/aif360-r

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: Continuous Integration
 
# Controls when the action will run.
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
    paths-ignore:
      - '*.md'
 
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:
 
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build-py:
    timeout-minutes: 30
    runs-on: latchkey-small
 
    strategy:
      fail-fast: false
      matrix:
        python-version: ['3.10', 3.11, 3.12, 3.13]
 
    env:
      UCI_DB: "https://archive.ics.uci.edu/ml/machine-learning-databases"
      PROPUBLICA_GH: "https://raw.githubusercontent.com/propublica/compas-analysis/bafff5da3f2e45eca6c2d5055faad269defd135a"
 
    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - name: Check out repo
        uses: actions/checkout@v6
 
      - name: Set up R
        uses: r-lib/actions/setup-r@v2
 
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: ${{ matrix.python-version }}
 
      - name: Install dependencies
        run: |
          sudo apt install libglpk-dev libxml2-dev
          python -m pip install --upgrade pip setuptools wheel
          pip install '.[all]' --extra-index-url https://download.pytorch.org/whl/cpu
          pip install flake8
          pip list
          python -m rpy2.situation
 
      - name: Download datasets
        run: |
          wget ${UCI_DB}/adult/adult.data -P aif360/data/raw/adult/
          wget ${UCI_DB}/adult/adult.test -P aif360/data/raw/adult/
          wget ${UCI_DB}/adult/adult.names -P aif360/data/raw/adult/
          wget ${UCI_DB}/statlog/german/german.data -P aif360/data/raw/german/
          wget ${UCI_DB}/statlog/german/german.doc -P aif360/data/raw/german/
          wget ${PROPUBLICA_GH}/compas-scores-two-years.csv -P aif360/data/raw/compas/
          wget ${UCI_DB}/00222/bank-additional.zip -P aif360/data/raw/bank/ && unzip -j aif360/data/raw/bank/bank-additional.zip -d aif360/data/raw/bank/ && rm aif360/data/raw/bank/bank-additional.zip
          (cd aif360/data/raw/meps;Rscript generate_data.R <<< y)
 
      - name: Lint with flake8
        run: |
          # stop the build if there are Python syntax errors or undefined names
          flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
          # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
          flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
 
      - name: Test with pytest
        run: pytest tests --cov=aif360 --cov-report=term-missing
 
  build-r:
    timeout-minutes: 30
    runs-on: latchkey-small
 
    strategy:
      fail-fast: false
      matrix:
        python-version: ['3.10', 3.11, 3.12, 3.13]
 
    steps:
      - name: Check out repo
        uses: actions/checkout@v6
 
      - name: Set up R
        uses: r-lib/actions/setup-r@v2
 
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: ${{ matrix.python-version }}
 
      - name: Install R dependencies
        run: install.packages(c("reticulate", "rstudioapi", "testthat"))
        shell: Rscript {0}
 
      - name: Install Python dependencies
        run: |
          python -m pip install --upgrade pip setuptools wheel
          pip install '.[all]'
 
      - name: Install R package
        run: R CMD INSTALL aif360/aif360-r
 

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