From ca9f2ceeaada5ae0ea38ed9fe5dda27713c69db6 Mon Sep 17 00:00:00 2001 From: Phillip Miller Date: Wed, 29 Dec 2021 06:04:34 -0500 Subject: [PATCH] use Codecov instead of Codacy --- .../workflows/codacy-coverage-reporter.yml | 78 ------------------- .../workflows/codecov-coverage-reporter.yml | 67 ++++++++++++++++ .github/workflows/go.yml | 48 ++++++------ .gitignore | 1 + README.md | 2 +- 5 files changed, 93 insertions(+), 103 deletions(-) delete mode 100644 .github/workflows/codacy-coverage-reporter.yml create mode 100644 .github/workflows/codecov-coverage-reporter.yml diff --git a/.github/workflows/codacy-coverage-reporter.yml b/.github/workflows/codacy-coverage-reporter.yml deleted file mode 100644 index 114a8ae..0000000 --- a/.github/workflows/codacy-coverage-reporter.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: codacy-coverage-reporter - -on: - push: - tags: - - '*' - pull_request: - -jobs: - codacy-coverage-reporter: - strategy: - matrix: - go-version: [1.17.x] - os: [ubuntu-latest] - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v2 - - # Setup Go - - name: Setup Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - - id: go-cache-paths - run: | - echo "::set-output name=go-build::$(go env GOCACHE)" - echo "::set-output name=go-mod::$(go env GOMODCACHE)" - - # Cache go build cache - - name: Go Build Cache - uses: actions/cache@v2 - with: - path: ${{ steps.go-cache-paths.outputs.go-build }} - key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - - # Cache go mod cache - - name: Go Mod Cache - uses: actions/cache@v2 - with: - path: ${{ steps.go-cache-paths.outputs.go-mod }} - key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} - - # Remove apt repos that are known to break from time to time - # See https://github.com/actions/virtual-environments/issues/323 - - name: Remove broken apt repos [Ubuntu] - run: | - for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done - if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-18.04' - - # Install all the dependencies - - name: Install dependencies - run: | - go version - go install github.com/axw/gocov/gocov@latest - go install github.com/AlekSi/gocov-xml@latest - go get -u github.com/jstemmer/go-junit-report - go get -u github.com/kyoh86/richgo - sudo apt-get update -y || true - - # Run build of the application - - name: Run build - run: | - make -f MakeFile build - - # Run Tests and Coverage - - name: Run Tests and Coverage - run: | - go test -v -coverprofile=coverage.out ./... | tee test.out - cat test.out | go-junit-report > coverage/${{ runner.OS }}-report.xml - gocov convert coverage.out | gocov-xml > coverage/${{ runner.OS }}-report.xml - - - name: Run codacy-coverage-reporter - uses: codacy/codacy-coverage-reporter-action@v1 - with: - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} - coverage-reports: coverage/${{ runner.OS }}-report.xml \ No newline at end of file diff --git a/.github/workflows/codecov-coverage-reporter.yml b/.github/workflows/codecov-coverage-reporter.yml new file mode 100644 index 0000000..a3eac7d --- /dev/null +++ b/.github/workflows/codecov-coverage-reporter.yml @@ -0,0 +1,67 @@ +name: Codecov + +on: + push: + tags: + - '*' + pull_request: + +jobs: + coverage-reporter: + strategy: + matrix: + go-version: [1.17.x] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + + # Setup Go + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - id: go-cache-paths + run: | + echo "::set-output name=gobuild::$(go env GOCACHE)" + echo "::set-output name=gomod::$(go env GOMODCACHE)" + + # Cache go build cache + - name: Go Build Cache + uses: actions/cache@v2 + with: + path: ${{ steps.go-cache-paths.outputs.gobuild }} + key: ${{ runner.os }}-gobuild-${{ hashFiles('**/go.sum') }} + + # Cache go mod cache + - name: Go Mod Cache + uses: actions/cache@v2 + with: + path: ${{ steps.go-cache-paths.outputs.gomod }} + key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }} + + # Remove apt repos that are known to break from time to time + # See https://github.com/actions/virtual-environments/issues/323 + - name: Remove broken apt repos [Ubuntu] + run: | + for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done + if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-18.04' + + # Run build of the application + - name: Run build + run: | + make -f MakeFile build + + # Run Tests and Coverage + - name: Run coverage + run: go test ./... -v -race -coverprofile=coverage.txt -covermode=atomic + + - name: Codecov + uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage.txt + env_vars: OS,GOVERSION + verbose: true \ No newline at end of file diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 91ab09c..fbf8a64 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -24,22 +24,22 @@ jobs: - id: go-cache-paths run: | - echo "::set-output name=go-build::$(go env GOCACHE)" - echo "::set-output name=go-mod::$(go env GOMODCACHE)" + echo "::set-output name=gobuild::$(go env GOCACHE)" + echo "::set-output name=gomod::$(go env GOMODCACHE)" # Cache go build cache - name: Go Build Cache uses: actions/cache@v2 with: - path: ${{ steps.go-cache-paths.outputs.go-build }} - key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + path: ${{ steps.go-cache-paths.outputs.gobuild }} + key: ${{ runner.os }}-gobuild-${{ hashFiles('**/go.sum') }} # Cache go mod cache - name: Go Mod Cache uses: actions/cache@v2 with: - path: ${{ steps.go-cache-paths.outputs.go-mod }} - key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} + path: ${{ steps.go-cache-paths.outputs.gomod }} + key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }} - name: Install dependencies run: go get github.com/mattn/go-isatty@v0.0.12 @@ -66,22 +66,22 @@ jobs: - id: go-cache-paths run: | - echo "::set-output name=go-build::$(go env GOCACHE)" - echo "::set-output name=go-mod::$(go env GOMODCACHE)" + echo "::set-output name=gobuild::$(go env GOCACHE)" + echo "::set-output name=gomod::$(go env GOMODCACHE)" # Cache go build cache - name: Go Build Cache uses: actions/cache@v2 with: - path: ${{ steps.go-cache-paths.outputs.go-build }} - key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + path: ${{ steps.go-cache-paths.outputs.gobuild }} + key: ${{ runner.os }}-gobuild-${{ hashFiles('**/go.sum') }} # Cache go mod cache - name: Go Mod Cache uses: actions/cache@v2 with: - path: ${{ steps.go-cache-paths.outputs.go-mod }} - key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} + path: ${{ steps.go-cache-paths.outputs.gomod }} + key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }} - name: Install dependencies run: go get github.com/mattn/go-isatty@v0.0.12 @@ -118,22 +118,22 @@ jobs: - id: go-cache-paths run: | - echo "::set-output name=go-build::$(go env GOCACHE)" - echo "::set-output name=go-mod::$(go env GOMODCACHE)" + echo "::set-output name=gobuild::$(go env GOCACHE)" + echo "::set-output name=gomod::$(go env GOMODCACHE)" # Cache go build cache - name: Go Build Cache uses: actions/cache@v2 with: - path: ${{ steps.go-cache-paths.outputs.go-build }} - key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + path: ${{ steps.go-cache-paths.outputs.gobuild }} + key: ${{ runner.os }}-gobuild-${{ hashFiles('**/go.sum') }} # Cache go mod cache - name: Go Mod Cache uses: actions/cache@v2 with: - path: ${{ steps.go-cache-paths.outputs.go-mod }} - key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} + path: ${{ steps.go-cache-paths.outputs.gomod }} + key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }} - name: Go Build run: | @@ -196,22 +196,22 @@ jobs: - id: go-cache-paths run: | - echo "::set-output name=go-build::$(go env GOCACHE)" - echo "::set-output name=go-mod::$(go env GOMODCACHE)" + echo "::set-output name=gobuild::$(go env GOCACHE)" + echo "::set-output name=gomod::$(go env GOMODCACHE)" # Cache go build cache - name: Go Build Cache uses: actions/cache@v2 with: - path: ${{ steps.go-cache-paths.outputs.go-build }} - key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + path: ${{ steps.go-cache-paths.outputs.gobuild }} + key: ${{ runner.os }}-gobuild-${{ hashFiles('**/go.sum') }} # Cache go mod cache - name: Go Mod Cache uses: actions/cache@v2 with: - path: ${{ steps.go-cache-paths.outputs.go-mod }} - key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} + path: ${{ steps.go-cache-paths.outputs.gomod }} + key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }} - name: Install dependencies run: go get github.com/mattn/go-isatty@v0.0.12 diff --git a/.gitignore b/.gitignore index 6a3fb6b..a8b4bed 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ bin/* *.html *.xml coverage/* +coverage.txt diff --git a/README.md b/README.md index e3217f3..21c8d6d 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ ![GitHub release (latest by date)](https://img.shields.io/github/v/release/mr-pmillz/pimp-my-shell?style=plastic) ![GitHub commit activity](https://img.shields.io/github/commit-activity/m/mr-pmillz/pimp-my-shell?style=plastic) [![Twitter](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2Fmr-pmillz%2Fpimp-my-shell)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Fmr-pmillz%2Fpimp-my-shell) -[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/cffe102aadbd4f4394754f0c259cc527)](https://www.codacy.com/gh/mr-pmillz/pimp-my-shell/dashboard?utm_source=github.com&utm_medium=referral&utm_content=mr-pmillz/pimp-my-shell&utm_campaign=Badge_Coverage) [![CI](https://github.com/mr-pmillz/pimp-my-shell/actions/workflows/go.yml/badge.svg)](https://github.com/mr-pmillz/pimp-my-shell/actions/workflows/go.yml) +[![codecov](https://codecov.io/gh/mr-pmillz/pimp-my-shell/branch/master/graph/badge.svg)](https://codecov.io/gh/mr-pmillz/pimp-my-shell) Table of Contents =================