Skip to content

Commit 00ff688

Browse files
Enable codecov and generate metadata file as artifact (#1320)
1 parent 0d1f929 commit 00ff688

File tree

4 files changed

+93
-1
lines changed

4 files changed

+93
-1
lines changed

.buildkite/pipeline.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ steps:
44
queue: "init"
55
docker: "*"
66
command: ".buildkite/scripts/fossa.sh"
7+
78
- label: ":golang: unit-test"
89
agents:
910
queue: "workers"
1011
docker: "*"
11-
command: "make unit_test"
12+
commands:
13+
- "make unit_test"
14+
- ".buildkite/scripts/gen_coverage_metadata.sh .build/metadata.txt"
1215
artifact_paths:
1316
- ".build/*/coverage/*.out"
17+
- ".build/cover.out"
18+
- ".build/metadata.txt"
1419
plugins:
1520
- docker-compose#v3.0.0:
1621
run: unit-test
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
# This script generates coverage metadata for the coverage report.
6+
# Output is used by SonarQube integration in Uber and not used by OS repo coverage tool itself.
7+
8+
# Example output:
9+
# commit-sha: 6953daa563e8e44512bc349c9608484cfd4ec4ff
10+
# timestamp: 2024-03-04T19:29:16Z
11+
12+
output_path="$1"
13+
14+
echo "commit-sha: $(git rev-parse HEAD)" > "$output_path"
15+
echo "timestamp: $(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$output_path"
16+
17+
echo "Coverage metadata written to $output_path"

.github/workflows/codecov.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Workflow for Codecov integration
2+
on: [push, pull_request]
3+
jobs:
4+
codecov:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: Checkout
8+
uses: actions/checkout@v4
9+
with:
10+
fetch-depth: 0
11+
12+
- name: Set up Go
13+
uses: actions/setup-go@v4
14+
with:
15+
go-version: 1.22.x
16+
cache: false
17+
18+
- name: Download dependencies
19+
run: go mod download
20+
21+
- name: Test and generate coverage report
22+
run: make unit_test
23+
24+
- name: Upload coverage reports to Codecov
25+
uses: codecov/[email protected] # https://github.com/codecov/codecov-action
26+
with:
27+
file: .build/cover.out
28+
exclude: ./
29+
token: ${{ secrets.CODECOV_TOKEN }}
30+
slug: uber-go/cadence-client

codecov.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Refs:
2+
# - https://docs.codecov.com/docs/common-recipe-list
3+
# - https://docs.codecov.com/docs/codecovyml-reference
4+
#
5+
# After making changes, run below command to validate
6+
# curl --data-binary @codecov.yml https://codecov.io/validate
7+
coverage:
8+
range: 80...100
9+
round: down
10+
precision: 2
11+
status:
12+
project: # measuring the overall project coverage
13+
default: # context, you can create multiple ones with custom titles
14+
informational: true
15+
target: 85% # specify the target coverage for each commit status
16+
# option: "auto" (compare against parent commit or pull request base)
17+
# option: "X%" a static target percentage to hit
18+
threshold: 0% # allow the coverage drop by x% before marking as failure
19+
if_ci_failed: ignore # require the CI to pass before setting the status
20+
patch:
21+
default:
22+
informational: true
23+
comment:
24+
layout: "header, files, footer"
25+
hide_project_coverage: false
26+
codecov:
27+
require_ci_to_pass: false
28+
ignore:
29+
- "**/*_generated.go"
30+
- "**/*_mock.go"
31+
- "**/testdata/**"
32+
- "**/*_test.go"
33+
- "**/*_testsuite.go"
34+
- "compatibility/**"
35+
- "idls/**"
36+
- "internal/compatibility/**"
37+
- "internal/tools/**"
38+
- "mocks/**"
39+
- "test/**"
40+
- "testsuite/**"

0 commit comments

Comments
 (0)