From ee8ea315ebf4375a85af7877eaef3e8a331d18e0 Mon Sep 17 00:00:00 2001 From: Prathyusha Lakkireddy Date: Fri, 7 Jan 2022 05:55:03 +0530 Subject: [PATCH] add code cov action (#6) * add code cov action * remove codecov.yml * comment config test * add badges * add codeccov yml * add secret key of code cov * update code cov threshold --- .codecov.yml | 24 ++++++++++++++++++++++++ .github/workflows/build.yml | 26 ++++++++++++++++++++++++++ .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 23 ++++++++++++++++------- Makefile | 8 ++++++++ README.md | 6 ++++++ 6 files changed, 81 insertions(+), 8 deletions(-) create mode 100644 .codecov.yml create mode 100644 .github/workflows/build.yml create mode 100644 Makefile create mode 100644 README.md diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..26afead --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,24 @@ +# +# This codecov.yml is the default configuration for +# all repositories on Codecov. You may adjust the settings +# below in your own codecov.yml in your repository. +# +coverage: + precision: 2 + round: down + range: 70...100 + + status: + # Learn more at https://codecov.io/docs#yaml_default_commit_status + status: #Code coverage status will be posted to pull requests based on targets defined below. + diff: #diff coverage is code coverage only for the lines changed in a pull request. + target: 45% + + project: + default: + threshold: 1% # allow this much decrease on project + changes: false + +comment: + layout: "header, diff, flags" + behavior: default # update if exists else create new diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..39c2417 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,26 @@ +name: Build + +on: + workflow_dispatch: + pull_request: + push: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup go + uses: actions/setup-go@v2 + with: + go-version: 1.17 + + - name: Setup token for pulling from allinbits private repos + run: | + go env -w GOPRIVATE=github.com/allinbits/* + git config --global url."https://git:${{ secrets.TENDERBOT_GIT_TOKEN }}@github.com".insteadOf "https://github.com" + + - name: Build + run: go build -v ./... \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8e6d688..29accee 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: golangci-lint +name: Lint on: pull_request: push: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 410f8e8..91f3541 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,16 +1,21 @@ -name: Execute tests +name: Tests on: workflow_dispatch: pull_request: push: +env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + jobs: - test: - runs-on: self-hosted + code_cov: + runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v2 + with: + fetch-depth: 2 - name: Setup go uses: actions/setup-go@v2 @@ -22,8 +27,12 @@ jobs: go env -w GOPRIVATE=github.com/allinbits/* git config --global url."https://git:${{ secrets.TENDERBOT_GIT_TOKEN }}@github.com".insteadOf "https://github.com" - - name: Build - run: go build -v ./... + - name: Run Tests + run: make test - - name: Test - run: go test -v ./... + - name: Run coverage + run: go test ./... -race -coverprofile=coverage.out -covermode=atomic + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + with: + file: coverage.out diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e8b8115 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +test: + go test -v -race ./... -cover + +lint: + golangci-lint run ./... + +build: + go build ./... \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c697cf5 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# Emeris-utils + +[![codecov](https://codecov.io/gh/allinbits/emeris-utils/branch/main/graph/badge.svg?token=8MZNYVSKK9)](https://codecov.io/gh/allinbits/emeris-utils) +[![Build status](https://github.com/allinbits/emeris-utils/workflows/Build/badge.svg)](https://github.com/allinbits/emeris-utils/commits/main) +[![Tests status](https://github.com/allinbits/emeris-utils/workflows/Tests/badge.svg)](https://github.com/allinbits/emeris-utils/commits/main) +[![Lint](https://github.com/allinbits/emeris-utils/workflows/Lint/badge.svg?token)](https://github.com/allinbits/emeris-utils/commits/main)