Run the tests workflow (pyomeca/bioptim)
The Run the tests workflow from pyomeca/bioptim, explained and optimized by Latchkey.
CI health: C - fair
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the Run the tests workflow from the pyomeca/bioptim repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Run the tests
on: [pull_request]
env:
PREFIX_MACOS: /Users/runner/miniconda3/envs/bioptim
PREFIX_WINDOWS: C:\Miniconda3\envs\bioptim
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
shard: [1, 2, 3, 4, 5, 6]
name: Tests on ${{ matrix.os }}-shard ${{ matrix.shard }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
steps:
- name: Set prefix osx
run: |
echo "PREFIX=${{ env.PREFIX_MACOS }}" >> $GITHUB_ENV
if: matrix.os == 'macos-latest'
- name: Set prefix windows
run: |
echo "PREFIX=${{ env.PREFIX_WINDOWS }}" >> $GITHUB_ENV
if: matrix.os == 'windows-latest'
- name: Checkout code
uses: actions/checkout@v3
- name: Checkout submodules
if: matrix.shard == 1
run: git submodule update --init --recursive
- name: Setup environment
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
activate-environment: bioptim
environment-file: environment.yml
- name: Print conda info
run: |
conda info
conda list
- name: Install extra dependencies
run: conda install "numpy>=2.4,<3" pip pytest-cov black pytest pytest-cov codecov packaging -cconda-forge
- name: Install ACADOS on Mac
run: |
pwd
cd external
./acados_install_mac.sh 4 ${{ env.PREFIX_MACOS }}
cd ..
if: matrix.os == 'macos-latest' && matrix.shard == 1
- name: Test installed version of bioptim
run: |
pip install .
cd
python -c "import bioptim"
if: matrix.shard == 1
- name: Run tests without code coverage
run: pytest -v --color=yes tests/shard${{ matrix.shard }}
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Run the tests on: [pull_request] env: PREFIX_MACOS: /Users/runner/miniconda3/envs/bioptim PREFIX_WINDOWS: C:\Miniconda3\envs\bioptim concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: timeout-minutes: 30 strategy: fail-fast: false matrix: os: [macos-latest, windows-latest] shard: [1, 2, 3, 4, 5, 6] name: Tests on ${{ matrix.os }}-shard ${{ matrix.shard }} runs-on: ${{ matrix.os }} defaults: run: shell: bash -l {0} steps: - name: Set prefix osx run: | echo "PREFIX=${{ env.PREFIX_MACOS }}" >> $GITHUB_ENV if: matrix.os == 'macos-latest' - name: Set prefix windows run: | echo "PREFIX=${{ env.PREFIX_WINDOWS }}" >> $GITHUB_ENV if: matrix.os == 'windows-latest' - name: Checkout code uses: actions/checkout@v3 - name: Checkout submodules if: matrix.shard == 1 run: git submodule update --init --recursive - name: Setup environment uses: conda-incubator/setup-miniconda@v3 with: miniforge-version: latest activate-environment: bioptim environment-file: environment.yml - name: Print conda info run: | conda info conda list - name: Install extra dependencies run: conda install "numpy>=2.4,<3" pip pytest-cov black pytest pytest-cov codecov packaging -cconda-forge - name: Install ACADOS on Mac run: | pwd cd external ./acados_install_mac.sh 4 ${{ env.PREFIX_MACOS }} cd .. if: matrix.os == 'macos-latest' && matrix.shard == 1 - name: Test installed version of bioptim run: | pip install . cd python -c "import bioptim" if: matrix.shard == 1 - name: Run tests without code coverage run: pytest -v --color=yes tests/shard${{ matrix.shard }}
What changed
- Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
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:
- Dependency installs
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.