CI workflow (prometheus-community/postgres_exporter)
The CI workflow from prometheus-community/postgres_exporter, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the CI workflow from the prometheus-community/postgres_exporter 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: CI
on:
pull_request:
push:
branches: [main, master, 'release-*']
tags: ['v*']
permissions:
contents: read
jobs:
integration_tests:
name: Integration tests
runs-on: ubuntu-latest
strategy:
matrix:
# Define Postgres versions to test against.
postgres_version:
- 13.22
- 14.19
- 15.14
- 16.10
- 17.6
- 18.1
services:
postgres:
image: postgres:${{ matrix.postgres_version }}
env:
POSTGRES_DB: circle_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: test
# options: >-
# --health-cmd="pg_isready -U postgres -d circle_test"
# --health-interval=10s
# --health-timeout=5s
# --health-retries=5
container:
# Whenever the Go version is updated here, .promu.yml
# should also be updated.
image: quay.io/prometheus/golang-builder:1.26-base
env:
DATA_SOURCE_NAME: 'postgresql://postgres:test@postgres:5432/circle_test?sslmode=disable'
GOOPTS: '-v -tags integration'
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- uses: prometheus/promci-setup@3e5cd31b34b8ae19efa8f071c5e3cdb44884a7f8 # v0.2.1
- run: make build
- run: make test
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
--- name: CI on: pull_request: push: branches: [main, master, 'release-*'] tags: ['v*'] permissions: contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: integration_tests: timeout-minutes: 30 name: Integration tests runs-on: latchkey-small strategy: matrix: # Define Postgres versions to test against. postgres_version: - 13.22 - 14.19 - 15.14 - 16.10 - 17.6 - 18.1 services: postgres: image: postgres:${{ matrix.postgres_version }} env: POSTGRES_DB: circle_test POSTGRES_USER: postgres POSTGRES_PASSWORD: test # options: >- # --health-cmd="pg_isready -U postgres -d circle_test" # --health-interval=10s # --health-timeout=5s # --health-retries=5 container: # Whenever the Go version is updated here, .promu.yml # should also be updated. image: quay.io/prometheus/golang-builder:1.26-base env: DATA_SOURCE_NAME: 'postgresql://postgres:test@postgres:5432/circle_test?sslmode=disable' GOOPTS: '-v -tags integration' steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: persist-credentials: false - uses: prometheus/promci-setup@3e5cd31b34b8ae19efa8f071c5e3cdb44884a7f8 # v0.2.1 - run: make build - run: make test
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.
- Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 1 job (6 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.