Mac tests workflow (palantir/python-language-server)
The Mac tests workflow from palantir/python-language-server, 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 Mac tests workflow from the palantir/python-language-server 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: Mac tests
on:
push:
branches:
- develop
pull_request:
branches:
- '*'
jobs:
build:
name: Mac Py${{ matrix.PYTHON_VERSION }}
runs-on: macos-latest
env:
CI: 'true'
OS: 'macos'
PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }}
strategy:
fail-fast: false
matrix:
PYTHON_VERSION: ['3.8', '3.7', '3.6', '2.7']
timeout-minutes: 10
steps:
- uses: actions/cache@v1
with:
path: ~/Library/Caches/pip
key: ${{ runner.os }}-${{ matrix.PYTHON_VERSION }}-pip-${{ hashFiles('setup.py') }}
restore-keys: ${{ runner.os }}-${{ matrix.PYTHON_VERSION }}-pip-
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.PYTHON_VERSION }}
architecture: 'x64'
- name: Create Jedi environment for testing
if: matrix.PYTHON_VERSION != '2.7'
run: |
python3 -m venv /tmp/pyenv
/tmp/pyenv/bin/python -m pip install loghub
- run: python -m pip install --upgrade pip setuptools
- run: pip install -e .[all,test]
- run: py.test -v test/
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: Mac tests on: push: branches: - develop pull_request: branches: - '*' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: name: Mac Py${{ matrix.PYTHON_VERSION }} runs-on: macos-latest env: CI: 'true' OS: 'macos' PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }} strategy: fail-fast: false matrix: PYTHON_VERSION: ['3.8', '3.7', '3.6', '2.7'] timeout-minutes: 10 steps: - uses: actions/cache@v1 with: path: ~/Library/Caches/pip key: ${{ runner.os }}-${{ matrix.PYTHON_VERSION }}-pip-${{ hashFiles('setup.py') }} restore-keys: ${{ runner.os }}-${{ matrix.PYTHON_VERSION }}-pip- - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: cache: 'pip' python-version: ${{ matrix.PYTHON_VERSION }} architecture: 'x64' - name: Create Jedi environment for testing if: matrix.PYTHON_VERSION != '2.7' run: | python3 -m venv /tmp/pyenv /tmp/pyenv/bin/python -m pip install loghub - run: python -m pip install --upgrade pip setuptools - run: pip install -e .[all,test] - run: py.test -v test/
What changed
- 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.
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 (4 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.