Skip to content
Latchkey

Poetry Downstream Tests workflow (python-poetry/poetry-core)

The Poetry Downstream Tests workflow from python-poetry/poetry-core, explained and optimized by Latchkey.

D

CI health: D - needs work

Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: python-poetry/poetry-core.github/workflows/downstream.yamlLicense MITView source

What it does

This is the Poetry Downstream Tests workflow from the python-poetry/poetry-core 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

workflow (.yml)
name: Poetry Downstream Tests

on:
  workflow_dispatch:
  pull_request: {}
  push:
    branches: [main]

permissions: {}

jobs:
  tests:
    name: ${{ matrix.ref }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        ref: ["main"]
      fail-fast: false
    defaults:
      run:
        shell: bash
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false
          path: poetry-core

      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false
          path: poetry
          repository: python-poetry/poetry
          ref: ${{ matrix.ref }}

      - name: Set up Python 3.10
        uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
        with:
          python-version: "3.10"

      - name: Get full python version
        id: full-python-version
        run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT

      - name: Set up Poetry
        run: |
          pip install poetry
          poetry config virtualenvs.in-project true

      - name: Set up cache
        uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
        id: cache
        with:
          path: ./poetry/.venv
          key: venv-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}

      - name: Ensure cache is healthy
        if: steps.cache.outputs.cache-hit == 'true'
        working-directory: ./poetry
        run: timeout 10s poetry run pip --version >/dev/null 2>&1 || rm -rf .venv

      - name: Switch downstream to development poetry-core
        working-directory: ./poetry
        run: |
          # remove poetry-core from main group to avoid version conflicts
          # with a potential entry in the test group
          poetry remove poetry-core
          # add to test group to overwrite a potential entry in that group
          poetry add --lock --group test ../poetry-core

      - name: Install downstream dependencies
        working-directory: ./poetry
        run: |
          # force update of directory dependency in cached venv
          # (even if directory dependency with same version is already installed)
          poetry run pip uninstall -y poetry-core
          poetry install

      # TODO: mark run as success even when this fails and add comment to PR instead
      - name: Run downstream test suite
        working-directory: ./poetry
        run: poetry run pytest

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: Poetry Downstream Tests
 
on:
  workflow_dispatch:
  pull_request: {}
  push:
    branches: [main]
 
permissions: {}
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  tests:
    timeout-minutes: 30
    name: ${{ matrix.ref }}
    runs-on: latchkey-small
    strategy:
      matrix:
        ref: ["main"]
      fail-fast: false
    defaults:
      run:
        shell: bash
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false
          path: poetry-core
 
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false
          path: poetry
          repository: python-poetry/poetry
          ref: ${{ matrix.ref }}
 
      - name: Set up Python 3.10
        uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
        with:
          cache: 'pip'
          python-version: "3.10"
 
      - name: Get full python version
        id: full-python-version
        run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
 
      - name: Set up Poetry
        run: |
          pip install poetry
          poetry config virtualenvs.in-project true
 
      - name: Set up cache
        uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
        id: cache
        with:
          path: ./poetry/.venv
          key: venv-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
 
      - name: Ensure cache is healthy
        if: steps.cache.outputs.cache-hit == 'true'
        working-directory: ./poetry
        run: timeout 10s poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
 
      - name: Switch downstream to development poetry-core
        working-directory: ./poetry
        run: |
          # remove poetry-core from main group to avoid version conflicts
          # with a potential entry in the test group
          poetry remove poetry-core
          # add to test group to overwrite a potential entry in that group
          poetry add --lock --group test ../poetry-core
 
      - name: Install downstream dependencies
        working-directory: ./poetry
        run: |
          # force update of directory dependency in cached venv
          # (even if directory dependency with same version is already installed)
          poetry run pip uninstall -y poetry-core
          poetry install
 
      # TODO: mark run as success even when this fails and add comment to PR instead
      - name: Run downstream test suite
        working-directory: ./poetry
        run: poetry run pytest
 

What changed

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