diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml new file mode 100644 index 0000000..c999474 --- /dev/null +++ b/.github/workflows/rebase.yml @@ -0,0 +1,20 @@ +on: + issue_comment: + types: [created] + +name: Automatic Rebase +jobs: + rebase: + name: Rebase + if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') + runs-on: ubuntu-latest + steps: + - name: Checkout the latest code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Automatic Rebase + uses: cirrus-actions/rebase@1.5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..f79e32d --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,21 @@ +name: Release Drafter + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - master + - main + # pull_request event is required only for autolabeler + pull_request: + # Only following types are handled by the action, but one can default to all as well + types: [opened, reopened, synchronize] + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..32e51b3 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,82 @@ +on: + push: + branches: + - master + - main + # Only run if there are changes to Go code or related configurations + paths: + - "**.go" + - "go.mod" + - "go.sum" + - "codecov.yml" + pull_request: + # Only run if there are changes to Go code or related configurations + paths: + - "**.go" + - "go.mod" + - "go.sum" + - "codecov.yml" + +name: Tests +jobs: + test-cache: + name: "Run unit tests" + runs-on: ubuntu-latest + strategy: + matrix: + go-version: [1.16.x, 1.x] + steps: + uses: actions/checkout@v2 + with: + fetch-depth: 1 + uses: WillAbides/setup-go-faster@v1 + with: + go-version: ${{ matrix.go-version }} + + - uses: actions/cache@v2 + with: + # In order: + # * Module download cache + # * Build cache (Linux) + # * Build cache (Mac) + # * Build cache (Windows) + path: | + ~/go/pkg/mod + ~/.cache/go-build + ~/Library/Caches/go-build + %LocalAppData%\go-build + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Test with race and coverage + run: | + go test -race -coverprofile=coverage.out -covermode=atomic + go tool cover -func=coverage.out + + - uses: codecov/codecov-action@v2 + with: + files: ./coverage.out + + lint: + name: "Run static analysis" + runs-on: "ubuntu-latest" + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + - uses: WillAbides/setup-go-faster@v1 + with: + go-version: "1.x" + + - run: "GO111MODULE=on go get honnef.co/go/tools/cmd/staticcheck" + + - uses: actions/cache@v2 + with: + path: ~/.cache/staticcheck + key: staticcheck-${{ github.sha }} + restore-keys: | + staticcheck- + + - run: "go vet ./..." + - run: "$(go env GOPATH)/bin/staticcheck ./..." diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6aafa40..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: go - -go: - - "1.x" - - master -matrix: - allow_failures: - - go: master - fast_finish: true - -before_script: - - go get -t -v ./... - - go get -v golang.org/x/lint/golint - - go get -v honnef.co/go/tools/cmd/staticcheck - - go vet ./... - -script: - # run all our tests with race detector - - go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... - # "go vet on steroids" + linter - - golint ./... - - staticcheck ./... - -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/README.md b/README.md index 3745bf9..ca6d837 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ slug Package `slug` generate slug from unicode string, URL-friendly slugify with multiple languages support. -[![GoDoc](https://godoc.org/github.com/gosimple/slug?status.png)](https://godoc.org/github.com/gosimple/slug) -[![Build Status](https://travis-ci.com/gosimple/slug.svg?branch=master)](https://travis-ci.com/gosimple/slug) - -[Documentation online](http://godoc.org/github.com/gosimple/slug) +[![Go Reference](https://pkg.go.dev/badge/github.com/gosimple/slug.svg)](https://pkg.go.dev/github.com/gosimple/slug) +[![Tests](https://github.com/gosimple/slug/actions/workflows/tests.yml/badge.svg)](https://github.com/gosimple/slug/actions/workflows/tests.yml) +[![codecov](https://codecov.io/gh/gosimple/slug/branch/master/graph/badge.svg?token=FT2kEZHQW7)](https://codecov.io/gh/gosimple/slug) +[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/gosimple/slug?logo=github&sort=semver)](https://github.com/gosimple/slug/releases) ## Example diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..bd46b3e --- /dev/null +++ b/codecov.yml @@ -0,0 +1,4 @@ +comment: + layout: "diff, files" + behavior: default + require_changes: false # if true: only post the comment if coverage changes