This repository has been archived by the owner on Jan 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 327
143 lines (134 loc) · 4.61 KB
/
go-tests.yml
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: go-tests
on:
pull_request:
push:
jobs:
lint:
runs-on: ubuntu-latest
env:
GOTAGS: ''
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: go.mod
- name: Download go modules
run: go mod download
- name: Install golangci-lint
run: |-
download=https://raw.githubusercontent.com/golangci/golangci-lint/9a8a056e9fe49c0e9ed2287aedce1022c79a115b/install.sh # v1.52.2
curl -sSf "$download" | sh -s v1.50.1
- run: go mod download
- name: lint
run: |-
./bin/golangci-lint run --build-tags="$GOTAGS" -v --concurrency 2 \
--disable-all \
--timeout 10m \
--enable gofmt \
--enable gosimple \
--enable govet
check-vendor:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- run: go mod tidy
- run: |
if ! git diff --exit-code; then
echo "Git directory has vendor changes"
exit 1
fi
split-go-tests:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.split-tests.outputs.matrix }}
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: './go.mod'
- name: Split tests
id: split-tests
env:
runner_count: 8
run: ./.github/scripts/split-tests.sh
go-test:
name: go-test-${{ matrix.id }}
runs-on: ubuntu-latest
needs: split-go-tests
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.split-go-tests.outputs.matrix) }}
env:
TEST_RESULTS_DIR: "/tmp/test-results"
GOTESTSUM_RELEASE: 1.8.2
GOTAGS: ''
GOMAXPROCS: 4
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Start Services
run: |-
docker compose -f .github/services/go-tests/docker-compose.yml up --detach --no-color --wait
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: './go.mod'
- name: Install gotestsum
run: |-
url=https://github.com/gotestyourself/gotestsum/releases/download
curl -sSL "${url}/v${GOTESTSUM_RELEASE}/gotestsum_${GOTESTSUM_RELEASE}_linux_amd64.tar.gz" | \
sudo tar -xz --overwrite -C /usr/local/bin gotestsum
- run: go mod download
- name: Waiting for Postgres to be ready
run: |-
for _ in $(seq 1 10);
do
nc -z localhost 5432 && echo Success && exit 0
echo -n .
sleep 1
done
echo Failed waiting for Postgres && exit 1
- name: go test
env:
POSTGRES_USER: postgres
POSTGRES_DB: waypoint_test
run: |-
read -ra PACKAGE_NAMES <<< "${{ join(matrix.packages, ' ') }}"
mkdir -p "$TEST_RESULTS_DIR"
echo "Testing packages: ${PACKAGE_NAMES[*]}"
gotestsum --format=short-verbose \
--junitfile "$TEST_RESULTS_DIR/gotestsum-report.xml" -- \
-tags="$GOTAGS" -p 2 \
-cover -coverprofile=coverage.txt \
"${PACKAGE_NAMES[@]}"
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: test-results-${{ matrix.id }}
path: "/tmp/test-results"
- name: Stop containers
if: always()
run: |-
docker compose -f .github/services/go-tests/docker-compose.yml down
dev-build:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: './go.mod'
- run: |-
go install github.com/kevinburke/go-bindata/...
make bin
dev-build-windows:
if: github.ref != 'refs/heads/main'
runs-on: windows-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: './go.mod'
- run: |-
go install github.com/kevinburke/go-bindata/...
make bin/windows
permissions:
contents: read