Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add testv cov action #5

Merged
merged 16 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 20%

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
50 changes: 50 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Lint
on:
pull_request:
permissions:
contents: read
env:
GOPRIVATE: "github.com/allinbits/*"

jobs:
setup-matrix:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- name: Setup matrix combinations
id: setup-matrix-combinations
run: |
MATRIX_PARAMS_COMBINATIONS="$(make versions-json)"
echo ::set-output name=matrix-combinations::{\"include\":$MATRIX_PARAMS_COMBINATIONS}
outputs:
matrix-combinations: ${{ steps.setup-matrix-combinations.outputs.matrix-combinations }}

golangci:
name: lint
runs-on: self-hosted
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix-combinations) }}
timeout-minutes: 10
steps:
- uses: actions/checkout@v2

- name: Setup go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Configure git for private modules
env:
GIT_TOKEN: ${{ secrets.TENDERBOT_GIT_TOKEN }}
run: git config --global url."https://git:${GIT_TOKEN}@github.com".insteadOf "https://github.com"

- name: Setup multisdk
run: make setup-${{ matrix.versions }}

- name: golangci-lint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the lint seems to be failing, also make target for lint is missing

Copy link
Contributor Author

@PrathyushaLakkireddy PrathyushaLakkireddy Mar 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, Lint is failing bcz of some unused code.
Error: transferMsgType is unused in v42/v44. So shall I remove/comment it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure it's not being used in either of the versions, it gets tricky in this repo with build flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code which has used it was commented, but not transferMsgType var.

uses: golangci/[email protected]
with:
version: v1.43
args: --timeout 10m --build-tags sdk_${{ matrix.versions }}
github-token: ${{ secrets.TENDERBOT_GIT_TOKEN }}
55 changes: 55 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Tests

on:
workflow_dispatch:
pull_request:
push:

env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
jobs:
setup-matrix:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- name: Setup matrix combinations
id: setup-matrix-combinations
run: |
MATRIX_PARAMS_COMBINATIONS="$(make versions-json)"
echo ::set-output name=matrix-combinations::{\"include\":$MATRIX_PARAMS_COMBINATIONS}
outputs:
matrix-combinations: ${{ steps.setup-matrix-combinations.outputs.matrix-combinations }}

code_cov:
runs-on: self-hosted
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix-combinations) }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2

- 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/*
go env -w GOPROXY=direct
git config --global url."https://git:${{ secrets.TENDERBOT_GIT_TOKEN }}@github.com".insteadOf "https://github.com"
- name: Setup multisdk
run: make setup-${{ matrix.versions }}

- name: Run Tests
run: make test-${{ matrix.versions }}

- name: Run coverage
run: make coverage-${{ matrix.versions }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
file: coverage.out
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ SHELL := /usr/bin/env bash
SETUP_VERSIONS := $(shell jq -r '.versions|map("setup-\(.)")[]' ${TARGETS})
BUILD_VERSIONS := $(shell jq -r '.versions|map("build-\(.)")[]' ${TARGETS})
STORE_MOD_VERSIONS := $(shell jq -r '.versions|map("store-mod-\(.)")[]' ${TARGETS})
TEST_VERSIONS = $(shell jq -r '.versions|map("test-\(.)")[]' ${TARGETS})
COVERAGE_VERSIONS = $(shell jq -r '.versions|map("coverage-\(.)")[]' ${TARGETS})
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')

Expand Down Expand Up @@ -51,3 +53,13 @@ versions-json:
$(STORE_MOD_VERSIONS):
cp ./go.mod mods/go.mod.$(shell echo $@ | sed 's/store-mod-//g')
cp ./go.sum mods/go.sum.$(shell echo $@ | sed 's/store-mod-//g')

$(TEST_VERSIONS):
go test -v -failfast -race -count=1 \
-tags $(shell echo $@ | sed -e 's/test-/sdk_/g' -e 's/-/_/g'),muslc \
./...

$(COVERAGE_VERSIONS):
go test -v -failfast -coverprofile=coverage.out -covermode=atomic -count=1\
-tags $(shell echo $@ | sed -e 's/coverage-/sdk_/g' -e 's/-/_/g'),muslc \
./...
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# sdk-service

[![codecov](https://codecov.io/gh/allinbits/sdk-service/branch/main/graph/badge.svg?token=AXDASRALWG)](https://codecov.io/gh/allinbits/sdk-service)
[![Build status](https://github.com/allinbits/sdk-service/workflows/Build/badge.svg)](https://github.com/allinbits/sdk-service/commits/main)
[![Tests status](https://github.com/allinbits/sdk-service/workflows/Tests/badge.svg)](https://github.com/allinbits/sdk-service/commits/main)
[![Lint](https://github.com/allinbits/sdk-service/workflows/Lint/badge.svg?token)](https://github.com/allinbits/sdk-service/commits/main)