Lint workflow (microsoft/Olive)
The Lint workflow from microsoft/Olive, 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 Lint workflow from the microsoft/Olive 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: Lint
on:
push:
branches:
- main
- rel-*
pull_request:
jobs:
optional-lint:
name: Optional Lint
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- name: misspell # Check spellings as well
uses: reviewdog/action-misspell@v1
with:
github_token: ${{ secrets.github_token }}
locale: "US"
reporter: github-pr-check
level: info
filter_mode: diff_context
ignore: canceled,strat,hardlinked
exclude: |
./NOTICE.txt
- name: shellcheck # Static check shell scripts
uses: reviewdog/action-shellcheck@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
level: info
filter_mode: file
lint-python-format:
# Required workflow
name: Python format
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
# Version range or exact version of Python to use, using SemVer's version range syntax. Reads from .python-version if unset.
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install -r requirements-dev.txt
lintrunner init
- name: Run lintrunner on all files
run: |
set +e
if ! lintrunner --force-color --all-files --tee-json=lint.json -v; then
echo ""
echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner\`. To set up lintrunner locally, see https://github.com/microsoft/Olive/blob/main/CONTRIBUTING.md#linting .\e[0m"
exit 1
fi
- name: Produce SARIF
if: always()
run: |
python -m lintrunner_adapters to-sarif lint.json lintrunner.sarif
- name: Upload SARIF file
if: always()
continue-on-error: true
uses: github/codeql-action/upload-sarif@v3
with:
# Path to SARIF file relative to the root of the repository
sarif_file: lintrunner.sarif
category: lintrunner
checkout_path: ${{ github.workspace }}
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: Lint on: push: branches: - main - rel-* pull_request: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: optional-lint: timeout-minutes: 30 name: Optional Lint runs-on: latchkey-small permissions: actions: read contents: read security-events: write steps: - uses: actions/checkout@v4 - name: misspell # Check spellings as well uses: reviewdog/action-misspell@v1 with: github_token: ${{ secrets.github_token }} locale: "US" reporter: github-pr-check level: info filter_mode: diff_context ignore: canceled,strat,hardlinked exclude: | ./NOTICE.txt - name: shellcheck # Static check shell scripts uses: reviewdog/action-shellcheck@v1 with: github_token: ${{ secrets.github_token }} reporter: github-pr-check level: info filter_mode: file lint-python-format: timeout-minutes: 30 # Required workflow name: Python format runs-on: latchkey-small permissions: actions: read contents: read security-events: write steps: - uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v5 with: cache: 'pip' # Version range or exact version of Python to use, using SemVer's version range syntax. Reads from .python-version if unset. python-version: "3.12" - name: Install dependencies run: | python -m pip install -r requirements-dev.txt lintrunner init - name: Run lintrunner on all files run: | set +e if ! lintrunner --force-color --all-files --tee-json=lint.json -v; then echo "" echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner\`. To set up lintrunner locally, see https://github.com/microsoft/Olive/blob/main/CONTRIBUTING.md#linting .\e[0m" exit 1 fi - name: Produce SARIF if: always() run: | python -m lintrunner_adapters to-sarif lint.json lintrunner.sarif - name: Upload SARIF file if: always() continue-on-error: true uses: github/codeql-action/upload-sarif@v3 with: # Path to SARIF file relative to the root of the repository sarif_file: lintrunner.sarif category: lintrunner checkout_path: ${{ github.workspace }}
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 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.