Skip to content

Commit 01ec911

Browse files
Merge pull request #74 from newrelic/acabanas/update_sdk_go_modules
Upgraded github.com/newrelic/infra-integrations-sdk to v3.6.7 Switched to go modules Upgraded pipeline to go 1.16 Replaced gometalinter with golangci-lint Added integration tests
2 parents a22f3e0 + af8e5f3 commit 01ec911

164 files changed

Lines changed: 3463 additions & 32699 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: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ on:
99

1010
env:
1111
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12-
GO_VERSION: '1.9.7'
12+
GO_VERSION: '1.16'
13+
NRJMX_VERSION: '1.5.3'
1314
INTEGRATION: "jmx"
1415
ORIGINAL_REPO_NAME: 'newrelic/nri-jmx'
1516
REPO_FULL_NAME: ${{ github.event.repository.full_name }}
@@ -80,6 +81,28 @@ jobs:
8081
run: |
8182
.\build\windows\unit_tests.ps1
8283
84+
# can't run this step inside of container because of tests specific
85+
test-integration-nix:
86+
name: Run integration tests on *Nix
87+
runs-on: ubuntu-20.04
88+
defaults:
89+
run:
90+
working-directory: src/github.com/${{env.ORIGINAL_REPO_NAME}}
91+
steps:
92+
- name: Check out code
93+
uses: actions/checkout@v2
94+
with:
95+
fetch-depth: 1
96+
path: src/github.com/${{env.ORIGINAL_REPO_NAME}}
97+
- name: Install Go
98+
uses: actions/setup-go@v2
99+
with:
100+
go-version: ${{env.GO_VERSION}}
101+
- name: Integration test
102+
env:
103+
GOPATH: ${{ github.workspace }}
104+
run: make integration-test
105+
83106
prerelease:
84107
name: Build binary for *Nix/Win, create archives for *Nix/Win, create packages for *Nix, upload all artifacts into GH Release assets
85108
runs-on: ubuntu-20.04

.github/workflows/push_pr.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ 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-jmx"
14-
GO_VERSION: '1.9.7'
14+
GO_VERSION: '1.16'
15+
NRJMX_VERSION: '1.5.3'
1516
DOCKER_LOGIN_AVAILABLE: ${{ secrets.OHAI_DOCKER_HUB_ID }}
1617

1718
jobs:
@@ -83,6 +84,34 @@ jobs:
8384
run: |
8485
.\build\windows\unit_tests.ps1
8586
87+
# can't run this step inside of container because of tests specific
88+
test-integration-nix:
89+
name: Run integration tests on *Nix
90+
runs-on: ubuntu-20.04
91+
defaults:
92+
run:
93+
working-directory: src/github.com/${{env.ORIGINAL_REPO_NAME}}
94+
steps:
95+
- name: Check out code
96+
uses: actions/checkout@v2
97+
with:
98+
fetch-depth: 1
99+
path: src/github.com/${{env.ORIGINAL_REPO_NAME}}
100+
- name: Install Go
101+
uses: actions/setup-go@v2
102+
with:
103+
go-version: ${{env.GO_VERSION}}
104+
- name: Login to DockerHub
105+
if: ${{env.DOCKER_LOGIN_AVAILABLE}}
106+
uses: docker/login-action@v1
107+
with:
108+
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
109+
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
110+
- name: Integration test
111+
env:
112+
GOPATH: ${{ github.workspace }}
113+
run: make integration-test
114+
86115
test-build:
87116
name: Test binary compilation for all platforms:arch
88117
runs-on: ubuntu-20.04

.gometalinter.json

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

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ 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.4.6 (2021-04-26)
9+
### Changed
10+
- Upgraded github.com/newrelic/infra-integrations-sdk to v3.6.7
11+
- Switched to go modules
12+
- Upgraded pipeline to go 1.16
13+
- Replaced gometalinter with golangci-lint
14+
15+
## 2.4.5 (2021-01-13)
16+
### Changed
17+
- This fixes scenario where warnings received from nrjmx tool discarded data subsequent data. Now all warnings get logged and all data get processed.
18+
- Bundles previous non jlinked nrjmx tool version, due to issue when querying.
19+
820
## 2.4.4 (2020-01-22)
921
## Changed
1022
- Username and password now default to empty to support no auth

Makefile

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ INTEGRATION := jmx
77
BINARY_NAME = nri-$(INTEGRATION)
88
GO_PKGS := $(shell go list ./... | grep -v "/vendor/")
99
GO_FILES := ./src/
10-
GOTOOLS = github.com/kardianos/govendor \
11-
gopkg.in/alecthomas/gometalinter.v2 \
12-
github.com/axw/gocov/gocov \
13-
github.com/AlekSi/gocov-xml \
10+
GOFLAGS = -mod=readonly
11+
GOLANGCI_LINT = github.com/golangci/golangci-lint/cmd/golangci-lint
12+
GOCOV = github.com/axw/gocov/gocov
13+
GOCOV_XML = github.com/AlekSi/gocov-xml
1414

1515
all: build
1616

@@ -20,41 +20,26 @@ clean:
2020
@echo "=== $(INTEGRATION) === [ clean ]: Removing binaries and coverage file..."
2121
@rm -rfv bin coverage.xml $(TARGET)
2222

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

28-
tools-update: check-version
29-
@echo "=== $(INTEGRATION) === [ tools-update ]: Updating tools required by the project..."
30-
@go get -u $(GOTOOLS)
31-
@gometalinter.v2 --install
32-
33-
deps: tools deps-only
34-
35-
deps-only:
36-
@echo "=== $(INTEGRATION) === [ deps ]: Installing package dependencies required by the project..."
37-
@govendor sync
38-
39-
validate: deps
40-
@echo "=== $(INTEGRATION) === [ validate ]: Validating source code running gometalinter..."
41-
@gometalinter.v2 --config=.gometalinter.json ./...
42-
43-
validate-all: deps
44-
@echo "=== $(INTEGRATION) === [ validate ]: Validating source code running gometalinter..."
45-
@gometalinter.v2 --config=.gometalinter.json --enable=interfacer --enable=gosimple ./...
46-
47-
compile: deps
27+
compile:
4828
@echo "=== $(INTEGRATION) === [ compile ]: Building $(BINARY_NAME)..."
4929
@go build -o bin/$(BINARY_NAME) ./src
5030

51-
compile-only: deps-only
52-
@echo "=== $(INTEGRATION) === [ compile ]: Building $(BINARY_NAME)..."
53-
@go build -o bin/$(BINARY_NAME) ./src
54-
55-
test: deps
31+
test:
5632
@echo "=== $(INTEGRATION) === [ test ]: Running unit tests..."
57-
@gocov test -race $(GO_PKGS) | gocov-xml > coverage.xml
33+
@go run $(GOFLAGS) $(GOCOV) test -race ./... | go run $(GOFLAGS) $(GOCOV_XML) > coverage.xml
34+
35+
integration-test:
36+
@echo "=== $(INTEGRATION) === [ test ]: running integration tests..."
37+
@if [ "$(NRJMX_VERSION)" = "" ]; then \
38+
echo "Error: missing required env-var: NRJMX_VERSION\n" ;\
39+
exit 1 ;\
40+
fi
41+
@docker-compose -f test/integration/docker-compose.yml up -d --build
42+
@go test -v -tags=integration ./test/integration/. -count=1 ; (ret=$$?; docker-compose -f test/integration/docker-compose.yml down && exit $$ret)
5843

5944
# Include thematic Makefiles
6045
include $(CURDIR)/build/ci.mk
@@ -63,13 +48,13 @@ include $(CURDIR)/build/release.mk
6348
check-version:
6449
ifdef GOOS
6550
ifneq "$(GOOS)" "$(NATIVEOS)"
66-
$(error GOOS is not $(NATIVEOS). Cross-compiling is only allowed for 'clean', 'deps-only' and 'compile-only' targets)
51+
$(error GOOS is not $(NATIVEOS). Cross-compiling is only allowed for 'clean' target)
6752
endif
6853
endif
6954
ifdef GOARCH
7055
ifneq "$(GOARCH)" "$(NATIVEARCH)"
71-
$(error GOARCH variable is not $(NATIVEARCH). Cross-compiling is only allowed for 'clean', 'deps-only' and 'compile-only' targets)
56+
$(error GOARCH variable is not $(NATIVEARCH). Cross-compiling is only allowed for 'clean' target)
7257
endif
7358
endif
7459

75-
.PHONY: all build clean tools tools-update deps validate compile test check-version
60+
.PHONY: all build clean validate compile test integration-test check-version

0 commit comments

Comments
 (0)