Skip to content
Latchkey

Run detailed tests workflow (wasserth/TotalSegmentator)

The Run detailed tests workflow from wasserth/TotalSegmentator, 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: wasserth/TotalSegmentator.github/workflows/run_tests.ymlLicense Apache-2.0View source

What it does

This is the Run detailed tests workflow from the wasserth/TotalSegmentator 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: Run detailed tests
on:
  push:
    paths-ignore:
      - '**.md'
jobs:

  run-tests:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.12"]  # save action minutes; not relevant: for open source unlimited minutes
    steps:
      - uses: actions/checkout@v6

      - name: Free Disk Space (Ubuntu)
        uses: jlumbroso/free-disk-space@main
        with:
          tool-cache: false
          android: true
          dotnet: false
          haskell: false
          large-packages: false
          docker-images: false
          swap-storage: false

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

      - name: Install spine report system dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y wkhtmltopdf xvfb
          
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install pytest Cython fury xgboost
          pip install torch==2.6.0 -f https://download.pytorch.org/whl/cpu
          pip install timm monai
          pip install .

      - name: Run test script
        run: ./tests/tests.sh ${{ secrets.TOTALSEGMENTATOR_LICENSE }}
        shell: bash

      - name: Run spine report tests
        run: pytest -v tests/test_spine_report.py

  # upload-dockerhub:
  #   runs-on: ubuntu-latest
  #   # needs: run-tests
  #   # if: success() && github.ref == 'refs/heads/master'
  #   strategy:
  #     matrix:
  #       python-version: ["3.8"]
  #   steps:
  #     - uses: actions/checkout@v6
  #     - name: Check disk space
  #       run: df -h
  #     - name: Login to Docker Hub
  #       uses: docker/login-action@v1
  #       with:
  #         username: ${{ secrets.DOCKER_HUB_USERNAME }}
  #         password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
  #     - name: Set up Docker Buildx
  #       uses: docker/setup-buildx-action@v1
  #     - name: Build and push
  #       uses: docker/build-push-action@v2
  #       with:
  #         context: .
  #         file: ./Dockerfile
  #         push: true
  #         tags: ${{ secrets.DOCKER_HUB_USERNAME }}/totalsegmentator_container:master

The same workflow, on Latchkey

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

name: Run detailed tests
on:
  push:
    paths-ignore:
      - '**.md'
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
 
  run-tests:
    timeout-minutes: 30
    runs-on: latchkey-small
    strategy:
      matrix:
        python-version: ["3.12"]  # save action minutes; not relevant: for open source unlimited minutes
    steps:
      - uses: actions/checkout@v6
 
      - name: Free Disk Space (Ubuntu)
        uses: jlumbroso/free-disk-space@main
        with:
          tool-cache: false
          android: true
          dotnet: false
          haskell: false
          large-packages: false
          docker-images: false
          swap-storage: false
 
      - name: Set up Python ${{matrix.python-version}}
        uses: actions/setup-python@v6
        with:
          python-version: ${{matrix.python-version}}
          cache: 'pip'
 
      - name: Install spine report system dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y wkhtmltopdf xvfb
          
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install pytest Cython fury xgboost
          pip install torch==2.6.0 -f https://download.pytorch.org/whl/cpu
          pip install timm monai
          pip install .
 
      - name: Run test script
        run: ./tests/tests.sh ${{ secrets.TOTALSEGMENTATOR_LICENSE }}
        shell: bash
 
      - name: Run spine report tests
        run: pytest -v tests/test_spine_report.py
 
  # upload-dockerhub:
  #   runs-on: latchkey-small
  #   # needs: run-tests
  #   # if: success() && github.ref == 'refs/heads/master'
  #   strategy:
  #     matrix:
  #       python-version: ["3.8"]
  #   steps:
  #     - uses: actions/checkout@v6
  #     - name: Check disk space
  #       run: df -h
  #     - name: Login to Docker Hub
  #       uses: docker/login-action@v1
  #       with:
  #         username: ${{ secrets.DOCKER_HUB_USERNAME }}
  #         password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
  #     - name: Set up Docker Buildx
  #       uses: docker/setup-buildx-action@v1
  #     - name: Build and push
  #       uses: docker/build-push-action@v2
  #       with:
  #         context: .
  #         file: ./Dockerfile
  #         push: true
  #         tags: ${{ secrets.DOCKER_HUB_USERNAME }}/totalsegmentator_container:master

What changed

4 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