Python application workflow (dooit-org/dooit)
The Python application workflow from dooit-org/dooit, 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 Python application workflow from the dooit-org/dooit 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: Python application
on:
workflow_dispatch:
release:
types: [published, prereleased, released]
permissions:
contents: write
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install pyinstaller
- name: Package app with pyinstaller
run: |
pip install git+https://github.com/dooit-org/dooit-extras.git
python -c "with open('dooit.py', 'w') as f: f.write('from dooit.__main__ import main\nmain()\n')"
pyinstaller --clean -F dooit.py --add-data="dooit/utils/default_config.py:dooit/utils/" --add-data="dooit/ui/styles.tcss:dooit/ui/" --hidden-import=dooit_extras.formatters --hidden-import=dooit_extras.bar_widgets --hidden-import=dooit_extras.scripts
# Setup File name
- name: Set Binary file name on Linux and Mac
if: matrix.os != 'windows-latest'
run: echo "BINARY_FILE_NAME=dooit" >> $GITHUB_ENV
- name: Set Binary file name on Windows
if: matrix.os == 'windows-latest'
run: Add-Content -Path $env:GITHUB_ENV -Value "BINARY_FILE_NAME=dooit.exe"
# Setup final release file names
- name: Set Final file name on Linux
if: matrix.os == 'ubuntu-latest'
run: echo "FINAL_FILE_NAME=linux-dooit" >> $GITHUB_ENV
- name: Set Final file name on MacOs
if: matrix.os == 'macos-latest'
run: echo "FINAL_FILE_NAME=macos-dooit" >> $GITHUB_ENV
- name: Set Final file name on Windows
if: matrix.os == 'windows-latest'
run: Add-Content -Path $env:GITHUB_ENV -Value "FINAL_FILE_NAME=windows-dooit.exe"
- name: Rename build files
run: cp ./dist/${{ env.BINARY_FILE_NAME }} ./dist/${{ env.FINAL_FILE_NAME }}
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.6.2
with:
name: ${{ env.FINAL_FILE_NAME }}
path: ./dist/${{ env.BINARY_FILE_NAME }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ./dist/${{ env.FINAL_FILE_NAME }}
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: Python application on: workflow_dispatch: release: types: [published, prereleased, released] permissions: contents: write jobs: build: timeout-minutes: 30 runs-on: ${{ matrix.os }} strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v4 - name: Set up Python 3.11 uses: actions/setup-python@v5 with: cache: 'pip' python-version: "3.11" - name: Install dependencies run: | python -m pip install --upgrade pip pip install . pip install pyinstaller - name: Package app with pyinstaller run: | pip install git+https://github.com/dooit-org/dooit-extras.git python -c "with open('dooit.py', 'w') as f: f.write('from dooit.__main__ import main\nmain()\n')" pyinstaller --clean -F dooit.py --add-data="dooit/utils/default_config.py:dooit/utils/" --add-data="dooit/ui/styles.tcss:dooit/ui/" --hidden-import=dooit_extras.formatters --hidden-import=dooit_extras.bar_widgets --hidden-import=dooit_extras.scripts # Setup File name - name: Set Binary file name on Linux and Mac if: matrix.os != 'windows-latest' run: echo "BINARY_FILE_NAME=dooit" >> $GITHUB_ENV - name: Set Binary file name on Windows if: matrix.os == 'windows-latest' run: Add-Content -Path $env:GITHUB_ENV -Value "BINARY_FILE_NAME=dooit.exe" # Setup final release file names - name: Set Final file name on Linux if: matrix.os == 'ubuntu-latest' run: echo "FINAL_FILE_NAME=linux-dooit" >> $GITHUB_ENV - name: Set Final file name on MacOs if: matrix.os == 'macos-latest' run: echo "FINAL_FILE_NAME=macos-dooit" >> $GITHUB_ENV - name: Set Final file name on Windows if: matrix.os == 'windows-latest' run: Add-Content -Path $env:GITHUB_ENV -Value "FINAL_FILE_NAME=windows-dooit.exe" - name: Rename build files run: cp ./dist/${{ env.BINARY_FILE_NAME }} ./dist/${{ env.FINAL_FILE_NAME }} - name: Upload a Build Artifact uses: actions/upload-artifact@v4.6.2 with: name: ${{ env.FINAL_FILE_NAME }} path: ./dist/${{ env.BINARY_FILE_NAME }} - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: files: ./dist/${{ env.FINAL_FILE_NAME }}
What changed
- Cache dependency installs on the setup step so they are served from cache.
- 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 (3 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.