Skip to content

Commit

Permalink
ci: configure codecov upload during PR (#394)
Browse files Browse the repository at this point in the history
## 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 <[email protected]>
  • Loading branch information
beeme1mr authored Feb 9, 2023
1 parent ff518a3 commit c2a1d53
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
55 changes: 28 additions & 27 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ dist/
pkg/eval/flagd-definitions.json
*.crt
*.key
coverage.out
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit c2a1d53

Please sign in to comment.