Crossplatform workflow (tough-dev-school/education-backend)
The Crossplatform workflow from tough-dev-school/education-backend, explained and optimized by Latchkey.
CI health: B - good
Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Crossplatform workflow from the tough-dev-school/education-backend 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: Crossplatform
on:
schedule:
- cron: '30 4 * * *'
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-24.04
steps:
- name: checkout
uses: actions/checkout@v6
- name: build
uses: ./.github/actions/build
- name: lint
run: make lint
test:
needs: lint
runs-on: ubuntu-24.04
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_PASSWORD: secret
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:6.2.20-alpine
ports:
- 6379:6379
steps:
- name: checkout
uses: actions/checkout@v6
- name: build
uses: ./.github/actions/build
- name: install locale stuff
run: |
sudo apt-get update
sudo apt-get --no-install-recommends install -y locales-all gettext
- name: test
env:
DATABASE_URL: postgres://postgres:secret@localhost:5432/postgres
REDISCLOUD_URL: redis://localhost:6379/5
run: make test
build-docker-image:
needs: test
runs-on: ubuntu-24.04
steps:
- name: checkout
uses: actions/checkout@v6
- name: build
uses: ./.github/actions/build
- name: set up qemu
uses: docker/setup-qemu-action@v3
- name: set up buildx
uses: docker/setup-buildx-action@v3
- name: generate image identifier
id: image
uses: ASzc/change-string-case-action@v6
with:
string: ${{ github.repository_owner }}
- name: login to ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: build dev image
uses: docker/build-push-action@v6
with:
context: .
target: web
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ steps.image.outputs.lowercase }}/dev-backend:${{ github.sha }}
ghcr.io/${{ steps.image.outputs.lowercase }}/dev-backend:${{ github.ref_name }}
${{ github.ref == 'refs/heads/master' && 'ghcr.io/tough-dev-school/dev-backend:latest' || '' }}
build-args: |
PYTHON_VERSION=${{ env.python-version }}
RELEASE=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Crossplatform on: schedule: - cron: '30 4 * * *' workflow_dispatch: jobs: lint: timeout-minutes: 30 runs-on: latchkey-small steps: - name: checkout uses: actions/checkout@v6 - name: build uses: ./.github/actions/build - name: lint run: make lint test: timeout-minutes: 30 needs: lint runs-on: latchkey-small services: postgres: image: postgres:15-alpine env: POSTGRES_PASSWORD: secret options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 5432:5432 redis: image: redis:6.2.20-alpine ports: - 6379:6379 steps: - name: checkout uses: actions/checkout@v6 - name: build uses: ./.github/actions/build - name: install locale stuff run: | sudo apt-get update sudo apt-get --no-install-recommends install -y locales-all gettext - name: test env: DATABASE_URL: postgres://postgres:secret@localhost:5432/postgres REDISCLOUD_URL: redis://localhost:6379/5 run: make test build-docker-image: timeout-minutes: 30 needs: test runs-on: latchkey-small steps: - name: checkout uses: actions/checkout@v6 - name: build uses: ./.github/actions/build - name: set up qemu uses: docker/setup-qemu-action@v3 - name: set up buildx uses: docker/setup-buildx-action@v3 - name: generate image identifier id: image uses: ASzc/change-string-case-action@v6 with: string: ${{ github.repository_owner }} - name: login to ghcr uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: build dev image uses: docker/build-push-action@v6 with: context: . target: web push: true platforms: linux/amd64,linux/arm64 tags: | ghcr.io/${{ steps.image.outputs.lowercase }}/dev-backend:${{ github.sha }} ghcr.io/${{ steps.image.outputs.lowercase }}/dev-backend:${{ github.ref_name }} ${{ github.ref == 'refs/heads/master' && 'ghcr.io/tough-dev-school/dev-backend:latest' || '' }} build-args: | PYTHON_VERSION=${{ env.python-version }} RELEASE=${{ github.sha }} cache-from: type=gha cache-to: type=gha,mode=max
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.
5 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
- Container pulls and builds
This workflow runs 3 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.