Skip to content

Commit 03dd166

Browse files
go modules , sdk 3.6.7 , go 1.16 , golanci-lint (#63)
1 parent 345732e commit 03dd166

184 files changed

Lines changed: 9419 additions & 101906 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/prerelease.yml

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,22 @@ on:
99

1010
env:
1111
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12-
GO_VERSION: '1.9.7'
12+
GO_VERSION: '1.16'
1313
INTEGRATION: "mssql"
1414
ORIGINAL_REPO_NAME: ${{ github.event.repository.full_name }}
1515
REPO_FULL_NAME: ${{ github.event.repository.full_name }}
1616
TAG: ${{ github.event.release.tag_name }}
1717

1818
jobs:
19-
validate:
20-
name: Validate code via linters
19+
golangci-lint:
20+
name: Validate code via golangci
2121
runs-on: ubuntu-20.04
2222
steps:
2323
- uses: actions/checkout@v2
24-
- name: Login to DockerHub
25-
uses: docker/login-action@v1
24+
- name: golangci-lint
25+
uses: golangci/golangci-lint-action@v2
2626
with:
27-
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
28-
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
29-
- name: Validate code
30-
run: make ci/validate
27+
only-new-issues: true
3128

3229
snyk:
3330
name: Run security checks via snyk
@@ -78,11 +75,31 @@ jobs:
7875
shell: pwsh
7976
run: |
8077
.\build\windows\unit_tests.ps1
78+
test-integration-nix:
79+
name: Run integration tests on *Nix
80+
runs-on: ubuntu-20.04
81+
defaults:
82+
run:
83+
working-directory: src/github.com/${{env.ORIGINAL_REPO_NAME}}
84+
steps:
85+
- name: Check out code
86+
uses: actions/checkout@v2
87+
with:
88+
fetch-depth: 1
89+
path: src/github.com/${{env.ORIGINAL_REPO_NAME}}
90+
- name: Install Go
91+
uses: actions/setup-go@v2
92+
with:
93+
go-version: ${{env.GO_VERSION}}
94+
- name: Integration test
95+
env:
96+
GOPATH: ${{ github.workspace }}
97+
run: make integration-test
8198

8299
prerelease:
83100
name: Build binary for *Nix/Win, create archives for *Nix/Win, create packages for *Nix, upload all artifacts into GH Release assets
84101
runs-on: ubuntu-20.04
85-
needs: [validate, test-nix, test-windows, snyk]
102+
needs: [golangci-lint, test-nix, test-windows, snyk]
86103
steps:
87104
- uses: actions/checkout@v2
88105
- name: Login to DockerHub

.github/workflows/push_pr.yml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,19 @@ env:
1111
TAG: "v0.0.0" # needed for goreleaser windows builds
1212
REPO_FULL_NAME: ${{ github.event.repository.full_name }}
1313
ORIGINAL_REPO_NAME: "newrelic/nri-mssql"
14-
GO_VERSION: '1.9.7'
14+
GO_VERSION: '1.16'
1515
DOCKER_LOGIN_AVAILABLE: ${{ secrets.OHAI_DOCKER_HUB_ID }}
1616

1717
jobs:
18-
validate:
19-
name: Validate code via linters
18+
golangci-lint:
19+
name: Validate code via golangci
2020
runs-on: ubuntu-20.04
2121
steps:
2222
- uses: actions/checkout@v2
23-
- name: Login to DockerHub
24-
if: ${{env.DOCKER_LOGIN_AVAILABLE}}
25-
uses: docker/login-action@v1
23+
- name: golangci-lint
24+
uses: golangci/golangci-lint-action@v2
2625
with:
27-
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
28-
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
29-
- name: Validate code
30-
run: make ci/validate
31-
26+
only-new-issues: true
3227
snyk:
3328
name: Run security checks via snyk
3429
runs-on: ubuntu-20.04
@@ -81,6 +76,26 @@ jobs:
8176
shell: pwsh
8277
run: |
8378
.\build\windows\unit_tests.ps1
79+
test-integration-nix:
80+
name: Run integration tests on *Nix
81+
runs-on: ubuntu-20.04
82+
defaults:
83+
run:
84+
working-directory: src/github.com/${{env.ORIGINAL_REPO_NAME}}
85+
steps:
86+
- name: Check out code
87+
uses: actions/checkout@v2
88+
with:
89+
fetch-depth: 1
90+
path: src/github.com/${{env.ORIGINAL_REPO_NAME}}
91+
- name: Install Go
92+
uses: actions/setup-go@v2
93+
with:
94+
go-version: ${{env.GO_VERSION}}
95+
- name: Integration test
96+
env:
97+
GOPATH: ${{ github.workspace }}
98+
run: make integration-test
8499

85100
test-build:
86101
name: Test binary compilation for all platforms:arch

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ dist/
5757
# build files
5858
src/versioninfo.json
5959
src/resource.syso
60+
61+
vendor/

.gometalinter.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

.papers_config.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ reject:
4545
- EPL-1.0
4646

4747
exceptions:
48-
- github.com/newrelic/nri-mssql/vendor/github.com/newrelic/infra-integrations-sdk/args
49-
- github.com/newrelic/nri-mssql/vendor/github.com/newrelic/infra-integrations-sdk/data/event
50-
- github.com/newrelic/nri-mssql/vendor/github.com/newrelic/infra-integrations-sdk/data/inventory
51-
- github.com/newrelic/nri-mssql/vendor/github.com/newrelic/infra-integrations-sdk/data/metric
52-
- github.com/newrelic/nri-mssql/vendor/github.com/newrelic/infra-integrations-sdk/integration
53-
- github.com/newrelic/nri-mssql/vendor/github.com/newrelic/infra-integrations-sdk/log
54-
- github.com/newrelic/nri-mssql/vendor/github.com/newrelic/infra-integrations-sdk/persist
48+
- github.com/newrelic/infra-integrations-sdk/args
49+
- github.com/newrelic/infra-integrations-sdk/data/event
50+
- github.com/newrelic/infra-integrations-sdk/data/inventory
51+
- github.com/newrelic/infra-integrations-sdk/data/metric
52+
- github.com/newrelic/infra-integrations-sdk/integration
53+
- github.com/newrelic/infra-integrations-sdk/log
54+
- github.com/newrelic/infra-integrations-sdk/persist
5555

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## 2.6.0 (2021-06-05)
9+
## Changed
10+
- Update Go to v1.16.
11+
- Migrate to Go Modules
12+
- Update Infrastracture SDK to v3.6.7.
13+
- Update other dependecies.
814
## 2.5.4 (2021-04-06)
915
### Added
1016
- `ExtraConnectionURLArgs` argument allowing to specify custom connection strings

Makefile

Lines changed: 22 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,40 @@
1-
WORKDIR := $(shell pwd)
2-
NATIVEOS := $(shell go version | awk -F '[ /]' '{print $$4}')
3-
NATIVEARCH := $(shell go version | awk -F '[ /]' '{print $$5}')
4-
INTEGRATION := mssql
5-
BINARY_NAME = nri-$(INTEGRATION)
6-
GO_FILES := ./src/
7-
GOTOOLS = github.com/kardianos/govendor \
8-
gopkg.in/alecthomas/gometalinter.v2 \
9-
github.com/axw/gocov/gocov \
10-
github.com/AlekSi/gocov-xml \
1+
WORKDIR := $(shell pwd)
2+
INTEGRATION := mssql
3+
BINARY_NAME = nri-$(INTEGRATION)
4+
GO_FILES := ./src/
5+
GOFLAGS = -mod=readonly
6+
GOLANGCI_LINT = github.com/golangci/golangci-lint/cmd/golangci-lint
7+
GOCOV = github.com/axw/gocov/gocov
8+
GOCOV_XML = github.com/AlekSi/gocov-xml
119

1210
all: build
1311

14-
build: check-version clean validate test compile
12+
build: clean validate test compile
1513

1614
clean:
1715
@echo "=== $(INTEGRATION) === [ clean ]: Removing binaries and coverage file..."
1816
@rm -rfv bin coverage.xml
1917

20-
tools: check-version
21-
@echo "=== $(INTEGRATION) === [ tools ]: Installing tools required by the project..."
22-
@go get $(GOTOOLS)
23-
@gometalinter.v2 --install
18+
validate:
19+
@echo "=== $(INTEGRATION) === [ validate ]: Validating source code running golangci-lint..."
20+
@go run $(GOFLAGS) $(GOLANGCI_LINT) run --verbose
2421

25-
tools-update: check-version
26-
@echo "=== $(INTEGRATION) === [ tools-update ]: Updating tools required by the project..."
27-
@go get -u $(GOTOOLS)
28-
@gometalinter.v2 --install
29-
30-
deps: tools deps-only
31-
32-
deps-only:
33-
@echo "=== $(INTEGRATION) === [ deps ]: Installing package dependencies required by the project..."
34-
@govendor sync
35-
36-
validate: deps
37-
@echo "=== $(INTEGRATION) === [ validate ]: Validating source code running gometalinter..."
38-
@gometalinter.v2 --config=.gometalinter.json $(GO_FILES)...
39-
40-
validate-all: deps
41-
@echo "=== $(INTEGRATION) === [ validate ]: Validating source code running gometalinter..."
42-
@gometalinter.v2 --config=.gometalinter.json --enable=interfacer --enable=gosimple $(GO_FILES)...
22+
test:
23+
@echo "=== $(INTEGRATION) === [ test ]: Running unit tests..."
24+
@go run $(GOFLAGS) $(GOCOV) test ./... | go run $(GOFLAGS) $(GOCOV_XML) > coverage.xml
4325

44-
compile: deps
45-
@echo "=== $(INTEGRATION) === [ compile ]: Building $(BINARY_NAME)..."
46-
@go build -o bin/$(BINARY_NAME) $(GO_FILES)
26+
integration-test:
27+
@echo "=== $(INTEGRATION) === [ test ]: running integration tests..."
28+
@docker-compose -f tests/docker-compose.yml pull
29+
@go test -v -tags=integration ./tests/. || (ret=$$?; docker-compose -f tests/docker-compose.yml down && exit $$ret)
30+
@docker-compose -f tests/docker-compose.yml down
4731

48-
compile-only: deps-only
32+
compile:
4933
@echo "=== $(INTEGRATION) === [ compile ]: Building $(BINARY_NAME)..."
5034
@go build -o bin/$(BINARY_NAME) $(GO_FILES)
5135

52-
test: deps
53-
@echo "=== $(INTEGRATION) === [ test ]: Running unit tests..."
54-
@gocov test -race $(GO_FILES)... | gocov-xml > coverage.xml
55-
5636
# Include thematic Makefiles
5737
include $(CURDIR)/build/ci.mk
5838
include $(CURDIR)/build/release.mk
5939

60-
check-version:
61-
ifdef GOOS
62-
ifneq "$(GOOS)" "$(NATIVEOS)"
63-
$(error GOOS is not $(NATIVEOS). Cross-compiling is only allowed for 'clean', 'deps-only' and 'compile-only' targets)
64-
endif
65-
endif
66-
ifdef GOARCH
67-
ifneq "$(GOARCH)" "$(NATIVEARCH)"
68-
$(error GOARCH variable is not $(NATIVEARCH). Cross-compiling is only allowed for 'clean', 'deps-only' and 'compile-only' targets)
69-
endif
70-
endif
71-
72-
.PHONY: all build clean tools tools-update deps validate compile test check-version
40+
.PHONY: all build clean validate compile test

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![New Relic Community Plus header](https://raw.githubusercontent.com/newrelic/open-source-office/master/examples/categories/images/Community_Plus.png)](https://opensource.newrelic.com/oss-category/#community-plus)
1+
[![Community Plus header](https://github.com/newrelic/opensource-website/raw/master/src/images/categories/Community_Plus.png)](https://opensource.newrelic.com/oss-category/#community-plus)
22

33
# New Relic integration for Microsoft SQL Server
44

@@ -101,8 +101,6 @@ If you want to know more about usage of `./bin/nri-mssql`, pass the `-help` para
101101
$ ./bin/nri-mssql -help
102102
```
103103

104-
External dependencies are managed through the [govendor tool](https://github.com/kardianos/govendor). Locking all external dependencies to a specific version (if possible) into the vendor directory is required.
105-
106104
## Testing
107105

108106
To run the tests execute:

0 commit comments

Comments
 (0)