mirror of https://github.com/gorilla/mux
Browse Source
Fixes # https://gorilla-web-toolkit.atlassian.net/browse/GPT-95 **Summary of Changes** Added `.github/workflows/test.yml` that runs golangci-lint & go tests on any PR created or each push to main branch. --------- Signed-off-by: Corey Daley <cdaley@redhat.com> Signed-off-by: Apoorva Jagtap <35304110+apoorvajagtap@users.noreply.github.com> Co-authored-by: Corey Daley <cdaley@redhat.com>pull/719/head
Apoorva Jagtap
1 year ago
committed by
GitHub
14 changed files with 280 additions and 145 deletions
@ -1,70 +0,0 @@
|
||||
version: 2.1 |
||||
|
||||
jobs: |
||||
"test": |
||||
parameters: |
||||
version: |
||||
type: string |
||||
default: "latest" |
||||
golint: |
||||
type: boolean |
||||
default: true |
||||
modules: |
||||
type: boolean |
||||
default: true |
||||
goproxy: |
||||
type: string |
||||
default: "" |
||||
docker: |
||||
- image: "circleci/golang:<< parameters.version >>" |
||||
working_directory: /go/src/github.com/gorilla/mux |
||||
environment: |
||||
GO111MODULE: "on" |
||||
GOPROXY: "<< parameters.goproxy >>" |
||||
steps: |
||||
- checkout |
||||
- run: |
||||
name: "Print the Go version" |
||||
command: > |
||||
go version |
||||
- run: |
||||
name: "Fetch dependencies" |
||||
command: > |
||||
if [[ << parameters.modules >> = true ]]; then |
||||
go mod download |
||||
export GO111MODULE=on |
||||
else |
||||
go get -v ./... |
||||
fi |
||||
# Only run gofmt, vet & lint against the latest Go version |
||||
- run: |
||||
name: "Run golint" |
||||
command: > |
||||
if [ << parameters.version >> = "latest" ] && [ << parameters.golint >> = true ]; then |
||||
go get -u golang.org/x/lint/golint |
||||
golint ./... |
||||
fi |
||||
- run: |
||||
name: "Run gofmt" |
||||
command: > |
||||
if [[ << parameters.version >> = "latest" ]]; then |
||||
diff -u <(echo -n) <(gofmt -d -e .) |
||||
fi |
||||
- run: |
||||
name: "Run go vet" |
||||
command: > |
||||
if [[ << parameters.version >> = "latest" ]]; then |
||||
go vet -v ./... |
||||
fi |
||||
- run: |
||||
name: "Run go test (+ race detector)" |
||||
command: > |
||||
go test -v -race ./... |
||||
|
||||
workflows: |
||||
tests: |
||||
jobs: |
||||
- test: |
||||
matrix: |
||||
parameters: |
||||
version: ["latest", "1.15", "1.14", "1.13", "1.12", "1.11"] |
@ -0,0 +1,20 @@
|
||||
; https://editorconfig.org/ |
||||
|
||||
root = true |
||||
|
||||
[*] |
||||
insert_final_newline = true |
||||
charset = utf-8 |
||||
trim_trailing_whitespace = true |
||||
indent_style = space |
||||
indent_size = 2 |
||||
|
||||
[{Makefile,go.mod,go.sum,*.go,.gitmodules}] |
||||
indent_style = tab |
||||
indent_size = 4 |
||||
|
||||
[*.md] |
||||
indent_size = 4 |
||||
trim_trailing_whitespace = false |
||||
|
||||
eclint_indent_style = unset |
@ -0,0 +1,20 @@
|
||||
# Add issues or pull-requests created to the project. |
||||
name: Add issue or pull request to Project |
||||
|
||||
on: |
||||
issues: |
||||
types: |
||||
- opened |
||||
pull_request: |
||||
types: |
||||
- opened |
||||
|
||||
jobs: |
||||
add-to-project: |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: Add issue to project |
||||
uses: actions/add-to-project@v0.5.0 |
||||
with: |
||||
project-url: https://github.com/orgs/gorilla/projects/4 |
||||
github-token: ${{ secrets.ADD_TO_PROJECT_TOKEN }} |
@ -0,0 +1,55 @@
|
||||
name: CI |
||||
on: |
||||
push: |
||||
branches: |
||||
- main |
||||
pull_request: |
||||
branches: |
||||
- main |
||||
|
||||
permissions: |
||||
contents: read |
||||
|
||||
jobs: |
||||
verify-and-test: |
||||
strategy: |
||||
matrix: |
||||
go: ['1.19','1.20'] |
||||
os: [ubuntu-latest, macos-latest, windows-latest] |
||||
fail-fast: true |
||||
runs-on: ${{ matrix.os }} |
||||
steps: |
||||
- name: Checkout Code |
||||
uses: actions/checkout@v3 |
||||
|
||||
- name: Setup Go ${{ matrix.go }} |
||||
uses: actions/setup-go@v4 |
||||
with: |
||||
go-version: ${{ matrix.go }} |
||||
cache: false |
||||
|
||||
- name: Run GolangCI-Lint |
||||
uses: golangci/golangci-lint-action@v3 |
||||
with: |
||||
version: v1.53 |
||||
args: --timeout=5m |
||||
|
||||
- name: Run GoSec |
||||
if: matrix.os == 'ubuntu-latest' |
||||
uses: securego/gosec@master |
||||
with: |
||||
args: ./... |
||||
|
||||
- name: Run GoVulnCheck |
||||
uses: golang/govulncheck-action@v1 |
||||
with: |
||||
go-version-input: ${{ matrix.go }} |
||||
go-package: ./... |
||||
|
||||
- name: Run Tests |
||||
run: go test -race -cover -coverprofile=coverage -covermode=atomic -v ./... |
||||
|
||||
- name: Upload coverage to Codecov |
||||
uses: codecov/codecov-action@v3 |
||||
with: |
||||
files: ./coverage |
@ -0,0 +1,34 @@
|
||||
GO_LINT=$(shell which golangci-lint 2> /dev/null || echo '')
|
||||
GO_LINT_URI=github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||
|
||||
GO_SEC=$(shell which gosec 2> /dev/null || echo '')
|
||||
GO_SEC_URI=github.com/securego/gosec/v2/cmd/gosec@latest
|
||||
|
||||
GO_VULNCHECK=$(shell which govulncheck 2> /dev/null || echo '')
|
||||
GO_VULNCHECK_URI=golang.org/x/vuln/cmd/govulncheck@latest
|
||||
|
||||
.PHONY: golangci-lint |
||||
golangci-lint: |
||||
$(if $(GO_LINT), ,go install $(GO_LINT_URI))
|
||||
@echo "##### Running golangci-lint"
|
||||
golangci-lint run -v
|
||||
|
||||
.PHONY: gosec |
||||
gosec: |
||||
$(if $(GO_SEC), ,go install $(GO_SEC_URI))
|
||||
@echo "##### Running gosec"
|
||||
gosec ./...
|
||||
|
||||
.PHONY: govulncheck |
||||
govulncheck: |
||||
$(if $(GO_VULNCHECK), ,go install $(GO_VULNCHECK_URI))
|
||||
@echo "##### Running govulncheck"
|
||||
govulncheck ./...
|
||||
|
||||
.PHONY: verify |
||||
verify: golangci-lint gosec govulncheck |
||||
|
||||
.PHONY: test |
||||
test: |
||||
@echo "##### Running tests"
|
||||
go test -race -cover -coverprofile=coverage.coverprofile -covermode=atomic -v ./...
|
Loading…
Reference in new issue