Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/datadog-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
go-version: 1.14
- runs-on: macos-latest
go-version: 1.15
- runs-on: macos-latest
go-version: 1.21
# No official linux/arm64 Go binaries before 1.16
- runs-on: ubuntu-24.04-arm
go-version: 1.13
Expand All @@ -55,6 +57,23 @@ jobs:
- run: go fmt ./statsd/...
- run: go test -race -v ./statsd/...

coverage:
runs-on: ubuntu-latest
steps:
- name: Setup go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c
with:
go-version: "1.24"
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Run tests with coverage
run: go test -coverprofile=coverage.out -covermode=atomic ./statsd/...
- name: Upload coverage to Datadog
uses: datadog/coverage-upload-github-action@d9548b1c3c4ab639d5d3ab29a1508af188975f77
with:
api_key: ${{ secrets.DD_API_KEY }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip coverage upload when the secret is unavailable

Because this workflow also runs on pull_request, PRs from forks and Dependabot events do not receive repository secrets, so secrets.DD_API_KEY resolves empty while the Datadog upload action requires api_key. In those contexts the new coverage job will fail after the tests pass, blocking or red-marking otherwise valid external PRs; guard this step/job to trusted events or make the upload conditional on the secret being present.

Useful? React with 👍 / 👎.

site: datadoghq.com

go_12_test:
runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 8 additions & 0 deletions code-coverage.datadog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
schema-version: v1
gates:
- type: total_coverage_percentage
config:
threshold: 83
- type: patch_coverage_percentage
config:
threshold: 90
Loading