Auto generate stub of RANS cpp module workflow (xiaosu-zhu/McQuic)
The Auto generate stub of RANS cpp module workflow from xiaosu-zhu/McQuic, explained and optimized by Latchkey.
CI health: F - at risk
Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Auto generate stub of RANS cpp module workflow from the xiaosu-zhu/McQuic 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
name: Auto generate stub of RANS cpp module
on:
push:
branches: [main]
paths: ['third_party/CompressAI/**']
jobs:
update-stub:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: '3.9'
- name: Setup conda
uses: conda-incubator/setup-miniconda@v2
with:
auto-activate-base: true
activate-environment: ""
- name: Install dependencies
run: |
eval "$(conda shell.bash hook)"
conda activate
conda install -y python=3.9 cpuonly "torchvision>=0.12,<1" "pytorch>=1.11,<2" -c pytorch
conda install -y "pybind11>=2.6,<3" "pip>=22" "tensorboard>=2.3,<3" "rich>=10,<11" "python-lmdb>=1.2,<2" "pyyaml>=5.4,<7" "marshmallow>=3.14,<4" "click>=8,<9" "vlutils>=0.1.22" "msgpack-python>=1,<2" packaging -c xiaosu-zhu -c conda-forge
conda install -y pip
pip install -e .
pip install pybind11-stubgen
- name: Generate python stubs
run: |
eval "$(conda shell.bash hook)"
conda activate
pybind11-stubgen --no-setup-py mcquic.rans
mv stubs/mcquic/rans-stubs/*.pyi mcquic/rans.pyi
sed -i 's/: str/: bytes/g' mcquic/rans.pyi
rm -rf stubs
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Auto update pyi stubs of mcquic.rans module
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: Auto generate stub of RANS cpp module on: push: branches: [main] paths: ['third_party/CompressAI/**'] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: update-stub: timeout-minutes: 30 runs-on: latchkey-small steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v3 with: cache: 'pip' python-version: '3.9' - name: Setup conda uses: conda-incubator/setup-miniconda@v2 with: auto-activate-base: true activate-environment: "" - name: Install dependencies run: | eval "$(conda shell.bash hook)" conda activate conda install -y python=3.9 cpuonly "torchvision>=0.12,<1" "pytorch>=1.11,<2" -c pytorch conda install -y "pybind11>=2.6,<3" "pip>=22" "tensorboard>=2.3,<3" "rich>=10,<11" "python-lmdb>=1.2,<2" "pyyaml>=5.4,<7" "marshmallow>=3.14,<4" "click>=8,<9" "vlutils>=0.1.22" "msgpack-python>=1,<2" packaging -c xiaosu-zhu -c conda-forge conda install -y pip pip install -e . pip install pybind11-stubgen - name: Generate python stubs run: | eval "$(conda shell.bash hook)" conda activate pybind11-stubgen --no-setup-py mcquic.rans mv stubs/mcquic/rans-stubs/*.pyi mcquic/rans.pyi sed -i 's/: str/: bytes/g' mcquic/rans.pyi rm -rf stubs - uses: stefanzweifel/git-auto-commit-action@v4 with: commit_message: Auto update pyi stubs of mcquic.rans module
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.
2 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:
- Dependency installs
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.