diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8724d4f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,72 @@ +name: Go + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + permissions: + contents: read + strategy: + fail-fast: false + matrix: + go-version: [ '1.23' ] + + services: + etcd: + image: quay.io/coreos/etcd + ports: + - 2379:2379 + - 2380:2380 + env: + ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379 + ETCD_ADVERTISE_CLIENT_URLS: http://0.0.0.0:2379 + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + + - name: Test + run: go test -covermode atomic -coverprofile=covprofile ./... + + - name: Install goveralls + env: + GO111MODULE: off + run: go get github.com/mattn/goveralls + + - name: Send coverage + env: + COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: goveralls -coverprofile=covprofile -service=github + + semantic-release: + needs: [test] + if: github.repository == 'casbin/etcd-watcher' && github.event_name == 'push' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.x' + + - name: Install semantic-release + run: npm install --save-dev semantic-release@21.0.0 @semantic-release/commit-analyzer @semantic-release/release-notes-generator @semantic-release/github + + - name: Run semantic-release + run: npx semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index c43b413..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: Go -on: - push: - branches: - - master - pull_request: - -jobs: - - test: - - strategy: - matrix: - go: ["1.23"] - - runs-on: ubuntu-latest - services: - casbin: - image: quay.io/coreos/etcd - ports: - - 2379:2379 - - 2380:2380 - env: - ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379 - ETCD_ADVERTISE_CLIENT_URLS: http://0.0.0.0:2379 - steps: - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go }} - - - uses: actions/checkout@v2 - - name: Run Unit tests - run: go test -v -coverprofile=profile.cov ./... - - - name: Install goveralls - env: - GO111MODULE: off - run: go get github.com/mattn/goveralls - - - name: Send coverage - env: - COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: goveralls -coverprofile=profile.cov -service=github - - semantic-release: - needs: [test] - runs-on: ubuntu-latest - steps: - - - uses: actions/checkout@v2 - - - name: Run semantic-release - if: github.repository == 'casbin/etcd-watcher' && github.event_name == 'push' - run: | - npm install --save-dev semantic-release@17.2.4 - npx semantic-release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/README.md b/README.md index 38d8fb2..0813505 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,14 @@ -Etcd Watcher [![Go](https://github.com/casbin/etcd-watcher/actions/workflows/test.yml/badge.svg)](https://github.com/casbin/etcd-watcher/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/casbin/etcd-watcher/badge.svg?branch=master)](https://coveralls.io/github/casbin/etcd-watcher?branch=master) [![Godoc](https://godoc.org/github.com/casbin/etcd-watcher?status.svg)](https://godoc.org/github.com/casbin/etcd-watcher) +Etcd Watcher ==== +[![Go Report Card](https://goreportcard.com/badge/github.com/casbin/etcd-watcher)](https://goreportcard.com/report/github.com/casbin/etcd-watcher) +[![Go](https://github.com/casbin/etcd-watcher/actions/workflows/ci.yml/badge.svg)](https://github.com/casbin/etcd-watcher/actions/workflows/ci.yml) +[![Coverage Status](https://coveralls.io/repos/github/casbin/etcd-watcher/badge.svg?branch=master)](https://coveralls.io/github/casbin/etcd-watcher?branch=master) +[![Go Reference](https://pkg.go.dev/badge/github.com/casbin/etcd-watcher/v2.svg)](https://pkg.go.dev/github.com/casbin/etcd-watcher/v2) +[![Release](https://img.shields.io/github/release/casbin/etcd-watcher.svg)](https://github.com/casbin/etcd-watcher/releases/latest) +[![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord&label=discord&color=5865F2)](https://discord.gg/S5UjpzGZjN) +[![Sourcegraph](https://sourcegraph.com/github.com/casbin/etcd-watcher/-/badge.svg)](https://sourcegraph.com/github.com/casbin/etcd-watcher?badge) + Etcd Watcher is the [Etcd](https://github.com/coreos/etcd) watcher for [Casbin](https://github.com/casbin/casbin). With this library, Casbin can synchronize the policy with the database in multiple enforcer instances. ## Installation