Validate Main workflow (zefhub/zef)
The Validate Main workflow from zefhub/zef, 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 Validate Main workflow from the zefhub/zef repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Validate Main
on:
push:
branches:
- main
jobs:
check-license:
uses: ./.github/workflows/check-license.yml
test-code:
# check-license is quick and we want to abort quickly if that fails
needs: check-license
runs-on: ${{ matrix.os }}
environment: Release
strategy:
matrix:
# os: [ubuntu-20.04, macos-latest, windows-latest]
os: [ubuntu-20.04, macos-latest]
python-version: [3.7, "3.10", "3.11"]
exclude:
- os: macos-latest
python-version: 3.8
- os: macos-latest
python-version: 3.7
- os: windows-latest
python-version: 3.7
steps:
########
# Git things
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
# TODO: Update this to check via building the wheel rather than a local build
- name: Build
uses: ./.github/actions/build
timeout-minutes: 30
with:
python-version: ${{ matrix.python-version }}
os: ${{ matrix.os }}
test-auth-key: ${{ secrets.TEST_AUTH_KEY }}
- uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
if_mention: failure
channel: '#alerts-github-ci'
fields: repo,message,commit,author,ref,workflow # selectable (default: repo,message)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Validate Main on: push: branches: - main concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: check-license: timeout-minutes: 30 uses: ./.github/workflows/check-license.yml test-code: timeout-minutes: 30 # check-license is quick and we want to abort quickly if that fails needs: check-license runs-on: ${{ matrix.os }} environment: Release strategy: matrix: # os: [ubuntu-20.04, macos-latest, windows-latest] os: [ubuntu-20.04, macos-latest] python-version: [3.7, "3.10", "3.11"] exclude: - os: macos-latest python-version: 3.8 - os: macos-latest python-version: 3.7 - os: windows-latest python-version: 3.7 steps: ######## # Git things - uses: actions/checkout@v3 with: token: ${{ secrets.GITHUB_TOKEN }} # TODO: Update this to check via building the wheel rather than a local build - name: Build uses: ./.github/actions/build timeout-minutes: 30 with: python-version: ${{ matrix.python-version }} os: ${{ matrix.os }} test-auth-key: ${{ secrets.TEST_AUTH_KEY }} - uses: 8398a7/action-slack@v3 with: status: ${{ job.status }} if_mention: failure channel: '#alerts-github-ci' fields: repo,message,commit,author,ref,workflow # selectable (default: repo,message) env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} if: failure()
What changed
- Cancel superseded runs when a branch or PR gets a newer push.
- 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.
This workflow runs 2 jobs (7 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.