Skip to content
Latchkey

install-example-projects workflow (conda-incubator/unidep)

The install-example-projects workflow from conda-incubator/unidep, explained and optimized by Latchkey.

F

CI health: F - at risk

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: conda-incubator/unidep.github/workflows/install-example-projects.ymlLicense BSD-3-ClauseView source

What it does

This is the install-example-projects workflow from the conda-incubator/unidep repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: install-example-projects

on:
  push:
    branches: [main]
  pull_request:

jobs:
  pip-install:
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.9", "3.10", "3.11", "3.12"]
        platform: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.platform }}
    env:
      PYTHONIOENCODING: "utf8" # https://gist.github.com/NodeJSmith/e7e37f2d3f162456869f015f842bcf15
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}
      - name: Update pyproject.toml
        run: |
          python .github/use-local-unidep.py
      - name: Install example packages
        run: |
          set -ex
          # Loop over all folders in `./example` and install them
          for d in ./example/*/ ; do
            pip install -e "$d"
            pkg=$(basename $d)
            python -c "import $pkg"
            pip list
          done
        shell: bash

  micromamba-install:
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.9", "3.10", "3.11", "3.12"]
        platform: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.platform }}
    env:
      PYTHONIOENCODING: "utf8" # https://gist.github.com/NodeJSmith/e7e37f2d3f162456869f015f842bcf15
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0
      - name: Set up Python ${{ matrix.python-version }}
        uses: mamba-org/setup-micromamba@v3
        with:
          environment-name: unidep
          create-args: >-
            python=${{ matrix.python-version }}
      - name: Install unidep
        run: |
          python -m pip install --upgrade pip
          pip install -e ".[toml]"
        shell: bash -el {0}
      - name: Update pyproject.toml
        run: python .github/use-local-unidep.py
        shell: bash -el {0}
      - name: Install example packages
        run: |
          set -ex
          # Loop over all folders in `./example` and install them
          for d in ./example/*/ ; do
            unidep install -e "$d"
            pkg=$(basename $d)
            python -c "import $pkg"
            micromamba list
          done
        shell: bash -el {0}
      - name: Install pyproject_toml_project in new environment
        run: |
          unidep install -n new-env -e ./example/pyproject_toml_project
          micromamba activate new-env
          python -c "import pyproject_toml_project"
        shell: bash -el {0}


  miniconda-install:
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.9", "3.12"] # Just testing the oldest and newest supported versions
        platform: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.platform }}
    env:
      PYTHONIOENCODING: "utf8" # https://gist.github.com/NodeJSmith/e7e37f2d3f162456869f015f842bcf15
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0
      - uses: conda-incubator/setup-miniconda@v4
        with:
          auto-update-conda: true
          python-version: ${{ matrix.python-version }}
      - name: Conda info
        shell: bash -el {0}
        run: conda info
      - name: Install unidep
        run: |
          python -m pip install --upgrade pip
          pip install -e ".[toml]"
        shell: bash -el {0}
      - name: Update pyproject.toml
        run: python .github/use-local-unidep.py
        shell: bash -el {0}
      - name: Install example packages
        run: |
          set -ex
          # Loop over all folders in `./example` and install them
          for d in ./example/*/ ; do
            unidep install -e "$d"
            pkg=$(basename $d)
            python -c "import $pkg"
            conda list
          done
        shell: bash -el {0}
      - name: Install pyproject_toml_project in new environment
        run: |
          unidep install -n new-env -e ./example/pyproject_toml_project
          conda activate new-env
          python -c "import pyproject_toml_project"
        shell: bash -el {0}

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: install-example-projects
 
on:
  push:
    branches: [main]
  pull_request:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  pip-install:
    timeout-minutes: 30
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.9", "3.10", "3.11", "3.12"]
        platform: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.platform }}
    env:
      PYTHONIOENCODING: "utf8" # https://gist.github.com/NodeJSmith/e7e37f2d3f162456869f015f842bcf15
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: ${{ matrix.python-version }}
      - name: Update pyproject.toml
        run: |
          python .github/use-local-unidep.py
      - name: Install example packages
        run: |
          set -ex
          # Loop over all folders in `./example` and install them
          for d in ./example/*/ ; do
            pip install -e "$d"
            pkg=$(basename $d)
            python -c "import $pkg"
            pip list
          done
        shell: bash
 
  micromamba-install:
    timeout-minutes: 30
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.9", "3.10", "3.11", "3.12"]
        platform: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.platform }}
    env:
      PYTHONIOENCODING: "utf8" # https://gist.github.com/NodeJSmith/e7e37f2d3f162456869f015f842bcf15
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0
      - name: Set up Python ${{ matrix.python-version }}
        uses: mamba-org/setup-micromamba@v3
        with:
          environment-name: unidep
          create-args: >-
            python=${{ matrix.python-version }}
      - name: Install unidep
        run: |
          python -m pip install --upgrade pip
          pip install -e ".[toml]"
        shell: bash -el {0}
      - name: Update pyproject.toml
        run: python .github/use-local-unidep.py
        shell: bash -el {0}
      - name: Install example packages
        run: |
          set -ex
          # Loop over all folders in `./example` and install them
          for d in ./example/*/ ; do
            unidep install -e "$d"
            pkg=$(basename $d)
            python -c "import $pkg"
            micromamba list
          done
        shell: bash -el {0}
      - name: Install pyproject_toml_project in new environment
        run: |
          unidep install -n new-env -e ./example/pyproject_toml_project
          micromamba activate new-env
          python -c "import pyproject_toml_project"
        shell: bash -el {0}
 
 
  miniconda-install:
    timeout-minutes: 30
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.9", "3.12"] # Just testing the oldest and newest supported versions
        platform: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.platform }}
    env:
      PYTHONIOENCODING: "utf8" # https://gist.github.com/NodeJSmith/e7e37f2d3f162456869f015f842bcf15
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0
      - uses: conda-incubator/setup-miniconda@v4
        with:
          auto-update-conda: true
          python-version: ${{ matrix.python-version }}
      - name: Conda info
        shell: bash -el {0}
        run: conda info
      - name: Install unidep
        run: |
          python -m pip install --upgrade pip
          pip install -e ".[toml]"
        shell: bash -el {0}
      - name: Update pyproject.toml
        run: python .github/use-local-unidep.py
        shell: bash -el {0}
      - name: Install example packages
        run: |
          set -ex
          # Loop over all folders in `./example` and install them
          for d in ./example/*/ ; do
            unidep install -e "$d"
            pkg=$(basename $d)
            python -c "import $pkg"
            conda list
          done
        shell: bash -el {0}
      - name: Install pyproject_toml_project in new environment
        run: |
          unidep install -n new-env -e ./example/pyproject_toml_project
          conda activate new-env
          python -c "import pyproject_toml_project"
        shell: bash -el {0}
 

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 3 jobs (30 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