-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from oxyno-zeta/develop
- Loading branch information
Showing
11 changed files
with
364 additions
and
59 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: ci | ||
on: | ||
push: | ||
branches-ignore: | ||
- "github-pages" | ||
pull_request: {} | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: golangci/golangci-lint-action@v2 | ||
with: | ||
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version | ||
version: v1.43.0 | ||
|
||
# Optional: working directory, useful for monorepos | ||
# working-directory: somedir | ||
|
||
# Optional: golangci-lint command line arguments. | ||
# args: --issues-exit-code=0 | ||
|
||
# Optional: show only new issues if it's a pull request. The default value is `false`. | ||
# only-new-issues: true | ||
|
||
# Optional: if set to true then the action will use pre-installed Go. | ||
# skip-go-installation: true | ||
|
||
# Optional: if set to true then the action don't cache or restore ~/go/pkg. | ||
# skip-pkg-cache: true | ||
|
||
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build. | ||
# skip-build-cache: true | ||
test: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- lint | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: "^1.17.0" | ||
- run: make test/unit | ||
- run: make test/coverage | ||
- run: go get github.com/mattn/goveralls | ||
- env: | ||
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: goveralls -coverprofile=c.out -service=github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/commitizen-tools/commitizen | ||
rev: v2.20.0 | ||
hooks: | ||
- id: commitizen | ||
stages: [commit-msg] | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.0.1 | ||
hooks: | ||
- id: check-json | ||
stages: [commit] | ||
- id: check-merge-conflict | ||
stages: [commit] | ||
- id: trailing-whitespace | ||
stages: [commit] | ||
- id: end-of-file-fixer | ||
stages: [commit] | ||
- id: check-yaml | ||
stages: [commit] | ||
- id: check-added-large-files | ||
stages: [commit] | ||
- id: check-executables-have-shebangs | ||
stages: [commit] | ||
- id: detect-aws-credentials | ||
stages: [commit] | ||
- id: detect-private-key | ||
stages: [commit] | ||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
# Use the sha or branch you want to point at | ||
rev: v2.4.1 | ||
hooks: | ||
- id: prettier | ||
stages: [commit] | ||
- repo: https://github.com/shellcheck-py/shellcheck-py | ||
rev: v0.8.0.1 | ||
hooks: | ||
- id: shellcheck | ||
stages: [commit] | ||
- repo: local | ||
hooks: | ||
- id: backend-lint | ||
stages: [commit] | ||
files: \.go$ | ||
name: Backend Lint | ||
entry: make | ||
args: | ||
- code/lint | ||
require_serial: true | ||
language: system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package extra | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/golang/mock/gomock" | ||
) | ||
|
||
type orMatcher struct { | ||
matchers []gomock.Matcher | ||
} | ||
|
||
func (om *orMatcher) String() string { | ||
if len(om.matchers) == 0 { | ||
return "the \"or\" matcher will return false because list is empty" | ||
} | ||
|
||
// Initialize string | ||
str := "" | ||
|
||
// Loop over matchers | ||
for i, m := range om.matchers { | ||
// Ignore the first item | ||
if i > 0 { | ||
str += " or " | ||
} | ||
|
||
// Concat matcher string | ||
str += fmt.Sprintf("(%s)", m.String()) | ||
} | ||
|
||
return str | ||
} | ||
|
||
func (om *orMatcher) Matches(x interface{}) bool { | ||
// Check empty case | ||
if len(om.matchers) == 0 { | ||
return false | ||
} | ||
|
||
// Loop over matchers | ||
for _, m := range om.matchers { | ||
// Check if matcher is ok | ||
if m.Matches(x) { | ||
// Matches so ... End | ||
return true | ||
} | ||
} | ||
|
||
// No match until now | ||
// Or is false | ||
return false | ||
} | ||
|
||
// OrMatcher will return a new Or matcher. | ||
func OrMatcher(matchers ...gomock.Matcher) gomock.Matcher { | ||
return &orMatcher{matchers: matchers} | ||
} |
Oops, something went wrong.