From c2a1d539b0a420c74f8178ec8fe5534d5e7ca997 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Thu, 9 Feb 2023 15:43:11 -0500 Subject: [PATCH] ci: configure codecov upload during PR (#394) ## This PR - adds codecov to PR runs - updates make test to include recommended test flags ### Notes This change includes test flags for `race` and `covermode` based on a recommendation from [Codecov](https://about.codecov.io/blog/getting-started-with-code-coverage-for-golang/). Looking into the flags, they both seem like good ideas and run fine locally. ### How to test Run make test locally. Signed-off-by: Michael Beemer --- .github/workflows/build.yaml | 55 ++++++++++++++++++------------------ .gitignore | 1 + Makefile | 2 +- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 06b2e81ac..91d118a07 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -6,44 +6,43 @@ on: - feature/workflows - main paths-ignore: - - 'README.md' - - 'docs/**' + - "README.md" + - "docs/**" pull_request: branches: - main paths-ignore: - - 'README.md' - - 'docs/**' + - "README.md" + - "docs/**" env: GO_VERSION: 1.19.3 jobs: - benchmark: - name: Run Benchmark - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 - - name: Setup go - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3 - with: - go-version: ${{ env.GO_VERSION }} - - name: Run benchmark - run: go test -bench . -benchtime=5s -benchmem ./... | tee output.txt + name: Run Benchmark + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 + - name: Setup go + uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3 + with: + go-version: ${{ env.GO_VERSION }} + - name: Run benchmark + run: go test -bench . -benchtime=5s -benchmem ./... | tee output.txt - - name: Store benchmark result - uses: benchmark-action/github-action-benchmark@v1 - with: - name: Go Benchmark - tool: 'go' - output-file-path: output.txt - github-token: ${{ secrets.GITHUB_TOKEN }} - auto-push: false - # Show alert with commit comment on detecting possible performance regression - alert-threshold: '130%' - comment-on-alert: true - fail-on-alert: false + - name: Store benchmark result + uses: benchmark-action/github-action-benchmark@v1 + with: + name: Go Benchmark + tool: "go" + output-file-path: output.txt + github-token: ${{ secrets.GITHUB_TOKEN }} + auto-push: false + # Show alert with commit comment on detecting possible performance regression + alert-threshold: "130%" + comment-on-alert: true + fail-on-alert: false lint: runs-on: ubuntu-latest @@ -86,6 +85,8 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - run: make test + - name: Upload coverage to Codecov + uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3 docker-local: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 1de66322b..3b4ec8007 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ dist/ pkg/eval/flagd-definitions.json *.crt *.key +coverage.out \ No newline at end of file diff --git a/Makefile b/Makefile index 5c9baf7cf..faeec24d4 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ docker-push: build: go build -ldflags "-X main.version=dev -X main.commit=$$(git rev-parse --short HEAD) -X main.date=$$(date +%FT%TZ)" -o flagd test: - go test -cover ./... + go test -race -covermode=atomic -cover ./pkg/... -coverprofile=coverage.out run: go run main.go start -f file:config/samples/example_flags.json install: