documentation workflow (neurolib-dev/neurolib)
The documentation workflow from neurolib-dev/neurolib, explained and optimized by Latchkey.
CI health: F - at risk
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 documentation workflow from the neurolib-dev/neurolib 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: documentation
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.7]
steps:
- name: Copy Repository Contents β©
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }} π
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies π
run: |
python -m pip install --upgrade pip
pip install mkdocs mkdocs-material mkdocstrings mkdocstrings-python mknotebooks Pygments livereload
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install .
- name: Build documentation π·ββοΈ
run: |
mkdocs build
- name: Predeploy on PR βοΈ
if: github.event_name == 'pull_request'
uses: JamesIves/github-pages-deploy-action@4.0.0
with:
folder: site
target-folder: "predeploy"
token: ${{ secrets.DOC_ACCESS_TOKEN }}
branch: master
commit-message: "PR predeploy"
repository-name: neurolib-dev/neurolib-dev.github.io
- name: Deploy π
if: github.event_name == 'push'
uses: JamesIves/github-pages-deploy-action@4.0.0
with:
folder: site
token: ${{ secrets.DOC_ACCESS_TOKEN }}
branch: master
repository-name: neurolib-dev/neurolib-dev.github.io
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: documentation on: push: branches: - master pull_request: branches: - master concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: timeout-minutes: 30 runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest] python-version: [3.7] steps: - name: Copy Repository Contents β© uses: actions/checkout@v2 with: persist-credentials: false - name: Set up Python ${{ matrix.python-version }} π uses: actions/setup-python@v2 with: cache: 'pip' python-version: ${{ matrix.python-version }} - name: Install dependencies π run: | python -m pip install --upgrade pip pip install mkdocs mkdocs-material mkdocstrings mkdocstrings-python mknotebooks Pygments livereload if [ -f requirements.txt ]; then pip install -r requirements.txt; fi pip install . - name: Build documentation π·ββοΈ run: | mkdocs build - name: Predeploy on PR βοΈ if: github.event_name == 'pull_request' uses: JamesIves/github-pages-deploy-action@4.0.0 with: folder: site target-folder: "predeploy" token: ${{ secrets.DOC_ACCESS_TOKEN }} branch: master commit-message: "PR predeploy" repository-name: neurolib-dev/neurolib-dev.github.io - name: Deploy π if: github.event_name == 'push' uses: JamesIves/github-pages-deploy-action@4.0.0 with: folder: site token: ${{ secrets.DOC_ACCESS_TOKEN }} branch: master repository-name: neurolib-dev/neurolib-dev.github.io
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.
- 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 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.