Skip to content

Commit

Permalink
switch v2 directory to have v2 naming, add GitHub CI setup
Browse files Browse the repository at this point in the history
  • Loading branch information
paskal committed Apr 4, 2024
1 parent 206a7a3 commit 4e32f30
Show file tree
Hide file tree
Showing 35 changed files with 203 additions and 65 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/ci-v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: build-v2

on:
push:
branches:
tags:
paths:
- ".github/workflows/ci-v2.yml"
- "v2/**"
pull_request:
paths:
- ".github/workflows/ci-v2.yml"
- "v2/**"

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: disable and stop mono-xsp4.service (wtf?)
run: |
sudo systemctl stop mono-xsp4.service || true
sudo systemctl disable mono-xsp4.service || true
- name: set up go
uses: actions/setup-go@v5
with:
go-version: "1.21"
id: go

- name: launch mongodb
uses: wbari/start-mongoDB@v0.2
with:
mongoDBVersion: "6.0"

- name: checkout
uses: actions/checkout@v4

- name: build and test
run: |
go test -timeout=60s -v -race -p 1 -covermode=atomic -coverprofile=$GITHUB_WORKSPACE/profile.cov ./...
go build -race
working-directory: v2
env:
TZ: "America/Chicago"
ENABLE_MONGO_TESTS: "true"

- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
args: --config ../.golangci.yml
working-directory: v2

- name: submit coverage
run: |
go install github.com/mattn/goveralls@latest
goveralls -service="github" -coverprofile=$GITHUB_WORKSPACE/profile.cov
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ on:
push:
branches:
tags:
paths-ignore:
- ".github/workflows/ci-v2.yml"
- "v2/**"
pull_request:
paths-ignore:
- ".github/workflows/ci-v2.yml"
- "v2/**"

jobs:
build:
Expand All @@ -16,7 +22,7 @@ jobs:
sudo systemctl stop mono-xsp4.service || true
sudo systemctl disable mono-xsp4.service || true
- name: set up go 1.21
- name: set up go
uses: actions/setup-go@v5
with:
go-version: "1.21"
Expand Down
10 changes: 5 additions & 5 deletions v2/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (

"github.com/go-pkgz/rest"

"github.com/go-pkgz/auth/avatar"
"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/middleware"
"github.com/go-pkgz/auth/provider"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/avatar"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/middleware"
"github.com/go-pkgz/auth/v2/provider"
"github.com/go-pkgz/auth/v2/token"
)

// Client is a type of auth client
Expand Down
8 changes: 4 additions & 4 deletions v2/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/go-pkgz/auth/avatar"
"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/provider"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/avatar"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/provider"
"github.com/go-pkgz/auth/v2/token"
)

func TestNewService(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions v2/avatar/avatar.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"github.com/rrivera/identicon"
"golang.org/x/image/draw"

"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/token"
)

// Proxy provides http handler for avatars from avatar.Store
Expand Down
4 changes: 2 additions & 2 deletions v2/avatar/avatar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/token"
)

func TestAvatar_Put(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion v2/avatar/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"

"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/token"
)

// imgSfx for avatars
Expand Down
2 changes: 1 addition & 1 deletion v2/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/go-pkgz/auth
module github.com/go-pkgz/auth/v2

go 1.21

Expand Down
72 changes: 72 additions & 0 deletions v2/go.sum

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions v2/middleware/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"net/http"
"strings"

"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/provider"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/provider"
"github.com/go-pkgz/auth/v2/token"
)

// Authenticator is top level auth object providing middlewares
Expand Down
6 changes: 3 additions & 3 deletions v2/middleware/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/provider"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/provider"
"github.com/go-pkgz/auth/v2/token"
)

var testJwtValid = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ0ZXN0X3N5cyIsImV4cCI6Mjc4OTE5MTgyMiwianRpIjoicmFuZG9tIGlkIiwiaXNzIjoicmVtYXJrNDIiLCJuYmYiOjE1MjY4ODQyMjIsInVzZXIiOnsibmFtZSI6Im5hbWUxIiwiaWQiOiJwcm92aWRlcjFfaWQxIiwicGljdHVyZSI6Imh0dHA6Ly9leGFtcGxlLmNvbS9waWMucG5nIiwiaXAiOiIxMjcuMC4wLjEiLCJlbWFpbCI6Im1lQGV4YW1wbGUuY29tIiwiYXR0cnMiOnsiYm9vbGEiOnRydWUsInN0cmEiOiJzdHJhLXZhbCJ9fX0.orBYt_pVA4uvCCw0JMQLla3DA0mpjRTl_U9vT_wtI30"
Expand Down
2 changes: 1 addition & 1 deletion v2/middleware/user_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package middleware
import (
"net/http"

"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/token"
)

// UserUpdater defines interface adding extras or modifying UserInfo in request context
Expand Down
2 changes: 1 addition & 1 deletion v2/middleware/user_updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/token"
)

func TestUserUpdate(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions v2/provider/apple.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"github.com/go-pkgz/rest"
"github.com/golang-jwt/jwt"

"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/token"
)

const (
Expand All @@ -41,7 +41,7 @@ const (
appleRequestContentType = "application/x-www-form-urlencoded"

// UserAgent required to every request to Apple REST API
defaultUserAgent = "github.com/go-pkgz/auth"
defaultUserAgent = "github.com/go-pkgz/auth/v2"

// AcceptJSONHeader is the content to accept from response
AcceptJSONHeader = "application/json"
Expand Down
4 changes: 2 additions & 2 deletions v2/provider/apple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/oauth2"

"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/token"
)

type customLoader struct{} // implement custom private key loader interface
Expand Down
6 changes: 3 additions & 3 deletions v2/provider/custom_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (
goauth2 "github.com/go-oauth2/oauth2/v4/server"
"golang.org/x/oauth2"

"github.com/go-pkgz/auth/avatar"
"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/avatar"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/token"
)

// CustomHandlerOpt are options to initialize a handler for oauth2 server
Expand Down
4 changes: 2 additions & 2 deletions v2/provider/custom_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/token"
)

func TestCustomProvider(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions v2/provider/dev_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (

"golang.org/x/oauth2"

"github.com/go-pkgz/auth/avatar"
"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/avatar"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/token"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions v2/provider/dev_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/token"
)

func TestDevProvider(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions v2/provider/direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/go-pkgz/rest"
"github.com/golang-jwt/jwt"

"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/token"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions v2/provider/direct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/token"
)

func TestDirect_LoginHandler(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions v2/provider/oauth1.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/go-pkgz/rest"
"github.com/golang-jwt/jwt"

"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/token"
)

// Oauth1Handler implements /login, /callback and /logout handlers for oauth1 flow
Expand Down
4 changes: 2 additions & 2 deletions v2/provider/oauth1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/token"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions v2/provider/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/golang-jwt/jwt"
"golang.org/x/oauth2"

"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/token"
)

// Oauth2Handler implements /login, /callback and /logout handlers from aouth2 flow
Expand Down
4 changes: 2 additions & 2 deletions v2/provider/oauth2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/oauth2"

"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/auth/v2/token"
)

var testJwtValid = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ0ZXN0X3N5cyIsImV4cCI6Mjc4OTE5MTgyMiwianRpIjoicmFuZG9tIGlkIiwiaXNzIjoicmVtYXJrNDIiLCJuYmYiOjE1MjY4ODQyMjIsInVzZXIiOnsibmFtZSI6Im5hbWUxIiwiaWQiOiJpZDEiLCJwaWN0dXJlIjoiaHR0cDovL2V4YW1wbGUuY29tL3BpYy5wbmciLCJpcCI6IjEyNy4wLjAuMSIsImVtYWlsIjoibWVAZXhhbXBsZS5jb20iLCJhdHRycyI6eyJib29sYSI6dHJ1ZSwic3RyYSI6InN0cmEtdmFsIn19fQ.NN7TK-IbzpNgHMtld9-7BDypMGDZdMpwCmUMSfd31Zk"
Expand Down
2 changes: 1 addition & 1 deletion v2/provider/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/dghubble/oauth1"
"github.com/dghubble/oauth1/twitter"
"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/token"
"golang.org/x/oauth2"
"golang.org/x/oauth2/facebook"
"golang.org/x/oauth2/github"
Expand Down
2 changes: 1 addition & 1 deletion v2/provider/providers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/token"
)

func TestProviders_NewGoogle(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion v2/provider/sender/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package sender
import (
"time"

"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/v2/logger"
"github.com/go-pkgz/email"
)

Expand Down
2 changes: 1 addition & 1 deletion v2/provider/sender/email_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

"github.com/go-pkgz/auth/logger"
"github.com/go-pkgz/auth/v2/logger"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
2 changes: 1 addition & 1 deletion v2/provider/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http"
"strings"

"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/token"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion v2/provider/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/go-pkgz/auth/token"
"github.com/go-pkgz/auth/v2/token"
)

func TestHandler(t *testing.T) {
Expand Down
Loading

0 comments on commit 4e32f30

Please sign in to comment.