Code Analysis workflow (Unidata/siphon)
The Code Analysis workflow from Unidata/siphon, explained and optimized by Latchkey.
A
CI health: A - excellent
Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Code Analysis workflow from the Unidata/siphon repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
workflow (.yml)
name: "Code Analysis"
concurrency:
group: ${{ github.workflow}}-${{ github.head_ref }}
cancel-in-progress: true
on:
push:
branches: [main, ]
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
paths:
- '**.py'
- '.github/codeql/**'
- '.github/workflows/code-analysis.yml'
schedule:
- cron: '0 8 * * 6'
permissions:
contents: read
security-events: write
jobs:
CodeQL:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
config-file: ./.github/codeql/codeql-config.yml
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: "Code Analysis" concurrency: group: ${{ github.workflow}}-${{ github.head_ref }} cancel-in-progress: true on: push: branches: [main, ] pull_request: # The branches below must be a subset of the branches above branches: [main] paths: - '**.py' - '.github/codeql/**' - '.github/workflows/code-analysis.yml' schedule: - cron: '0 8 * * 6' permissions: contents: read security-events: write jobs: CodeQL: timeout-minutes: 30 runs-on: latchkey-small steps: - name: Checkout repository uses: actions/checkout@v7 - name: Initialize CodeQL uses: github/codeql-action/init@v4 with: config-file: ./.github/codeql/codeql-config.yml - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v4
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. - Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.