diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..f2fbdb0 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,53 @@ +name: Test and Generate code coverage badge + +on: + push: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + name: Update coverage badge + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. + fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. + + - name: Setup go + uses: actions/setup-go@v4 + with: + go-version-file: 'go.mod' + + - name: Run Test + run: | + go test -v ./... -covermode=count -coverprofile=coverage.out + go tool cover -func=coverage.out -o=coverage.out + + - name: Go Coverage Badge # Pass the `coverage.out` output to this action + uses: tj-actions/coverage-badge-go@v2 + with: + filename: coverage.out + + - name: Verify Changed files + uses: tj-actions/verify-changed-files@v16 + id: verify-changed-files + with: + files: README.md + + - name: Commit changes + if: steps.verify-changed-files.outputs.files_changed == 'true' + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add README.md + git commit -m "chore: Updated coverage badge." + + - name: Push changes + if: steps.verify-changed-files.outputs.files_changed == 'true' + uses: ad-m/github-push-action@master + with: + github_token: ${{ github.token }} + branch: ${{ github.head_ref }} \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5080312 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +test: + go test ./ ... diff --git a/README.md b/README.md index 23ee7f7..de6a13e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ gothumbor ========= -[![GoDoc](https://godoc.org/github.com/globocom/gothumbor?status.svg)](https://godoc.org/github.com/globocom/gothumbor) [![Build Status](https://travis-ci.org/globocom/gothumbor.svg?branch=master)](https://travis-ci.org/globocom/gothumbor) [![Coverage Status](https://coveralls.io/repos/globocom/gothumbor/badge.svg?branch=master&service=github)](https://coveralls.io/github/globocom/gothumbor?branch=master) +[![GoDoc](https://godoc.org/github.com/globocom/gothumbor?status.svg)](https://godoc.org/github.com/globocom/gothumbor) +[![Go Report Card](https://goreportcard.com/badge/github.com/globocom/gothumbor)](https://goreportcard.com/report/github.com/globocom/gothumbor) +[![Tests](https://github.com/globocom/gothumbor/actions/workflows/coverage.yml/badge.svg)](https://github.com/globocom/gothumbor/actions/workflows/coverage.yml) +![Coverage](https://img.shields.io/badge/Coverage-93.3%25-brightgreen) gothumbor allows easy usage of [Thumbor] in Go. diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..646e27b --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/globocom/gothumbor + +go 1.20