Skip to content

Commit

Permalink
chore: bump go version to 1.17, replace golint with staticcheck (#222)
Browse files Browse the repository at this point in the history
* ci(coverage): include coverage report

* chore: bump minimum go version to 1.17

* ci(staticcheck): fix linting issues

* ci(goimports): reorder imports

* chore(mockery): bump version to support go 1.18

* docs: Update contributing to mention conventional commits

Co-authored-by: Carsten Dietrich <carsten.dietrich@omnevo.net>
  • Loading branch information
bastianccm and carstendietrich committed May 6, 2022
1 parent fa5bd34 commit ae2b39e
Show file tree
Hide file tree
Showing 35 changed files with 271 additions and 112 deletions.
48 changes: 44 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.16', '1.*' ]
go: [ '1.17', '1.*' ]
name: Tests
steps:
- uses: actions/checkout@v2
Expand All @@ -25,6 +25,42 @@ jobs:
run: go get -v -t -d ./...
- name: Test
run: CGO_ENABLED=1 go test -race ./...
coverage:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.*' ]
name: Coverage Report
steps:
- uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Get dependencies
run: go get -v -t -d ./...
- name: Test
run: |
CGO_ENABLED=1 go run gotest.tools/gotestsum@v1.7.0 --junitfile test.xml --format testname -- -coverprofile coverage.txt -race ./...
go run github.com/boumenot/gocover-cobertura@v1.2.0 -ignore-gen-files -by-files < coverage.txt > coverage.xml
- name: Code Coverage Summary Report
uses: irongut/CodeCoverageSummary@v1.2.0
with:
filename: coverage.xml
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: true
hide_complexity: true
indicators: true
output: both
thresholds: '50 75'
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
static-checks:
runs-on: ubuntu-latest
strategy:
Expand All @@ -45,13 +81,17 @@ jobs:
run: |
fmt=$(gofmt -l .)
test -z $fmt || (echo "please run gofmt" ; echo $fmt ; exit 1)
- name: Go Lint
run: go run golang.org/x/lint/golint@6edffad -set_exit_status $(go list ./...)
- name: Go Staticcheck
run: go run honnef.co/go/tools/cmd/staticcheck@latest ./...
- name: Spelling
run: go run github.com/client9/misspell/cmd/misspell@v0.3.4 -error .
- name: Ineffective assignments
run: go run github.com/gordonklaus/ineffassign@4cc7213 .
- name: Goimports
run: |
go run golang.org/x/tools/cmd/goimports@latest -w .
git diff --quiet || (echo 'goimports requires code cleanup:' ; git diff ; exit 1)
- name: Go Generate
run: |
go generate ./...
git diff --quiet || (echo 'generated go files are not up-to-date, check go generate, go.sum and go.mod' ; git diff ; exit 1)
git diff --quiet || (echo 'generated go files are not up-to-date, check go generate, go.sum and go.mod:' ; git diff ; exit 1)
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
.idea
.temp
coverage
coverage.txt
coverage.xml
context_local.yml

docs/docs/3. Core Packages
Expand Down
18 changes: 10 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@ You can contribute by opening an Issue or with Pull request.


# Suggested Pull Request workflow
## Contributing

## committing

Please contribute by opening pull requests in github.
Please contribute by opening pull requests in GitHub.
This allows us to review, and optionally squash changes to an atomic change.

We have also put together a list of [Coding conventions](docs/1.%20Flamingo%20Basics/8.%20Coding%20Conventions.md)

## Commit messages

A commit message should always start with the affected modules, such as:
We adhere to conventional commits please refer to the specs for more details: https://www.conventionalcommits.org/en/v1.0.0/

`framework/dingo: add command line flags`
or
`core/pugtemplate/pugjs: update parser`
If possible include the affected module / part of flamingo:

A commit message is supposed to tell what has changed.
`feat(framework/dingo): add command line flags`

`fix(core/pugtemplate/pugjs): fix parsing of utf8 characters`

`chore: update dpendecy xyz`

A commit message is supposed to tell what has changed.
2 changes: 1 addition & 1 deletion core/locale/application/date_time_service_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package application

import (
"flamingo.me/flamingo/v3/core/locale/domain"
"testing"
"time"

"flamingo.me/flamingo/v3/core/locale/domain"
"flamingo.me/flamingo/v3/framework/flamingo"
"github.com/stretchr/testify/assert"
)
Expand Down
3 changes: 2 additions & 1 deletion core/locale/application/label_service_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package application

import (
"testing"

"flamingo.me/flamingo/v3/core/locale/domain"
"flamingo.me/flamingo/v3/core/locale/infrastructure/fake"
"flamingo.me/flamingo/v3/framework/config"
"flamingo.me/flamingo/v3/framework/flamingo"
"github.com/stretchr/testify/assert"
"testing"
)

func TestLabelService_NewLabel(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion core/locale/application/price_service_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package application

import (
"testing"

"flamingo.me/flamingo/v3/core/locale/domain"
"flamingo.me/flamingo/v3/core/locale/infrastructure/fake"
"flamingo.me/flamingo/v3/framework/config"
"github.com/leekchan/accounting"
"github.com/stretchr/testify/assert"
"testing"
)

func TestPriceService_GetConfigForCurrency(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package controllers

import (
"context"
"testing"

"flamingo.me/flamingo/v3/core/locale/application"
"flamingo.me/flamingo/v3/core/locale/domain"
"flamingo.me/flamingo/v3/core/locale/infrastructure/fake"
"flamingo.me/flamingo/v3/framework/config"
"flamingo.me/flamingo/v3/framework/web"
"github.com/stretchr/testify/assert"
"testing"
)

func TestTranslationController_GetAllTranslations(t *testing.T) {
Expand Down
5 changes: 2 additions & 3 deletions core/oauth/application/authmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type (
// RoundTrip implements RoundTripper interface and adds logging
func (f *loggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
if req == nil {
return nil, errors.New("No request given")
return nil, errors.New("no request given")
}
b, err := httputil.DumpRequest(req, true)
log.Println()
Expand Down Expand Up @@ -432,8 +432,7 @@ func (am *AuthManager) StoreTokenDetails(ctx context.Context, session *web.Sessi
tokenExtras.Add(extra, parsed)
}

var token oauth2.Token
token = *oauth2Token
token := *oauth2Token
session.Store(keyToken, token)
session.Store(keyRawIDToken, rawToken)
session.Store(keyTokenExtras, tokenExtras)
Expand Down
2 changes: 1 addition & 1 deletion core/oauth/interfaces/callback_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (cc *CallbackController) Get(ctx context.Context, request *web.Request) web
}

stats.Record(ctx, loginFailedCount.M(1))
return cc.responder.ServerError(errors.New("Invalid State"))
return cc.responder.ServerError(errors.New("invalid state"))
}

// cleanup previous token information
Expand Down
2 changes: 1 addition & 1 deletion core/security/application/doc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package application

//go:generate go run github.com/vektra/mockery/v2@v2.9.4 --name=SecurityService --case=underscore
//go:generate go run github.com/vektra/mockery/v2@v2.12.2 --name=SecurityService --case=underscore
16 changes: 14 additions & 2 deletions core/security/application/mocks/security_service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/security/application/role/doc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package role

//go:generate go run github.com/vektra/mockery/v2@v2.9.4 --all --case=underscore
//go:generate go run github.com/vektra/mockery/v2@v2.12.2 --all --case=underscore
14 changes: 13 additions & 1 deletion core/security/application/role/mocks/provider.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion core/security/application/role/mocks/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/security/application/voter/doc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package voter

//go:generate go run github.com/vektra/mockery/v2@v2.9.4 --all --case=underscore
//go:generate go run github.com/vektra/mockery/v2@v2.12.2 --all --case=underscore
17 changes: 15 additions & 2 deletions core/security/application/voter/mocks/security_voter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/security/domain/doc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package domain

//go:generate go run github.com/vektra/mockery/v2@v2.9.4 --all --case=underscore
//go:generate go run github.com/vektra/mockery/v2@v2.12.2 --all --case=underscore
18 changes: 16 additions & 2 deletions core/security/domain/mocks/permission_set.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions core/security/domain/mocks/role.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ae2b39e

Please sign in to comment.