Skip to content
Latchkey

CI workflow (prometheus-community/postgres_exporter)

The CI workflow from prometheus-community/postgres_exporter, explained and optimized by Latchkey.

C

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.

Grade your own workflow free or run it on Latchkey →
Source: prometheus-community/postgres_exporter.github/workflows/integration.ymlLicense Apache-2.0View source

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

workflow (.yml)
---
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

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.

Actions used in this workflow