Skip to content

Commit

Permalink
Add golint, gocyclo, and gocritic for golang projects (#13)
Browse files Browse the repository at this point in the history
* Add golint, gocyclo, and gocritic for golang projects

* Fix broken tests
  • Loading branch information
RothAndrew authored Feb 2, 2021
1 parent e1244af commit 2c57cee
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spec/gocritic_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env shellspec

Describe "printVersion()"
printVersion() {
gocritic version
}

It "validates tool is installed by checking version"
When call printVersion
The stderr should be present
The status should eq 0
End
End
13 changes: 13 additions & 0 deletions spec/gocyclo_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env shellspec

Describe "printHelp()"
printHelp() {
gocyclo --help
}

It "validates tool is installed by running it"
When call printHelp
The stderr should be present
The status should eq 2
End
End
13 changes: 13 additions & 0 deletions spec/golint_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env shellspec

Describe "printHelp()"
printHelp() {
golint --help
}

It "validates tool is installed by running it"
When call printHelp
The stderr should be present
The status should eq 0
End
End
14 changes: 14 additions & 0 deletions src/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ RUN asdf plugin-add golang https://github.com/kennyp/asdf-golang.git \
&& asdf install golang "${GO_VERSION}" \
&& asdf global golang "${GO_VERSION}" \
&& rm -rf /var/tmp/* /tmp/* /var/tmp/.???* /tmp/.???*
ENV GOPATH="/home/anvil/go"
ENV PATH="${PATH}:${GOPATH}/bin"

# Install golangci-lint. Get versions using asdf list all golangci-lint
ARG GOLANGCI_LINT_VERSION="1.34.1"
Expand All @@ -309,6 +311,18 @@ RUN asdf plugin-add goreleaser https://github.com/kforsthoevel/asdf-goreleaser.g
&& asdf global goreleaser "${GORELEASER_VERSION}" \
&& rm -rf /var/tmp/* /tmp/* /var/tmp/.???* /tmp/.???*

# Install golint. "go get" doesn't really support specifying versions, so we just get the latest
RUN go get -u golang.org/x/lint/golint \
&& rm -rf /var/tmp/* /tmp/* /var/tmp/.???* /tmp/.???*

# Install gocyclo. "go get" doesn't really support specifying versions, so we just get the latest
RUN go get -u github.com/fzipp/gocyclo/cmd/gocyclo \
&& rm -rf /var/tmp/* /tmp/* /var/tmp/.???* /tmp/.???*

# Install gocritic. "go get" doesn't really support specifying versions, so we just get the latest
RUN go get -u github.com/go-critic/go-critic/cmd/gocritic \
&& rm -rf /var/tmp/* /tmp/* /var/tmp/.???* /tmp/.???*

# Support tools installed as anvil when running as root user
USER root
ENV ASDF_DATA_DIR="/home/anvil/.asdf"
Expand Down

0 comments on commit 2c57cee

Please sign in to comment.