-
Notifications
You must be signed in to change notification settings - Fork 60
130 lines (130 loc) · 4.34 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
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/setup-go@v3
with:
go-version: 1.17
- uses: actions/checkout@v3
with:
# we depend on full git history for linters
fetch-depth: 0
- 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.54
args: --verbose --timeout=10m
test:
strategy:
matrix:
go-version: [1.18.x]
os: [ubuntu-latest]
os-major-version:
- "2-opensearch"
include:
- os-major-version: "2-opensearch"
version: 2
oss-image: "opensearchproject/opensearch"
OS_IMAGE: "opensearchproject/opensearch:2"
OS_DASHBOARD_IMAGE: "opensearchproject/opensearch-dashboards:2"
OPENSEARCH_PREFIX: "plugins.security"
needs: [lint]
name: Test against OS ${{ matrix.os-major-version }} on ${{ matrix.go-version }}/${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
OS_IMAGE: "${{matrix.OS_IMAGE}}"
OS_DASHBOARD_IMAGE: "${{matrix.OS_DASHBOARD_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 }}"
OS_COMMAND: "${{matrix.OS_COMMAND}}"
- name: Check Docker containers
run: docker ps -a
# While docker/OS 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 Opensearch
# ensure that OS has come up and is available
run: |
./script/wait-for-endpoint --timeout=20 http://admin:admin@localhost:9200
- name: Dump docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2
- name: Run the tests
run: |
export OPENSEARCH_URL=http://admin:admin@localhost:9200
export TF_LOG=INFO
TF_ACC=1 go test ./... -v -parallel 20 -cover -short
# 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
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@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/[email protected]
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}