Files
ntfy/.github/workflows/test.yaml
T
binwiederhier d6b510dc46 Run CI's checks, the server tests and the other Go tests as three parallel jobs, without coverage
The server package's race run takes about as long as all other packages together, so it gets its own job. Coverage was only printed to the log, and its instrumentation slowed the race run.
2026-11-01 23:54:10 +00:00

60 lines
2.2 KiB
YAML

name: test
on:
push:
branches: [ main ]
pull_request:
jobs:
test:
name: test (${{ matrix.part }})
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
part: [checks, server, rest] # In parallel: the server package takes as long as all others together
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: ntfy
POSTGRES_PASSWORD: ntfy
POSTGRES_DB: ntfy_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U ntfy"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
NTFY_TEST_DATABASE_URL: "postgres://ntfy:ntfy@localhost:5432/ntfy_test?sslmode=disable"
NTFY_TEST_S3_URL: ${{ secrets.NTFY_TEST_S3_URL }}
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: '.go-version'
- name: Install node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '24'
cache: 'npm'
cache-dependency-path: './web/package-lock.json'
- name: Install dependencies
timeout-minutes: 10 # A stalled apt mirror must fail the run, not hang it
run: make build-deps-ubuntu
- name: Build docs (required for tests)
run: make docs
- name: Build web app (required for tests)
run: make web
- name: Run web tests, formatting, vetting and linting
if: matrix.part == 'checks'
run: make web-test web-fmt-check fmt-check vet web-lint lint staticcheck template-check go-check
- name: Run Go tests of the server package (race detector)
if: matrix.part == 'server'
run: go test -race ./server
- name: Run Go tests of all other packages (race detector)
if: matrix.part == 'rest'
run: go test -race $(go list -f '{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPath}}{{end}}' ./... | grep -vE 'ntfy/v2/(test|examples|tools|web|server)$')