From 8cc68737716a3aa3b1e99ea1a32adf99afe966df Mon Sep 17 00:00:00 2001 From: "fujianhao.fjh" Date: Wed, 6 Dec 2023 10:38:49 +0800 Subject: [PATCH] setput github CI --- .github/codecov.yaml | 23 +++++++++++++ .github/workflows/reviewdog.yaml | 57 ++++++++++++++++++++++++++++++++ .gitignore | 4 +++ Makefile | 4 +++ ut.sh | 14 ++++++++ 5 files changed, 102 insertions(+) create mode 100644 .github/codecov.yaml create mode 100644 .github/workflows/reviewdog.yaml create mode 100644 .gitignore create mode 100644 Makefile create mode 100755 ut.sh diff --git a/.github/codecov.yaml b/.github/codecov.yaml new file mode 100644 index 0000000..7051d4d --- /dev/null +++ b/.github/codecov.yaml @@ -0,0 +1,23 @@ +# To validate: +# cat codecov.yml | curl --data-binary @- https://codecov.io/validate + +codecov: + notify: + require_ci_to_pass: yes + + allow_coverage_offsets: true + +coverage: + precision: 2 + round: down + range: "50...75" + + status: + project: + default: + threshold: 1 + # Disable patch since it is noisy and not correct + patch: + default: + enabled: no + if_not_found: success diff --git a/.github/workflows/reviewdog.yaml b/.github/workflows/reviewdog.yaml new file mode 100644 index 0000000..6ab4942 --- /dev/null +++ b/.github/workflows/reviewdog.yaml @@ -0,0 +1,57 @@ +name: actions +on: + push: + branches: + - master + pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review +jobs: + test: + if: ${{ !github.event.pull_request.draft }} + name: Test + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + go-version: + - "golang:1.21" + - "golang:1.20" + - "golang:1.19" + - "golang:1.18" + - "golang:1.17" + - "golang:1.16" + - "golang:1.15" + - "golang:1.14" + + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Run Unit tests. + env: + BUILD_IMAGE: ${{ matrix.go-version }} + run: make test + + - name: Coverage + run: bash <(curl -s https://codecov.io/bash) + + build: + if: ${{ !github.event.pull_request.draft }} + name: build + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.14 + cache: true + + - name: Run Build. + run: go build ./... diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c9a1ace --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.* +!.gitignore + +coverage.* \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dae4aa1 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +test: + bash ./ut.sh + +.PHONY: test \ No newline at end of file diff --git a/ut.sh b/ut.sh new file mode 100755 index 0000000..7a66ceb --- /dev/null +++ b/ut.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -e +echo "" > coverage.txt + +for d in $(go list ./test/... | grep -v test/fake); do + echo "--------Run test package: $d" + GO111MODULE=on go test -gcflags="all=-N -l" -v -coverprofile=profile.out -coverpkg=./... -covermode=atomic $d + echo "--------Finish test package: $d" + if [ -f profile.out ]; then + cat profile.out >> coverage.txt + rm profile.out + fi +done