-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (59 loc) · 2 KB
/
internal_tests.yaml
File metadata and controls
72 lines (59 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Internal Packages Tests
on:
pull_request:
workflow_call:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test Internal Packages
runs-on: [self-hosted-linux-amd64-noble-edge]
env:
COVERAGE_THRESHOLD: 85
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 1.26
- name: Ensure No Formatting Changes
run: |
go fmt ./...
git diff --exit-code
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.11.3
- name: Run Unit and Integration Test of internal packages
env:
POSTGRESQL_DB_CONNECT_STRING: postgres://postgres:postgres@localhost:5432/postgres
run: |
# Clear test cache to ensure coverage is calculated fresh
go clean -testcache
# We exclude packages from coverage analysis as they are highly uncovered at the moment
EXCLUDE_PKGS="internal/telemetry"
COVER_PKG=$(go list ./internal/... | grep -Ev "$EXCLUDE_PKGS" | tr '\n' ',')
go test -v -count=1 -coverprofile=coverage.out -race -tags=integration -coverpkg=$COVER_PKG ./internal/...
- name: Print coverage report
run: |
go tool cover -func=coverage.out
- name: Generate coverage report
run: go tool cover -html=coverage.out -o=coverage.html
- uses: actions/upload-artifact@v7.0.0
with:
name: coverage-report
path: coverage.html
- name: Enforce min coverage
run: |
if ! go tool cover -func=coverage.out | tail -1 | awk '{if ($3 < ENVIRON["COVERAGE_THRESHOLD"]) exit 1}'; then
echo "::error::Code coverage is below $COVERAGE_THRESHOLD"
exit 1
fi
services:
postgres:
image: postgres:16.13
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432