ultisuite-backend/.github/workflows/ci.yml
R3D347HR4Y 747e0d4bb4 Add CI workflow and unit tests for mail API
- Created a CI workflow in `.github/workflows/ci.yml` to run Go tests and verify database migrations.
- Added unit tests for the mail API in `internal/api/mail/handlers_test.go`, covering message listing, retrieval, sending, and label updating.
- Introduced a service interface for the mail handler in `internal/api/mail/service_iface.go`.
- Updated mail handler initialization to accept a service API in `internal/api/mail/handlers.go`.
- Implemented test authentication middleware for testing purposes in `internal/api/middleware/testauth.go`.
- Added various test cases for IMAP and SMTP functionalities, ensuring robust error handling and validation.
- Enhanced project documentation with checklist updates for testing and CI integration.
2026-05-22 17:02:37 +02:00

61 lines
1.5 KiB
YAML

name: CI
on:
push:
branches: [master, main]
pull_request:
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Go tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.23"
cache: true
- name: Run unit tests
run: go test ./...
migrations:
name: DB migrations
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: ulti
POSTGRES_PASSWORD: test
POSTGRES_DB: ultidb
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U ulti -d ultidb"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Install golang-migrate
run: |
curl -fsSL https://github.com/golang-migrate/migrate/releases/download/v4.18.1/migrate.linux-amd64.tar.gz | tar xz migrate
sudo install migrate /usr/local/bin/migrate
migrate -version
- name: Verify migrations (up → down → up)
env:
DATABASE_URL: postgres://ulti:test@localhost:5432/ultidb?sslmode=disable
run: |
set -euo pipefail
migrate -path migrations -database "$DATABASE_URL" up
migrate -path migrations -database "$DATABASE_URL" down -all
migrate -path migrations -database "$DATABASE_URL" up