-
Notifications
You must be signed in to change notification settings - Fork 134
175 lines (175 loc) · 6.68 KB
/
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
on: [push, pull_request]
name: Test
jobs:
lint:
# Separate golangci-lint into its own job because it can override go
# env variables and it runs jobs in parallel:
# https://github.com/golangci/golangci-lint-action#how-to-use
name: Runs go linters
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# we depend on full git history for linters
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '1.19'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be
# specified without patch version: we always use the latest patch
# version.
version: v1.51
args: --verbose --timeout=10m
test:
strategy:
matrix:
go-version: [1.18.x]
os: [ubuntu-latest]
es-major-version:
- "6"
- "7-opendistro"
- "7"
- "7-opensearch"
include:
- es-major-version: "6"
version: 6.8.9
# oss-image: "docker.elastic.co/elasticsearch/elasticsearch-oss"
oss-image: "elasticsearch"
XPACK_IMAGE: "docker.elastic.co/elasticsearch/elasticsearch:6.8.9"
ES_OPENDISTRO_IMAGE: "ghcr.io/phillbaker/opendistro-for-elasticsearch:0.10.0"
ES_KIBANA_IMAGE: "docker.elastic.co/kibana/kibana-oss:6.0.0"
- es-major-version: "7-opendistro"
version: 7.10.1
# oss-image: "docker.elastic.co/elasticsearch/elasticsearch-oss"
oss-image: "elasticsearch"
XPACK_IMAGE: "docker.elastic.co/elasticsearch/elasticsearch:7.10.1"
ES_OPENDISTRO_IMAGE: "amazon/opendistro-for-elasticsearch:1.13.3"
ES_KIBANA_IMAGE: "docker.elastic.co/kibana/kibana:7.10.1"
- es-major-version: "7"
version: 7.17.4
# oss-image: "docker.elastic.co/elasticsearch/elasticsearch-oss"
oss-image: "elasticsearch"
XPACK_IMAGE: "docker.elastic.co/elasticsearch/elasticsearch:7.17.4"
# Note: this is still 7.10.x
ES_OPENDISTRO_IMAGE: "amazon/opendistro-for-elasticsearch:1.13.2"
ES_KIBANA_IMAGE: "docker.elastic.co/kibana/kibana:7.17.4"
- es-major-version: "7-opensearch"
version: 1.1.0
oss-image: "opensearchproject/opensearch"
XPACK_IMAGE: "docker.elastic.co/elasticsearch/elasticsearch:7.10.1"
ES_OPENDISTRO_IMAGE: "opensearchproject/opensearch:1.1.0"
ES_KIBANA_IMAGE: "" # opensearchproject/opensearch-dashboards:1.0.0"
OPENSEARCH_PREFIX: "plugins.security"
OSS_ENV_VAR: "plugins.security.disabled=true"
needs: [lint]
name: Test against ES ${{ matrix.es-major-version }} on ${{ matrix.go-version }}/${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
XPACK_IMAGE: "${{matrix.XPACK_IMAGE}}"
ES_OPENDISTRO_IMAGE: "${{matrix.ES_OPENDISTRO_IMAGE}}"
ES_KIBANA_IMAGE: "${{matrix.ES_KIBANA_IMAGE}}"
OPENSEARCH_PREFIX: "${{matrix.OPENSEARCH_PREFIX}}"
OSS_ENV_VAR: "${{matrix.OSS_ENV_VAR}}"
steps:
- name: Prepare tests
run: |
sudo sysctl -w vm.max_map_count=262144
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
with:
# we depend on full git history for linters
fetch-depth: 0
- name: Cache dependencies
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod # Module download cache
~/.cache/go-build # Build cache (Linux)
~/Library/Caches/go-build # Build cache (Mac)
'%LocalAppData%\go-build' # Build cache (Windows)
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: Run Docker containers
run: docker-compose up --detach
env:
OSS_IMAGE: "${{ matrix.oss-image }}:${{ matrix.version }}"
ES_COMMAND: "${{matrix.ES_COMMAND}}"
- name: Check Docker containers
run: docker ps -a
# While docker/ES is booting up, run the linters
- name: Get tools
run: |
./script/install-tools
- name: Install managed version of terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.0.11
terraform_wrapper: false
- name: Run check scripts
run: |
./script/test-mod-tidy
./script/test-terraform-fmt
- name: Wait for Elasticsearch
# ensure that ES has come up and is available
run: |
./script/wait-for-endpoint --timeout=20 http://localhost:9200
- name: Wait for Kibana
# ensure that Kibana API has come up and is available
run: |
if [ -n "$ES_KIBANA_IMAGE" ]; then
./script/wait-for-endpoint --timeout=120 http://localhost:5601/api/saved_objects/_find?type=visualization
fi
- name: Warm up OpenDistro/Opensearch
# - OpenDistro lazily initializes its indexes, see
# https://github.com/opendistro-for-elasticsearch/alerting/issues/60
run: |
if [ -n "$ES_OPENDISTRO_IMAGE" ]; then
./script/wait-for-endpoint --timeout=120 http://admin:admin@localhost:9220
curl -s -v -X POST -H 'Content-type: application/json' -d '{"name":"_warmup","type":"slack","slack":{"url": "http://www.example.com"}}' http://admin:admin@localhost:9220/_opendistro/_alerting/destinations
fi
- name: Dump docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2
- name: Run the tests
run: |
export ELASTICSEARCH_URL=http://localhost:9200
export TF_LOG=INFO
TF_ACC=1 go test ./... -v -parallel 20 -cover -short
TF_ACC=1 go test ./... -v -cover -run XpackLicense
# check goreleaser config for deprecations
curl -sfL https://git.io/goreleaser | sh -s -- check
release:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [test]
runs-on: ubuntu-latest
name: Release
env:
GITHUB_TOKEN_ENCRYPTED:
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v2
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Run GoReleaser
uses: goreleaser/[email protected]
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}