PR Test workflow (sgl-project/SpecForge)
The PR Test workflow from sgl-project/SpecForge, explained and optimized by Latchkey.
CI health: A - excellent
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 PR Test workflow from the sgl-project/SpecForge 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: PR Test
on:
pull_request:
branches: [ main ]
workflow_dispatch:
concurrency:
group: pr-test-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
unit-test:
if: (github.repository == 'sgl-project/SpecForge' || github.event_name == 'pull_request') &&
github.event.pull_request.draft == false
runs-on: [self-hosted]
container:
image: lmsysorg/sglang:v0.5.14-cu130 # we lock to this version to avoid repeated docker pull
options: --gpus all --shm-size=2g --rm -v /dev/shm --privileged --pid=host
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Restore cache
run: |
if [ -d /github/home/cache ] && [ ! -z "$(ls -A /github/home/cache/)" ]; then
cp -p -r /github/home/cache ./
fi
if [ -d /github/home/sf ] && [ ! -z "$(ls -A /github/home/sf/)" ]; then
cp -p -r /github/home/sf ./
fi
- name: Remove flashinfer # this is needed to avoid flashinfer jit compilation makes the program hang
run: |
rm -rf /github/home/.cache/flashinfer
- name: Install dependencies
shell: bash
run: |
# if sf venv does not exist, create it
if [ ! -d sf ]; then
uv venv sf -p 3.11
fi
source sf/bin/activate
uv pip install wheel setuptools psutil packaging ninja
uv pip install torch==2.11.0 --index-url https://download.pytorch.org/whl/cu130
MAX_JOBS=8 uv pip install -v flash-attn --no-build-isolation
uv pip install -v . --prerelease=allow
- name: Run test
timeout-minutes: 45
shell: bash
run: |
source sf/bin/activate
export PYTHONPATH=$PWD
python -m unittest discover -s ./tests -p "test_*.py" -v
- name: Save cache
run: |
cp -p -r sf /github/home/
cp -p -r cache /github/home/
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: PR Test on: pull_request: branches: [ main ] workflow_dispatch: concurrency: group: pr-test-${{ github.ref }} cancel-in-progress: true permissions: contents: read jobs: unit-test: timeout-minutes: 30 if: (github.repository == 'sgl-project/SpecForge' || github.event_name == 'pull_request') && github.event.pull_request.draft == false runs-on: [self-hosted] container: image: lmsysorg/sglang:v0.5.14-cu130 # we lock to this version to avoid repeated docker pull options: --gpus all --shm-size=2g --rm -v /dev/shm --privileged --pid=host steps: - name: Checkout code uses: actions/checkout@v4 - name: Restore cache run: | if [ -d /github/home/cache ] && [ ! -z "$(ls -A /github/home/cache/)" ]; then cp -p -r /github/home/cache ./ fi if [ -d /github/home/sf ] && [ ! -z "$(ls -A /github/home/sf/)" ]; then cp -p -r /github/home/sf ./ fi - name: Remove flashinfer # this is needed to avoid flashinfer jit compilation makes the program hang run: | rm -rf /github/home/.cache/flashinfer - name: Install dependencies shell: bash run: | # if sf venv does not exist, create it if [ ! -d sf ]; then uv venv sf -p 3.11 fi source sf/bin/activate uv pip install wheel setuptools psutil packaging ninja uv pip install torch==2.11.0 --index-url https://download.pytorch.org/whl/cu130 MAX_JOBS=8 uv pip install -v flash-attn --no-build-isolation uv pip install -v . --prerelease=allow - name: Run test timeout-minutes: 45 shell: bash run: | source sf/bin/activate export PYTHONPATH=$PWD python -m unittest discover -s ./tests -p "test_*.py" -v - name: Save cache run: | cp -p -r sf /github/home/ cp -p -r cache /github/home/
What changed
- 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
- Container pulls and builds
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.