85 lines
1.9 KiB
YAML
85 lines
1.9 KiB
YAML
name: Run Tests
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- production
|
|
- develop
|
|
paths:
|
|
- '**/*.go'
|
|
- 'go.mod'
|
|
- 'go.sum'
|
|
- '.gitea/workflows/test.yml'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- production
|
|
- develop
|
|
paths:
|
|
- '**/*.go'
|
|
- 'go.mod'
|
|
- 'go.sum'
|
|
- '.gitea/workflows/test.yml'
|
|
|
|
jobs:
|
|
test:
|
|
name: Run Go Tests
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.25'
|
|
|
|
- name: Cache Go modules
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
|
|
- name: Install dependencies
|
|
run: go mod download
|
|
|
|
- name: Run tests
|
|
run: go test -v -race -coverprofile=coverage.out ./...
|
|
|
|
# - name: Upload coverage
|
|
# uses: codecov/codecov-action@v4
|
|
# if: always()
|
|
# with:
|
|
# file: ./coverage.out
|
|
# flags: backend
|
|
# name: backend-coverage
|
|
|
|
lint:
|
|
name: Lint Code
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: true # Allow failure until golangci-lint supports Go 1.25
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.25'
|
|
|
|
- name: Install golangci-lint from source
|
|
run: |
|
|
# Install golangci-lint from source using Go 1.25 to ensure compatibility
|
|
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
|
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
|
|
|
- name: Run golangci-lint
|
|
run: |
|
|
golangci-lint --version
|
|
golangci-lint run --timeout=5m
|