Skip to content
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

Updating Go version and Github Actions #44

Merged
merged 1 commit into from
Sep 22, 2023
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
33 changes: 33 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Security
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
jobs:
scan:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Setup Go 1.20
uses: actions/setup-go@v4
with:
go-version: 1.20.x
cache: false

- name: Run GoSec
uses: securego/gosec@master
with:
args: -exclude-dir examples ./...

- name: Run GoVulnCheck
uses: golang/govulncheck-action@v1
with:
go-version-input: 1.20.x
go-package: ./...
35 changes: 5 additions & 30 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,26 @@
name: CI
name: Test
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 }}
unit:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Setup Go ${{ matrix.go }}
- name: Setup Go 1.20
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
go-version: 1.20.x
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 ./...

Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Verify
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Setup Go 1.20
uses: actions/setup-go@v4
with:
go-version: 1.20.x
cache: false

- name: Run GolangCI-Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.53
args: --timeout=5m
12 changes: 12 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
linters:
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- contextcheck
- goconst
- gofmt
- misspell
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2023 The Gorilla Authors. All rights reserved.
Copyright (c) 2012-2023 The Gorilla web toolkit authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
Expand Down
40 changes: 29 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,45 @@ GO_VULNCHECK=$(shell which govulncheck 2> /dev/null || echo '')
GO_VULNCHECK_URI=golang.org/x/vuln/cmd/govulncheck@latest

.PHONY: golangci-lint
golangci-lint:
golangci-lint: ## Run golangci-lint. Example: make golangci-lint
$(if $(GO_LINT), ,go install $(GO_LINT_URI))
@echo "##### Running golangci-lint"
@echo "##### Running golangci-lint #####"
golangci-lint run -v

.PHONY: verify
verify: ## Run all verifications [golangci-lint]. Example: make verify
@echo "##### Running verifications #####"
$(MAKE) golangci-lint

.PHONY: gosec
gosec:
gosec: ## Run gosec. Example: make gosec
$(if $(GO_SEC), ,go install $(GO_SEC_URI))
@echo "##### Running gosec"
@echo "##### Running gosec #####"
gosec ./...

.PHONY: govulncheck
govulncheck:
govulncheck: ## Run govulncheck. Example: make govulncheck
$(if $(GO_VULNCHECK), ,go install $(GO_VULNCHECK_URI))
@echo "##### Running govulncheck"
@echo "##### Running govulncheck #####"
govulncheck ./...

.PHONY: verify
verify: golangci-lint gosec govulncheck
.PHONY: security
security: ## Run all security checks [gosec, govulncheck]. Example: make security
@echo "##### Running security checks #####"
$(MAKE) gosec
$(MAKE) govulncheck

.PHONY: test
test:
@echo "##### Running tests"
.PHONY: test-unit
test-unit: ## Run unit tests. Example: make test-unit
@echo "##### Running unit tests #####"
go test -race -cover -coverprofile=coverage.coverprofile -covermode=atomic -v ./...

.PHONY: test
test: ## Run all tests [test-unit]. Example: make test
@echo "##### Running tests #####"
$(MAKE) test-unit

.PHONY: help
help: ## Print this help. Example: make help
@echo "##### Printing help #####"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# gorilla/context

[![License](https://img.shields.io/github/license/gorilla/.github)](https://img.shields.io/github/license/gorilla/.github)
![testing](https://github.com/gorilla/context/actions/workflows/test.yml/badge.svg)
[![codecov](https://codecov.io/github/gorilla/context/branch/main/graph/badge.svg)](https://codecov.io/github/gorilla/context)
[![godoc](https://godoc.org/github.com/gorilla/context?status.svg)](https://godoc.org/github.com/gorilla/context)
[![sourcegraph](https://sourcegraph.com/github.com/gorilla/context/-/badge.svg)](https://sourcegraph.com/github.com/gorilla/context?badge)
[![OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/projects/7656/badge)](https://bestpractices.coreinfrastructure.org/projects/7656)

![Gorilla Logo](https://github.com/gorilla/.github/assets/53367916/d92caabf-98e0-473e-bfbf-ab554ba435e5)

Expand All @@ -17,7 +19,7 @@
gorilla/context is a general purpose registry for global request variables.

* It stores a `map[*http.Request]map[interface{}]interface{}` as a global singleton, and thus tracks variables by their HTTP request.
* Read the full documentation here: https://www.gorillatoolkit.org/pkg/context


### License

Expand Down
4 changes: 0 additions & 4 deletions context.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// Copyright 2012 The Gorilla Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package context

import (
Expand Down
4 changes: 0 additions & 4 deletions context_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// Copyright 2012 The Gorilla Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package context

import (
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/gorilla/context

go 1.19
go 1.20
Loading