Skip to content

Commit 2d65beb

Browse files
chore: use oidc to report coverage (#252)
1 parent f14576d commit 2d65beb

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

.github/workflows/CI.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ on:
99
jobs:
1010
run-tests:
1111
runs-on: ubuntu-latest
12-
env:
13-
DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }}
12+
permissions:
13+
id-token: write # Required to fetch the OIDC token
1414

1515
steps:
1616
- name: Set up Go 1.x
@@ -40,4 +40,4 @@ jobs:
4040
- name: Report test coverage to DeepSource
4141
run: |
4242
curl https://deepsource.io/cli | sh
43-
./bin/deepsource report --analyzer test-coverage --key go --value-file ./coverage.out
43+
./bin/deepsource report --analyzer test-coverage --key go --value-file ./coverage.out --use-oidc

utils/fetch_oidc_token_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ func TestGetDSNFromOIDC(t *testing.T) {
284284
t.Setenv("GITHUB_ACTIONS", "true")
285285
// ACTIONS_ID_TOKEN_REQUEST_TOKEN is missing
286286
t.Setenv("ACTIONS_ID_TOKEN_REQUEST_URL", "url")
287+
// make sure this is missing when running on github actions too
288+
os.Unsetenv("ACTIONS_ID_TOKEN_REQUEST_TOKEN")
287289
t.Cleanup(func() {
288290
os.Unsetenv("GITHUB_ACTIONS")
289291
os.Unsetenv("ACTIONS_ID_TOKEN_REQUEST_URL")
@@ -300,6 +302,7 @@ func TestGetDSNFromOIDC(t *testing.T) {
300302
t.Run("error_github_actions_env_vars_missing_url", func(t *testing.T) {
301303
t.Setenv("GITHUB_ACTIONS", "true")
302304
t.Setenv("ACTIONS_ID_TOKEN_REQUEST_TOKEN", "token")
305+
os.Unsetenv("ACTIONS_ID_TOKEN_REQUEST_URL")
303306
// ACTIONS_ID_TOKEN_REQUEST_URL is missing
304307
t.Cleanup(func() {
305308
os.Unsetenv("GITHUB_ACTIONS")

0 commit comments

Comments
 (0)