-
Notifications
You must be signed in to change notification settings - Fork 24
82 lines (69 loc) · 2.17 KB
/
test-build-workflow.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
name: Build and Test opensearch-cli
on:
push:
branches:
- main
- opensearch-*
pull_request:
branches:
- main
- opensearch-*
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Set up Go ubuntu-latest
uses: actions/setup-go@v2
with:
go-version: 1.18.2
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest
- name: Check out source code
uses: actions/checkout@v3
- name: Format check
run: goimports -w .
- name: Check for modified files
id: git-check
run: |
echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
- name: Display unformated changes and fail if any
if: steps.git-check.outputs.modified == 'true'
run: |
echo "Found some files are dirty. Please add changes to index and ammend commit".
git diff
exit 1
- name: Lint check
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.50.1
- name: Run Unit Tests
env:
GOPROXY: "https://proxy.golang.org"
run: |
go test ./... -coverprofile=coverage.out
go tool cover -func=coverage.out
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
file: coverage.out
flags: opensearch-cli
name: codecov-umbrella
build:
strategy:
matrix:
platform: [ ubuntu-latest, macos-latest, windows-latest ]
go-version: [ 1.18.2 ]
runs-on: ${{ matrix.platform }}
steps:
- name: Set up Go ${{ matrix.platform }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Check out source code
uses: actions/checkout@v3
- name: Build for ${{ matrix.platform }}-${{ matrix.go-version }}
env:
GOPROXY: "https://proxy.golang.org"
run: go build .