Skip to content

Commit

Permalink
add code cov action (#6)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
PrathyushaLakkireddy authored Jan 7, 2022
1 parent 0cadfea commit ee8ea31
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 8 deletions.
24 changes: 24 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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 ./...
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: golangci-lint
name: Lint
on:
pull_request:
push:
Expand Down
23 changes: 16 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test:
go test -v -race ./... -cover

lint:
golangci-lint run ./...

build:
go build ./...
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit ee8ea31

Please sign in to comment.