feat: add two new workflows (golangci-lint and test) (#7)

This commit is contained in:
Dawid Wysokiński 2022-05-18 06:40:19 +02:00 committed by GitHub
parent 56dd53db4d
commit e8ba0781b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 126 additions and 6 deletions

35
.github/workflows/golangci-lint.yml vendored Normal file
View File

@ -0,0 +1,35 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
pull_request:
branches:
- master
permissions:
contents: read
jobs:
golangci:
name: lint
strategy:
matrix:
platform: [ ubuntu-latest ]
go-version: [ 1.18.x ]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.46

38
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,38 @@
name: test
on:
push:
tags:
- 'v*'
branches:
- master
pull_request:
branches:
- master
jobs:
test:
strategy:
matrix:
go-version: [ 1.18.x ]
platform: [ ubuntu-latest ]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
- name: go mod download
run: go mod download
- name: Vet
run: go vet ./...
- name: Test
run: go mod download && go test -race -coverprofile=coverage.txt -covermode=atomic ./...

44
.golangci.yml Normal file
View File

@ -0,0 +1,44 @@
run:
tests: true
linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dupl
- errcheck
- gocritic
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- prealloc
- staticcheck
- structcheck
- typecheck
- unconvert
- unused
- varcheck
- lll
- nestif
- thelper
- nonamedreturns
linters-settings:
lll:
line-length: 150
issues:
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- dupl
- linters:
- lll
source: "^//go:generate "

View File

@ -2,10 +2,11 @@ package internal_test
import (
"encoding/json"
"github.com/Kichiyaki/gootp/internal"
"testing"
"time"
"github.com/Kichiyaki/gootp/internal"
"github.com/stretchr/testify/assert"
)

View File

@ -2,10 +2,11 @@ package internal
import (
"fmt"
"github.com/pquerna/otp"
"github.com/pquerna/otp/totp"
"strings"
"time"
"github.com/pquerna/otp"
"github.com/pquerna/otp/totp"
)
func GenerateOTP(entry Entry) (string, error) {

View File

@ -2,13 +2,14 @@ package main
import (
"fmt"
"github.com/Kichiyaki/gootp/internal"
"github.com/urfave/cli/v2"
"golang.org/x/term"
"log"
"os"
"path"
"syscall"
"github.com/Kichiyaki/gootp/internal"
"github.com/urfave/cli/v2"
"golang.org/x/term"
)
var Version = "development"