Python CI workflow (kaifcodec/ytconverter)
The Python CI workflow from kaifcodec/ytconverter, explained and optimized by Latchkey.
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.
What it does
This is the Python CI workflow from the kaifcodec/ytconverter 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 CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install colored fontstyle httpx yt-dlp
- name: Check syntax of ytconverter.py
run: python -m py_compile standalone/ytconverter.py
test-on-windows:
runs-on: windows-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install colored fontstyle httpx yt-dlp
- name: Create dummy data.json
shell: bash
run: |
echo "{\"Name\": \"CI User\", \"Num\": \"ci@example.com\"}" > data.json
- name: Install ffmpeg (Windows)
shell: pwsh
run: |
choco install ffmpeg -y
- name: Check for ffmpeg (Windows)
shell: pwsh
run: |
ffmpeg -version
- name: Test Single MP3 Download
shell: bash
run: |
echo "Starting Single MP3 Download Test"
printf "n\nn\nn\n1\nhttp://www.youtube.com/watch?v=dQw4w9WgXcQ\n0\n\n" | python3 standalone/ytconverter.py
echo "Single MP3 Download Test Finished"
- name: Test Single MP4 Download
shell: bash
run: |
echo "Starting Single MP4 Download Test"
printf "\n2\nhttp://www.youtube.com/watch?v=dQw4w9WgXcQ\n1\n\n" | python3 standalone/ytconverter.py
echo "Single MP4 Download Test Finished"
- name: Test Multiple MP4 Download
shell: bash
run: |
echo "Starting Multiple MP4 Download Test"
printf "n\nn\nn\n3\nhttp://www.youtube.com/watch?v=dQw4w9WgXcQ\n0\n1\n\n" | python3 standalone/ytconverter.py
echo "Multiple MP4 Download Test Finished"
- name: Test Exit Option
shell: bash
run: |
echo "Starting Exit Option Test"
printf "n\nn\nn\n4\n" | python3 standalone/ytconverter.py
echo "Exit Option Test Finished"
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 CI on: push: branches: [ main ] pull_request: branches: [ main ] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: timeout-minutes: 30 runs-on: latchkey-small steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: cache: 'pip' python-version: '3.9' - name: Install dependencies run: | python -m pip install --upgrade pip pip install colored fontstyle httpx yt-dlp - name: Check syntax of ytconverter.py run: python -m py_compile standalone/ytconverter.py test-on-windows: timeout-minutes: 30 runs-on: windows-latest needs: build steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: cache: 'pip' python-version: '3.9' - name: Install dependencies shell: bash run: | python -m pip install --upgrade pip pip install colored fontstyle httpx yt-dlp - name: Create dummy data.json shell: bash run: | echo "{\"Name\": \"CI User\", \"Num\": \"ci@example.com\"}" > data.json - name: Install ffmpeg (Windows) shell: pwsh run: | choco install ffmpeg -y - name: Check for ffmpeg (Windows) shell: pwsh run: | ffmpeg -version - name: Test Single MP3 Download shell: bash run: | echo "Starting Single MP3 Download Test" printf "n\nn\nn\n1\nhttp://www.youtube.com/watch?v=dQw4w9WgXcQ\n0\n\n" | python3 standalone/ytconverter.py echo "Single MP3 Download Test Finished" - name: Test Single MP4 Download shell: bash run: | echo "Starting Single MP4 Download Test" printf "\n2\nhttp://www.youtube.com/watch?v=dQw4w9WgXcQ\n1\n\n" | python3 standalone/ytconverter.py echo "Single MP4 Download Test Finished" - name: Test Multiple MP4 Download shell: bash run: | echo "Starting Multiple MP4 Download Test" printf "n\nn\nn\n3\nhttp://www.youtube.com/watch?v=dQw4w9WgXcQ\n0\n1\n\n" | python3 standalone/ytconverter.py echo "Multiple MP4 Download Test Finished" - name: Test Exit Option shell: bash run: | echo "Starting Exit Option Test" printf "n\nn\nn\n4\n" | python3 standalone/ytconverter.py echo "Exit Option Test Finished"
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.
- 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.
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 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.