Skip to content

Commit

Permalink
ci: github action ci and semantic release
Browse files Browse the repository at this point in the history
Signed-off-by: closetool <[email protected]>
  • Loading branch information
kilosonc committed Mar 16, 2021
1 parent e460480 commit a790323
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 9 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Go

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

test:
runs-on: ubuntu-latest

services:
mysql:
image: mysql
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: casbin
ports:
- 3306:3306
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14

- uses: actions/checkout@v2
- name: Run Unit tests
run: go test -v -coverprofile=./profile.cov ./...

#- uses: actions/checkout@v2
#- uses: shogo82148/actions-goveralls@v1
# with:
# path-to-profile: ./profile.cov

semantic-release:
needs: [test]
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2
- name: Run semantic-release
uses: go-semantic-release/action@v1
if: github.repository == 'casbin/gorm-adapter' && github.event_name == 'push'
with:
github-token: ${{ secrets.GH_TOKEN }}
2 changes: 1 addition & 1 deletion adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func NewAdapter(driverName string, dataSourceName string, params ...interface{})
} else {
return nil, errors.New("wrong format")
}
} else {
} else if len(params) != 0{
return nil, errors.New("too many parameters")
}

Expand Down
10 changes: 5 additions & 5 deletions adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func testUpdatePolicy(t *testing.T, a *Adapter) {
}

func TestAdapterWithCustomTable(t *testing.T) {
db, err := gorm.Open(postgres.Open("user=postgres host=127.0.0.1 port=5432 sslmode=disable"), &gorm.Config{})
db, err := gorm.Open(postgres.Open("user=postgres password=postgres host=127.0.0.1 port=5432 sslmode=disable"), &gorm.Config{})
if err != nil {
panic(err)
}
Expand All @@ -260,7 +260,7 @@ func TestAdapterWithCustomTable(t *testing.T) {
}
}

db, err = gorm.Open(postgres.Open("user=postgres host=127.0.0.1 port=5432 sslmode=disable dbname=casbin_custom_table"), &gorm.Config{})
db, err = gorm.Open(postgres.Open("user=postgres password=postgres host=127.0.0.1 port=5432 sslmode=disable dbname=casbin_custom_table"), &gorm.Config{})
if err != nil {
panic(err)
}
Expand All @@ -278,7 +278,7 @@ func TestAdapters(t *testing.T) {
testAutoSave(t, a)
testSaveLoad(t, a)

a = initAdapter(t, "postgres", "user=postgres host=127.0.0.1 port=5432 sslmode=disable")
a = initAdapter(t, "postgres", "user=postgres password=postgres host=127.0.0.1 port=5432 sslmode=disable")
testAutoSave(t, a)
testSaveLoad(t, a)

Expand All @@ -297,7 +297,7 @@ func TestAdapters(t *testing.T) {
a = initAdapterWithGormInstance(t, db)
testFilteredPolicy(t, a)

db, err = gorm.Open(postgres.Open("user=postgres host=127.0.0.1 port=5432 sslmode=disable dbname=casbin"), &gorm.Config{})
db, err = gorm.Open(postgres.Open("user=postgres password=postgres host=127.0.0.1 port=5432 sslmode=disable dbname=casbin"), &gorm.Config{})
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -330,7 +330,7 @@ func TestAdapters(t *testing.T) {
a = initAdapterWithGormInstanceByName(t, db, "casbin_rule")
testFilteredPolicy(t, a)

db, err = gorm.Open(postgres.Open("user=postgres host=127.0.0.1 port=5432 sslmode=disable dbname=casbin"), &gorm.Config{})
db, err = gorm.Open(postgres.Open("user=postgres password=postgres host=127.0.0.1 port=5432 sslmode=disable dbname=casbin"), &gorm.Config{})
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ require (
gorm.io/driver/postgres v1.0.1
gorm.io/driver/sqlite v1.1.4
gorm.io/driver/sqlserver v1.0.4
gorm.io/gorm v1.21.4-0.20210314024258-2055e29eb812
gorm.io/gorm v1.20.7
)
3 changes: 1 addition & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ gorm.io/driver/sqlserver v1.0.4/go.mod h1:ciEo5btfITTBCj9BkoUVDvgQbUdLWQNqdFY5OG
gorm.io/gorm v1.9.19/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
gorm.io/gorm v1.20.0/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
gorm.io/gorm v1.20.1/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
gorm.io/gorm v1.20.7 h1:rMS4CL3pNmYq1V5/X+nHHjh1Dx6dnf27+Cai5zabo+M=
gorm.io/gorm v1.20.7/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
gorm.io/gorm v1.21.4-0.20210314024258-2055e29eb812 h1:fN5b578CC+G7WQWCXJBnaTuT72rZvGAXWd20bMMiFwo=
gorm.io/gorm v1.21.4-0.20210314024258-2055e29eb812/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=

0 comments on commit a790323

Please sign in to comment.