-
Notifications
You must be signed in to change notification settings - Fork 71
119 lines (118 loc) · 4.4 KB
/
lint-and-test.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
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
name: Lint and Test
on: ["push", "workflow_dispatch"]
permissions: {}
jobs:
lint-actions:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Lint workflow
uses: docker://docker.mirror.hashicorp.services/rhysd/actionlint:latest
go-version:
runs-on: ubuntu-latest
needs:
- lint-actions
outputs:
go-version: ${{ steps.go-version.outputs.go-version }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Determine Go version
id: go-version
# We use .go-version as our source of truth for current Go
# version, because "goenv" can react to it automatically.
run: |
echo "Building with Go $(cat .go-version)"
echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT"
lint:
runs-on: ubuntu-latest
needs:
- go-version
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: ${{ needs.go-version.outputs.go-version }}
- name: Go CI lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
with:
args: "--verbose --enable gofmt"
only-new-issues: false
skip-pkg-cache: true
skip-build-cache: true
unit-tests:
runs-on: ubuntu-latest
needs:
- go-version
env:
TEST_RESULTS_DIR: /tmp/unit-test-results
GOTESTSUM_VERSION: 1.9.0
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: ${{ needs.go-version.outputs.go-version }}
- name: Install gotestsum
shell: bash
run: |
url=https://github.com/gotestyourself/gotestsum/releases/download
curl -sSL "${url}/v${{ env.GOTESTSUM_VERSION }}/gotestsum_${{ env.GOTESTSUM_VERSION }}_linux_amd64.tar.gz" | \
tar -xz --overwrite -C /usr/local/bin gotestsum
- name: Test
run: |
mkdir -p "$TEST_RESULTS_DIR/json"
gotestsum \
--format=short-verbose \
--jsonfile "$TEST_RESULTS_DIR/json/go-test-race.log" \
--junitfile "$TEST_RESULTS_DIR/gotestsum-report.xml" \
-- -race ./...
- uses: actions/upload-artifact@84480863f228bb9747b473957fcc9e309aa96097 # v4.4.2
with:
name: unit-test-results
path: ${{ env.TEST_RESULTS_DIR }}
integration-tests:
name: Integration test - Consul ${{ matrix.consul-version }}
runs-on: ubuntu-latest
needs:
- go-version
env:
TEST_RESULTS_DIR: /tmp/integration-test-results
strategy:
fail-fast: false
matrix:
consul-version:
- 1.15.1
- 1.14.5
- 1.13.7
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: ${{ needs.go-version.outputs.go-version }}
- name: Install Consul ${{ matrix.consul-version }}
shell: bash
run: |
CONSUL_VERSION="${{ matrix.consul-version }}"
FILENAME="consul_${CONSUL_VERSION}_linux_amd64.zip"
curl -sSLO "https://releases.hashicorp.com/consul/${CONSUL_VERSION}/${FILENAME}" && \
unzip "${FILENAME}" -d /usr/local/bin && \
rm "${FILENAME}"
consul version
- name: Integration tests
run: |
mkdir -p "$TEST_RESULTS_DIR/${{ matrix.consul-version }}"
./scripts/integration.sh "$TEST_RESULTS_DIR/${{ matrix.consul-version }}" \
| tee "$TEST_RESULTS_DIR/${{ matrix.consul-version }}/integration-${{ matrix.consul-version }}.log"
- uses: actions/upload-artifact@84480863f228bb9747b473957fcc9e309aa96097 # v4.4.2
with:
name: "integration-test-results-${{ matrix.consul-version }}"
path: ${{ env.TEST_RESULTS_DIR }}/${{ matrix.consul-version }}