CI workflow (dropbox/dropbox-sdk-python)
The CI workflow from dropbox/dropbox-sdk-python, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the CI workflow from the dropbox/dropbox-sdk-python 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: CI
on:
pull_request:
jobs:
CI:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-15-intel, macos-latest, windows-latest, ubuntu-latest]
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U build flake8 pytest
python -m pip install -r requirements.txt
python -m pip install -r test/requirements.txt
- name: Build wheel
run: python -m build --wheel
- name: Show dist contents
run: ls -la dist
shell: bash
- name: Install package from wheel (robust)
shell: bash
run: |
WHEEL="$(python -c "import glob; w=glob.glob('dist/*.whl'); print(w[0] if w else '')")"
if [ -z "$WHEEL" ]; then
echo "No wheel was built. dist contains:"
ls -la dist || true
exit 1
fi
python -m pip install "$WHEEL"
- name: Run linter
run: |
flake8 dropbox example test
- name: Run unit tests
run: |
pytest -v test/unit/test_dropbox_unit.py
Docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: "pip"
- name: Install build and doc tooling
run: |
python -m pip install -U pip
python -m pip install build twine sphinx
python -m pip install -r requirements.txt
python -m pip install -r test/requirements.txt
- name: Build sdist and wheel (PEP 517)
run: python -m build
- name: Validate distribution metadata
run: twine check dist/*
- name: Build wheel
run: python -m build --wheel
- name: Install package from wheel
run: |
python -c "import glob,sys; w=glob.glob('dist/*.whl'); assert w, f'No wheel built. dist contains: {glob.glob(\"dist/*\")}'; print(w[0])"
python -c "import glob; print(glob.glob('dist/*.whl')[0])" > wheel_path.txt
python -m pip install "$(cat wheel_path.txt)"
shell: bash
- name: Test documentation generation
run: |
sphinx-build -b html docs build/html
Integration:
continue-on-error: true
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 1
matrix:
os: [macos-15-intel, macos-latest, windows-latest, ubuntu-latest]
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U build pytest
python -m pip install -r requirements.txt
python -m pip install -r test/requirements.txt
- name: Build wheel
run: python -m build --wheel
- name: Install package from wheel (cross-platform)
shell: bash
run: |
python -m pip install "$(python -c "import glob,sys; w=glob.glob('dist/*.whl'); assert w, f'No wheel built. dist contains: {glob.glob(\"dist/*\")}'; print(w[0])")"
- name: Run integration tests
env:
LEGACY_USER_DROPBOX_TOKEN: ${{ secrets.LEGACY_USER_DROPBOX_TOKEN }}
LEGACY_USER_CLIENT_ID: ${{ secrets.LEGACY_USER_CLIENT_ID }}
LEGACY_USER_CLIENT_SECRET: ${{ secrets.LEGACY_USER_CLIENT_SECRET }}
LEGACY_USER_REFRESH_TOKEN: ${{ secrets.LEGACY_USER_REFRESH_TOKEN }}
SCOPED_USER_DROPBOX_TOKEN: ${{ secrets.SCOPED_USER_DROPBOX_TOKEN }}
SCOPED_USER_CLIENT_ID: ${{ secrets.SCOPED_USER_CLIENT_ID }}
SCOPED_USER_CLIENT_SECRET: ${{ secrets.SCOPED_USER_CLIENT_SECRET }}
SCOPED_USER_REFRESH_TOKEN: ${{ secrets.SCOPED_USER_REFRESH_TOKEN }}
SCOPED_TEAM_DROPBOX_TOKEN: ${{ secrets.SCOPED_TEAM_DROPBOX_TOKEN }}
SCOPED_TEAM_CLIENT_ID: ${{ secrets.SCOPED_TEAM_CLIENT_ID }}
SCOPED_TEAM_CLIENT_SECRET: ${{ secrets.SCOPED_TEAM_CLIENT_SECRET }}
SCOPED_TEAM_REFRESH_TOKEN: ${{ secrets.SCOPED_TEAM_REFRESH_TOKEN }}
DROPBOX_SHARED_LINK: ${{ secrets.DROPBOX_SHARED_LINK }}
run: |
pytest -v test/integration/test_dropbox.py
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: CI on: pull_request: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: CI: timeout-minutes: 30 runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [macos-15-intel, macos-latest, windows-latest, ubuntu-latest] python-version: ["3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v5 - name: Set up Python uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} cache: "pip" - name: Install dependencies run: | python -m pip install -U pip python -m pip install -U build flake8 pytest python -m pip install -r requirements.txt python -m pip install -r test/requirements.txt - name: Build wheel run: python -m build --wheel - name: Show dist contents run: ls -la dist shell: bash - name: Install package from wheel (robust) shell: bash run: | WHEEL="$(python -c "import glob; w=glob.glob('dist/*.whl'); print(w[0] if w else '')")" if [ -z "$WHEEL" ]; then echo "No wheel was built. dist contains:" ls -la dist || true exit 1 fi python -m pip install "$WHEEL" - name: Run linter run: | flake8 dropbox example test - name: Run unit tests run: | pytest -v test/unit/test_dropbox_unit.py Docs: timeout-minutes: 30 runs-on: latchkey-small steps: - uses: actions/checkout@v5 - name: Set up Python uses: actions/setup-python@v6 with: python-version: "3.11" cache: "pip" - name: Install build and doc tooling run: | python -m pip install -U pip python -m pip install build twine sphinx python -m pip install -r requirements.txt python -m pip install -r test/requirements.txt - name: Build sdist and wheel (PEP 517) run: python -m build - name: Validate distribution metadata run: twine check dist/* - name: Build wheel run: python -m build --wheel - name: Install package from wheel run: | python -c "import glob,sys; w=glob.glob('dist/*.whl'); assert w, f'No wheel built. dist contains: {glob.glob(\"dist/*\")}'; print(w[0])" python -c "import glob; print(glob.glob('dist/*.whl')[0])" > wheel_path.txt python -m pip install "$(cat wheel_path.txt)" shell: bash - name: Test documentation generation run: | sphinx-build -b html docs build/html Integration: timeout-minutes: 30 continue-on-error: true runs-on: ${{ matrix.os }} strategy: fail-fast: false max-parallel: 1 matrix: os: [macos-15-intel, macos-latest, windows-latest, ubuntu-latest] python-version: ["3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v5 - name: Set up Python uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} cache: "pip" - name: Install dependencies run: | python -m pip install -U pip python -m pip install -U build pytest python -m pip install -r requirements.txt python -m pip install -r test/requirements.txt - name: Build wheel run: python -m build --wheel - name: Install package from wheel (cross-platform) shell: bash run: | python -m pip install "$(python -c "import glob,sys; w=glob.glob('dist/*.whl'); assert w, f'No wheel built. dist contains: {glob.glob(\"dist/*\")}'; print(w[0])")" - name: Run integration tests env: LEGACY_USER_DROPBOX_TOKEN: ${{ secrets.LEGACY_USER_DROPBOX_TOKEN }} LEGACY_USER_CLIENT_ID: ${{ secrets.LEGACY_USER_CLIENT_ID }} LEGACY_USER_CLIENT_SECRET: ${{ secrets.LEGACY_USER_CLIENT_SECRET }} LEGACY_USER_REFRESH_TOKEN: ${{ secrets.LEGACY_USER_REFRESH_TOKEN }} SCOPED_USER_DROPBOX_TOKEN: ${{ secrets.SCOPED_USER_DROPBOX_TOKEN }} SCOPED_USER_CLIENT_ID: ${{ secrets.SCOPED_USER_CLIENT_ID }} SCOPED_USER_CLIENT_SECRET: ${{ secrets.SCOPED_USER_CLIENT_SECRET }} SCOPED_USER_REFRESH_TOKEN: ${{ secrets.SCOPED_USER_REFRESH_TOKEN }} SCOPED_TEAM_DROPBOX_TOKEN: ${{ secrets.SCOPED_TEAM_DROPBOX_TOKEN }} SCOPED_TEAM_CLIENT_ID: ${{ secrets.SCOPED_TEAM_CLIENT_ID }} SCOPED_TEAM_CLIENT_SECRET: ${{ secrets.SCOPED_TEAM_CLIENT_SECRET }} SCOPED_TEAM_REFRESH_TOKEN: ${{ secrets.SCOPED_TEAM_REFRESH_TOKEN }} DROPBOX_SHARED_LINK: ${{ secrets.DROPBOX_SHARED_LINK }} run: | pytest -v test/integration/test_dropbox.py
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - 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.
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 3 jobs (25 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.