This repository was archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
109 lines (107 loc) · 3.67 KB
/
go-tests.yml
File metadata and controls
109 lines (107 loc) · 3.67 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
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
name: hashicorp/waypoint-hzn/go-tests
on:
push:
branches:
- main
jobs:
check-vendor:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: go.mod
- run: go mod tidy
- run: |
if ! git diff --exit-code; then
echo "Git directory has vendor changes"
exit 1
fi
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
cache: true
cache-dependency-path: go.sum
go-version-file: go.mod
- uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
with:
version: v1.50.0
args: --timeout 3m00s
skip-pkg-cache: true
skip-build-cache: true
dev-build:
runs-on: ubuntu-latest
outputs:
go-version: ${{ steps.go-version.outputs.go-version }}
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: go.mod
- id: go-version
run: echo "go-version=$(cat ./.go-version)" >> "$GITHUB_OUTPUT"
- uses: hashicorp/actions-go-build@v0.1.7
with:
go_version: ${{ steps.go-version.outputs.go-version }}
os: linux
arch: amd64
reproducible: nope
# TODO: inquire about versioning
instructions: |-
mkdir -p dist
go build -o dist ./cmd/waypoint-hzn
go-test:
runs-on: ubuntu-latest
env:
TEST_RESULTS_DIR: "/tmp/test-results"
GO_TAGS: server
GOTESTSUM_RELEASE: 1.8.2
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Start Services
run: |-
docker compose -f .github/services/go-tests/docker-compose.yml up --detach --no-color --wait
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
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:
PACKAGE_NAMES: ./...
POSTGRES_USER: postgres
POSTGRES_DB: waypoint_test
run: |-
mkdir -p "$TEST_RESULTS_DIR"
echo "Testing \"$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@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: test-results
path: "/tmp/test-results"
- name: Stop containers
if: always()
run: |-
docker compose -f .github/services/go-tests/docker-compose.yml down
permissions:
contents: read