Skip to content

Commit 850c203

Browse files
authored
test: work around codecov token rate limit (#808)
With this change, PRs in the repo use the `CODECOV_TOKEN` to upload coverage to codecov, while PRs from forks will keep using the upload via the public API, which is suffering from rate limiting issues. We can't fix the rate limiting issues, but at least we can work around it for PRs by maintainers for now.
1 parent cd7f16a commit 850c203

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

.github/workflows/test-and-tag.yml

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ jobs:
2626
run: |
2727
go test ./... -race -covermode=atomic -coverprofile=coverage.out
2828
29-
- name: Upload coverage to Codecov
30-
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
29+
- name: Upload coverage artifact
30+
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
3131
with:
32-
files: coverage.out
32+
name: coverage
33+
path: coverage.out
3334

3435
# This builds the binary and starts it. If it does not exit within 3 seconds, consider it
3536
# successful
@@ -40,10 +41,47 @@ jobs:
4041
make build
4142
API_URL=https://example.com/api timeout 3 ./backend || code=$?; if [[ $code -ne 124 && $code -ne 0 ]]; then exit $code; fi
4243
44+
codecov-upstream:
45+
if: github.repository == 'envelope-zero/backend'
46+
needs: test
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
51+
52+
- name: Download coverage artifacts
53+
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
54+
with:
55+
name: coverage
56+
57+
- name: Upload coverage to Codecov
58+
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
59+
with:
60+
files: coverage.out
61+
token: ${{ secrets.CODECOV_TOKEN }}
62+
63+
codecov-fork:
64+
if: github.repository != 'envelope-zero/backend'
65+
needs: test
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Checkout
69+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
70+
71+
- name: Download coverage artifacts
72+
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
73+
with:
74+
name: coverage
75+
76+
- name: Upload coverage to Codecov
77+
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
78+
with:
79+
files: coverage.out
80+
4381
tag:
4482
runs-on: ubuntu-latest
4583
needs: test
46-
if: ${{ github.ref == 'refs/heads/main' }}
84+
if: github.repository == 'envelope-zero/backend' && github.ref == 'refs/heads/main'
4785
steps:
4886
- name: Checkout
4987
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

0 commit comments

Comments
 (0)