Check Pull Request workflow (diezo/Ensta)
The Check Pull Request workflow from diezo/Ensta, 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 Check Pull Request workflow from the diezo/Ensta 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: "Check Pull Request"
on:
pull_request:
branches:
- main
- master
jobs:
lint:
name: "Checking format"
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install pipenv
run: |
python -m pip install --upgrade pipenv wheel
- id: cache-pipenv
uses: actions/cache@v1
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
- name: Install dependencies
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: |
pipenv install --dev
- name: Run lint
run: |
pipenv run format || (echo "::error file={name},line={line},endLine={endLine},title={title}::{message}" && exit 1)
test:
name: "Running tests"
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install pipenv
run: |
python -m pip install --upgrade pipenv wheel
- id: cache-pipenv
uses: actions/cache@v1
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
- name: Install dependencies
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: |
pipenv install --dev
- name: Run test suite
run: |
pipenv run coverage
- name: Get Cover
uses: orgoro/coverage@v3.1
with:
coverageFile: coverage.xml
token: ${{ secrets.PR_GITHUB_TOKEN }}
install-test:
name: "Install"
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install project
run: |
python -m pip install ./
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: "Check Pull Request" on: pull_request: branches: - main - master concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: lint: timeout-minutes: 30 name: "Checking format" runs-on: latchkey-small steps: - name: Check out repository code uses: actions/checkout@v2 - name: Setup Python uses: actions/setup-python@v2 with: cache: 'pip' python-version: "3.10" - name: Install pipenv run: | python -m pip install --upgrade pipenv wheel - id: cache-pipenv uses: actions/cache@v1 with: path: ~/.local/share/virtualenvs key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} - name: Install dependencies if: steps.cache-pipenv.outputs.cache-hit != 'true' run: | pipenv install --dev - name: Run lint run: | pipenv run format || (echo "::error file={name},line={line},endLine={endLine},title={title}::{message}" && exit 1) test: timeout-minutes: 30 name: "Running tests" runs-on: latchkey-small steps: - name: Check out repository code uses: actions/checkout@v2 - name: Setup Python uses: actions/setup-python@v2 with: cache: 'pip' python-version: "3.10" - name: Install pipenv run: | python -m pip install --upgrade pipenv wheel - id: cache-pipenv uses: actions/cache@v1 with: path: ~/.local/share/virtualenvs key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} - name: Install dependencies if: steps.cache-pipenv.outputs.cache-hit != 'true' run: | pipenv install --dev - name: Run test suite run: | pipenv run coverage - name: Get Cover uses: orgoro/coverage@v3.1 with: coverageFile: coverage.xml token: ${{ secrets.PR_GITHUB_TOKEN }} install-test: timeout-minutes: 30 name: "Install" runs-on: latchkey-small steps: - name: Check out repository code uses: actions/checkout@v2 - name: Setup Python uses: actions/setup-python@v2 with: cache: 'pip' python-version: "3.10" - name: Install project run: | python -m pip install ./
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.
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 3 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.