Skip to content

Commit d291905

Browse files
committed
Append token to codecov.yml instead of duplicating the file
1 parent a3bc6df commit d291905

File tree

4 files changed

+37
-16
lines changed

4 files changed

+37
-16
lines changed

.github/codecov-upstream.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
- name: Prepare coverage token
138138
if: success() && !matrix.skip_coverage && ( github.repository == 'pytest-dev/pytest' || github.event_name == 'pull_request' )
139139
run: |
140-
cp .github/codecov-upstream.yml codecov.yml
140+
python scripts/append_codecov_token.py
141141
142142
- name: Combine coverage
143143
if: success() && !matrix.skip_coverage

codecov.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# note: `.github/codecov-upstream.yml` is basically a copy of this file, please propagate
2-
# changes as needed
31
coverage:
42
status:
53
project: true

scripts/append_codecov_token.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""
2+
Appends the codecov token to the 'codecov.yml' file at the root of the repository.
3+
4+
This is done by CI during PRs and builds on the pytest-dev repository so we can upload coverage, at least
5+
until codecov grows some native integration like it has with Travis and AppVeyor.
6+
7+
See discussion in https://github.com/pytest-dev/pytest/pull/6441 for more information.
8+
"""
9+
import os.path
10+
from textwrap import dedent
11+
12+
13+
def main():
14+
this_dir = os.path.dirname(__file__)
15+
cov_file = os.path.join(this_dir, "..", "codecov.yml")
16+
17+
assert os.path.isfile(cov_file), "{cov_file} does not exist".format(
18+
cov_file=cov_file
19+
)
20+
21+
with open(cov_file, "a") as f:
22+
# token from: https://codecov.io/gh/pytest-dev/pytest/settings
23+
# use same URL to regenerate it if needed
24+
text = dedent(
25+
"""
26+
codecov:
27+
token: "1eca3b1f-31a2-4fb8-a8c3-138b441b50a7"
28+
"""
29+
)
30+
f.write(text)
31+
32+
print("Token updated:", cov_file)
33+
34+
35+
if __name__ == "__main__":
36+
main()

0 commit comments

Comments
 (0)