Skip to content

Commit

Permalink
refactor: workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Kulkov committed Aug 22, 2023
1 parent c84ff30 commit 4d0efc4
Show file tree
Hide file tree
Showing 248 changed files with 62 additions and 47,691 deletions.
6 changes: 1 addition & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@ updates:
schedule:
interval: daily
labels:
- deps
assignees:
- jfk9w
reviewers:
- jfk9w
- dependabot
22 changes: 16 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
name: CI

on: [ push, pull_request, workflow_dispatch ]
on: [ push, pull_request_target, workflow_dispatch ]

jobs:
test:
name: Build and test
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: stable
- name: Build
run: make build
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
- name: Build
run: make build
- name: Test
run: make test
- name: Update test coverage
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
release:
name: Release
needs: [ test ]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref_type == 'branch' && github.ref_name == 'master'
steps:
- uses: actions/checkout@v3
- name: Coverage
uses: ncruces/go-coverage-report@main
- name: Tag
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
23 changes: 0 additions & 23 deletions .github/workflows/dependabot-auto-approve.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Dependabot
on: pull_request_target

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Approve and auto-merge PR
if: ${{ steps.metadata.outputs.update-type != 'version-update:semver-major' }}
run: |
gh pr review --approve "$PR_URL"
gh pr merge --auto --merge --delete-branch "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
run:
skip-files:
- dto.go
skip-dirs-use-default: true
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MODULE := github.com/jfk9w-go/lkdr-api
MODULE := $(shell head -1 go.mod | cut -d ' ' -f2)

build:
go build -v ./...
Expand Down
11 changes: 1 addition & 10 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"time"

"github.com/AlekSi/pointer"
"github.com/go-playground/validator/v10"
"github.com/jfk9w-go/based"
"github.com/pkg/errors"
)
Expand All @@ -25,12 +24,6 @@ type TokenStorage interface {
UpdateTokens(ctx context.Context, phone string, tokens *Tokens) error
}

var validate = based.Lazy[*validator.Validate]{
Fn: func(ctx context.Context) (*validator.Validate, error) {
return validator.New(), nil
},
}

type ClientBuilder struct {
Phone string `validate:"required"`
Clock based.Clock `validate:"required"`
Expand All @@ -42,9 +35,7 @@ type ClientBuilder struct {
}

func (b ClientBuilder) Build(ctx context.Context) (*Client, error) {
if validate, err := validate.Get(ctx); err != nil {
return nil, err
} else if err := validate.Struct(b); err != nil {
if err := based.Validate.Struct(b); err != nil {
return nil, err
}

Expand Down
16 changes: 8 additions & 8 deletions dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"github.com/pkg/errors"
)

var dateTimeLocation = &based.Lazy[*time.Location]{
Fn: func(ctx context.Context) (*time.Location, error) {
var dateTimeLocation = based.Lazy[*time.Location](
func(ctx context.Context) (*time.Location, error) {
return time.LoadLocation("Europe/Moscow")
},
}
)

type DateTime time.Time

Expand All @@ -25,7 +25,7 @@ func (dt DateTime) Time() time.Time {
}

func (dt DateTime) MarshalJSON() ([]byte, error) {
location, err := dateTimeLocation.Get(context.Background())
location, err := dateTimeLocation(context.Background())
if err != nil {
return nil, errors.Wrap(err, "load location")
}
Expand All @@ -40,7 +40,7 @@ func (dt *DateTime) UnmarshalJSON(data []byte) error {
return err
}

location, err := dateTimeLocation.Get(context.Background())
location, err := dateTimeLocation(context.Background())
if err != nil {
return errors.Wrap(err, "load location")
}
Expand All @@ -63,7 +63,7 @@ func (d Date) Time() time.Time {
}

func (d Date) MarshalJSON() ([]byte, error) {
location, err := dateTimeLocation.Get(context.Background())
location, err := dateTimeLocation(context.Background())
if err != nil {
return nil, errors.Wrap(err, "load location")
}
Expand All @@ -78,7 +78,7 @@ func (d *Date) UnmarshalJSON(data []byte) error {
return err
}

location, err := dateTimeLocation.Get(context.Background())
location, err := dateTimeLocation(context.Background())
if err != nil {
return errors.Wrap(err, "load location")
}
Expand Down Expand Up @@ -129,7 +129,7 @@ func (dt DateTimeMilliOffset) Time() time.Time {
}

func (dt DateTimeMilliOffset) MarshalJSON() ([]byte, error) {
location, err := dateTimeLocation.Get(context.Background())
location, err := dateTimeLocation(context.Background())
if err != nil {
return nil, errors.Wrap(err, "load location")
}
Expand Down
2 changes: 1 addition & 1 deletion example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func main() {
Config: rucaptcha.Config{
Key: config.RucaptchaKey,
},
}.Build(ctx)
}.Build()

if err != nil {
panic(err)
Expand Down
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
module github.com/jfk9w-go/lkdr-api

go 1.20
go 1.21

require (
github.com/AlekSi/pointer v1.2.0
github.com/caarlos0/env v3.5.0+incompatible
github.com/go-playground/validator/v10 v10.15.0
github.com/jfk9w-go/based v0.0.0-20230814155124-5395e1391762
github.com/jfk9w-go/rucaptcha-api v0.0.0-20230727070445-50e652b28bd7
github.com/jfk9w-go/based v0.0.5
github.com/jfk9w-go/rucaptcha-api v0.0.1
github.com/pkg/errors v0.9.1
)

require (
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator v9.31.0+incompatible // indirect
github.com/go-playground/validator/v10 v10.15.1 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
golang.org/x/crypto v0.12.0 // indirect
Expand Down
17 changes: 8 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,21 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator v9.31.0+incompatible h1:UA72EPEogEnq76ehGdEDp4Mit+3FDh548oRqwVgNsHA=
github.com/go-playground/validator v9.31.0+incompatible/go.mod h1:yrEkQXlcI+PugkyDjY2bRrL/UBU4f3rvrgkN3V8JEig=
github.com/go-playground/validator/v10 v10.15.0 h1:nDU5XeOKtB3GEa+uB7GNYwhVKsgjAR7VgKoNB6ryXfw=
github.com/go-playground/validator/v10 v10.15.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-playground/validator/v10 v10.15.1 h1:BSe8uhN+xQ4r5guV/ywQI4gO59C2raYcGffYWZEjZzM=
github.com/go-playground/validator/v10 v10.15.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/jfk9w-go/based v0.0.0-20230814155124-5395e1391762 h1:CfDnSia3l/IXVTH8E2pTNUWrxkkNnN/NU91kyY0BJlQ=
github.com/jfk9w-go/based v0.0.0-20230814155124-5395e1391762/go.mod h1:9h0ctKci25cxXn2WvJdweBYntHxpINOqEzS/1rDZEyY=
github.com/jfk9w-go/rucaptcha-api v0.0.0-20230727070445-50e652b28bd7 h1:Z9HdJhhCMMr81RG8EXBTNZODZRI2qY0Ypqr1LOHTexg=
github.com/jfk9w-go/rucaptcha-api v0.0.0-20230727070445-50e652b28bd7/go.mod h1:kZb/Q1QkmE133B300U8QUvF5sJFx0kIQVbRbiyikAlo=
github.com/jfk9w-go/based v0.0.5 h1:LFeTAPbq/mYPV5blCQkaUrNmgDLo/H2nejQQaRNiTRs=
github.com/jfk9w-go/based v0.0.5/go.mod h1:QaqTqQacIpRAAKlDuoe+lzN2lyBkrtYpIruWMOz8hhA=
github.com/jfk9w-go/rucaptcha-api v0.0.1 h1:135POAkrsi2KUtzwzU6G6M6FyuMcpEU3XmjSga2WMwA=
github.com/jfk9w-go/rucaptcha-api v0.0.1/go.mod h1:MxEDR/IhChBWSSM/AM4UZzUlifs8gWHaO95/x1xioHk=
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand All @@ -37,6 +36,7 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
Expand All @@ -47,7 +47,6 @@ golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
21 changes: 0 additions & 21 deletions vendor/github.com/AlekSi/pointer/LICENSE

This file was deleted.

44 changes: 0 additions & 44 deletions vendor/github.com/AlekSi/pointer/README.md

This file was deleted.

36 changes: 0 additions & 36 deletions vendor/github.com/AlekSi/pointer/generic.go

This file was deleted.

Loading

0 comments on commit 4d0efc4

Please sign in to comment.