From 45e15ea84fa3e5efe2cda1c1d61daf5da2c82c78 Mon Sep 17 00:00:00 2001 From: Anton Litvinov Date: Thu, 10 Sep 2020 13:53:23 +0300 Subject: [PATCH] [add] code coverage metrics --- .github/workflows/cover.yml | 48 +++++++++++++++++++++++++++++++++++++ README.md | 3 +++ route_builder_test.go | 3 ++- 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cover.yml diff --git a/.github/workflows/cover.yml b/.github/workflows/cover.yml new file mode 100644 index 0000000..300a5b0 --- /dev/null +++ b/.github/workflows/cover.yml @@ -0,0 +1,48 @@ +name: Test +on: [push] +env: + GO111MODULE: "on" + +jobs: + test: + name: Tests and Coverage + runs-on: ubuntu-latest + steps: + + - name: Install Go + uses: actions/setup-go@v1 + with: + go-version: 1.14 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Get dependencies + run: | + go get -d -v + + - name: Run tests and calculate code coverage + run: | + out=$(go test ./... -coverprofile cover.out) + out="${out//'%'/'%25'}" + out="${out//$'\n'/'%0A'}" + out="${out//$'\r'/'%0D'}" + echo -e "::set-env name=COVER::$out" + go tool cover -html=cover.out -o coverage.html + + - name: Upload artifacts + uses: actions/upload-artifact@v1 + with: + name: coverage + path: coverage.html + + - name: Comment + uses: mshick/add-pr-comment@v1 + with: + message: | + **code coverage: ** + ${{ env.COVER }} + repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token-user-login: 'github-actions[bot]' # The user.login for temporary GitHub tokens + allow-repeats: true # This is the default \ No newline at end of file diff --git a/README.md b/README.md index 85204c6..24f7553 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # go-data-routing +![Test](https://github.com/Zensey/go-data-routing/workflows/Test/badge.svg?branch=dev) + + The library provides a pipeline engine for stream processing of data. It is based on the concept of EIP (enterprise integration patterns). diff --git a/route_builder_test.go b/route_builder_test.go index 051b46f..55a2b46 100644 --- a/route_builder_test.go +++ b/route_builder_test.go @@ -14,7 +14,7 @@ func (r *Probe) Run() {} func TestEnrich(t *testing.T) { - for i := 0; i < 1000; i++ { + for i := 0; i < 100; i++ { Enrich(t) } } @@ -51,6 +51,7 @@ func Enrich(t *testing.T) { }() rc.Run() rc.Print() + // check that all nodes are stoped for _, r := range rc.routes { for _, n := range *r {