Skip to content

fix: fix golangci lint and travis #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ issues:
- testpackage
# part of the golangci govet package is picking up things that go vet doesn't. Seems flaky, shutting that specific error off

# Exclude some staticcheck messages
# Exclude some staticcheck messages
- linters:
- staticcheck
text: "SA1019:" # d.GetOkExists is deprecated: usage is discouraged due to undefined behaviors and may be removed in a future version of the SDK
Expand Down
36 changes: 13 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
dist: xenial
sudo: required
services:
- docker
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to allow your tests to run docker not to run the tests in docker so there's no point to enable it

language: go

env:
global:
GOFLAGS=-mod=vendor
GOGC=10
GOOPTS="-p 2"
go:
- 1.14.x
- tip

matrix:
fast_finish: true
allow_failures:
- go: tip
include:
- go: "1.14.x"
name: "Code Lint"
script: make lint
- go: "1.14.x"
name: "Code UnitTest"
script: make test
- go: "1.14.x"
name: "Website"
script:
#- make website-test #commented until Terraform Provider Program Validation
- make website-lint

install:
- make tools
- name: "Code Lint"
before_install: make tools
script: make lint
- name: "Website"
before_install: make tools
script:
#- make website-test #commented until Terraform Provider Program Validation
- make website-lint
script: make test
18 changes: 14 additions & 4 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@ GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
PKG_NAME=mongodbatlas
WEBSITE_REPO=github.com/hashicorp/terraform-website

GOFLAGS=-mod=vendor
GOGC=10
GOOPTS="-p 2"

GOLANGCI_VERSION=v1.29.0

export PATH := ./bin:$(PATH)

default: build

build: fmtcheck
go install


test: fmtcheck
go test $(TEST) -timeout=30s -parallel=4

Expand All @@ -32,9 +39,12 @@ lint:
# https://github.com/golangci/golangci-lint/issues/337 fixing error
golangci-lint run ./$(PKG_NAME) -v --deadline=30m

tools:
tools: ## Install dev tools
@echo "==> Installing dependencies..."
GO111MODULE=on go install github.com/client9/misspell/cmd/misspell
GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_VERSION)

check: test lint

test-compile:
@if [ "$(TEST)" = "./..." ]; then \
Expand Down Expand Up @@ -62,4 +72,4 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)

.PHONY: build test testacc fmt fmtcheck lint tools test-compile website website-lint website-test
.PHONY: build test testacc fmt fmtcheck lint check tools test-compile website website-lint website-test
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# MongoDB Atlas Provider
[![Build Status](https://travis-ci.org/terraform-providers/terraform-provider-mongodbatlas.svg?branch=master)](https://travis-ci.org/terraform-providers/terraform-provider-mongodbatlas)

This is the repository for the Terraform MongoDB Atlas Provider, which allows one to use Terraform with MongoDB's Database as a Service offering, Atlas.
Learn more about Atlas at [https://www.mongodb.com/cloud/atlas](https://www.mongodb.com/cloud/atlas)
Expand Down
2 changes: 1 addition & 1 deletion mongodbatlas/resource_mongodbatlas_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ func flattenBiConnector(biConnector *matlas.BiConnector) map[string]interface{}
}

func getInstanceSizeToInt(instanceSize string) int {
regex := regexp.MustCompile("[0-9]+")
regex := regexp.MustCompile(`\d+`)
num := regex.FindString(instanceSize)

return cast.ToInt(num) // if the string is empty it always return 0
Expand Down
2 changes: 1 addition & 1 deletion mongodbatlas/resource_mongodbatlas_custom_db_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func resourceMongoDBAtlasCustomDBRole() *schema.Resource {
Required: true,
ForceNew: true,
ValidateFunc: validation.All(
validation.StringMatch(regexp.MustCompile(`[\w\d-]+`), "`role_name` can contain only letters, digits, underscores, and dashes"),
validation.StringMatch(regexp.MustCompile(`[\w-]+`), "`role_name` can contain only letters, digits, underscores, and dashes"),
func(v interface{}, k string) (ws []string, es []error) {
value := v.(string)
if strings.HasPrefix(value, "x-gen") {
Expand Down
1 change: 0 additions & 1 deletion tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ package main

import (
_ "github.com/client9/misspell/cmd/misspell"
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
)