75 lines
1.9 KiB
YAML
75 lines
1.9 KiB
YAML
name: Backend Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- "apps/backend/**"
|
|
- ".github/workflows/backend-tests.yml"
|
|
pull_request:
|
|
branches: [main]
|
|
paths:
|
|
- "apps/backend/**"
|
|
- ".github/workflows/backend-tests.yml"
|
|
|
|
jobs:
|
|
test:
|
|
name: Run Backend Tests
|
|
runs-on: homelab-runner
|
|
defaults:
|
|
run:
|
|
working-directory: apps/backend
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
if: ${{ !contains(runner.name, 'homelab') }}
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: apps/backend/go.mod
|
|
cache-dependency-path: apps/backend/go.sum
|
|
|
|
- name: Cache Go modules
|
|
if: ${{ contains(runner.name, 'homelab') }}
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/go/pkg/mod
|
|
~/.cache/go-build
|
|
~/.cache/golangci-lint
|
|
key: go-${{ runner.os }}-${{ hashFiles('apps/backend/go.sum') }}
|
|
restore-keys: go-${{ runner.os }}-
|
|
|
|
- name: Build
|
|
run: go build -v ./cmd/kandev
|
|
|
|
- name: Run golangci-lint
|
|
uses: golangci/golangci-lint-action@v9
|
|
with:
|
|
version: v2.9
|
|
args: ./...
|
|
working-directory: apps/backend
|
|
|
|
- name: Run tests
|
|
run: |
|
|
set -o pipefail
|
|
go test -v -race -coverprofile=coverage.out -covermode=atomic -json ./... 2>&1 | tee test-results.json
|
|
|
|
- name: Generate test report
|
|
uses: robherley/go-test-action@v0
|
|
if: always()
|
|
with:
|
|
fromJSONFile: apps/backend/test-results.json
|
|
|
|
- name: Upload test artifacts
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: test-results
|
|
path: |
|
|
apps/backend/coverage.out
|
|
apps/backend/test-results.json
|
|
retention-days: 30
|