github action (#18) #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Thunder Test Pipeline | |
on: | |
push: | |
branches: [ main, dev ] | |
pull_request: | |
branches: [ main, dev ] | |
jobs: | |
test: | |
name: Run Tests and Generate Coverage | |
runs-on: ubuntu-latest | |
env: | |
JWT_SECRET: "testsecret" | |
services: | |
postgres: | |
image: postgres:15 | |
env: | |
POSTGRES_DB: testdb | |
POSTGRES_USER: testuser | |
POSTGRES_PASSWORD: testpass | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd "pg_isready -U testuser -d testdb" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
- name: Install Dependencies | |
run: go mod tidy | |
- name: Run Unit Tests | |
run: go test -v ./... | |
- name: Run Integration Tests (gRPC + REST) | |
run: go test -v ./backend/... ./db/... | |
- name: Generate Coverage Report | |
run: go test -coverprofile=coverage.txt ./backend/... ./db/... | |
- name: Print Coverage Summary | |
run: | | |
go tool cover -func=coverage.txt | |
- name: Upload Coverage Report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-report | |
path: coverage.txt |