Performance workflow (alerta/alerta)
The Performance workflow from alerta/alerta, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Performance workflow from the alerta/alerta 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: Performance
on:
push:
branches: [ master, release/* ]
tags: [ '**' ]
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
jobs:
load-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: alerta
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
alerta:
image: ghcr.io/alerta/alerta-api
ports:
- 8080:8080
env:
DEBUG: 1
DATABASE_URL: postgres://postgres:postgres@postgres:5432/alerta
options: >-
--health-cmd "curl --fail http://localhost:8080/_ || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-start-period 30s
steps:
- name: Perf test
run: >-
docker run
--network host
ghcr.io/act10ns/hey
-z 2s
-m POST
-T application/json
-d '{"environment":"Production","service":["network"],"resource":"router01","event":"node_down"}'
http://localhost:8080/alert
- uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
if: failure()
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Performance on: push: branches: [ master, release/* ] tags: [ '**' ] env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: load-test: timeout-minutes: 30 runs-on: latchkey-small services: postgres: image: postgres:15 env: POSTGRES_DB: alerta POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres ports: - 5432:5432 options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 alerta: image: ghcr.io/alerta/alerta-api ports: - 8080:8080 env: DEBUG: 1 DATABASE_URL: postgres://postgres:postgres@postgres:5432/alerta options: >- --health-cmd "curl --fail http://localhost:8080/_ || exit 1" --health-interval 10s --health-timeout 5s --health-retries 5 --health-start-period 30s steps: - name: Perf test run: >- docker run --network host ghcr.io/act10ns/hey -z 2s -m POST -T application/json -d '{"environment":"Production","service":["network"],"resource":"router01","event":"node_down"}' http://localhost:8080/alert - uses: act10ns/slack@v2 with: status: ${{ job.status }} steps: ${{ toJson(steps) }} if: failure()
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.
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 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.