Skip to content

Commit 21cb3d0

Browse files
committed
use codecov actions to upload instead of the cli
1 parent 285163a commit 21cb3d0

File tree

2 files changed

+188
-39
lines changed

2 files changed

+188
-39
lines changed

.github/workflows/run-tests-split.yml

Lines changed: 105 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,28 @@ env:
1818
AR_REPO: ${{ inputs.repo }}
1919

2020
jobs:
21+
# Create a list from 1 to `inputs.split` to use as our matrix for `test`
22+
prepare_groups:
23+
name: Prepare groups
24+
id: prepare_groups
25+
runs-on: ubuntu-latest
26+
# echo {1..5} => 1 2 3 4 5
27+
# echo {1..5} | sed 's/ /, /g' => 1, 2, 3, 4, 5
28+
# echo '[$(echo {1..5} | sed 's/ /, /g')]' => [1, 2, 3, 4, 5]
29+
steps:
30+
- id: prepare_groups
31+
runs: |
32+
group_list=$(echo "[$(echo {1..${{ inputs.split }}} | sed 's/ /, /g')]")
33+
echo "groups='$group_list'" >> $GITHUB_OUTPUT
34+
2135
test:
2236
name: Test
2337
runs-on: ubuntu-latest
38+
needs: [prepare_groups]
2439
strategy:
2540
matrix:
26-
group: [1, 2, 3, 4, 5]
41+
# Parse our group list into a JSON object
42+
group: ${{ fromJSON(needs.prepare_groups.outputs.groups) }}
2743
steps:
2844
- name: Checkout
2945
uses: actions/checkout@v4
@@ -59,20 +75,91 @@ jobs:
5975
if: inputs.run_integration == true
6076
run: |
6177
make test_env.run_integration GROUP=${{ matrix.group }} SPLIT=${{ inputs.split }}
62-
## Don't upload on forks for now.
63-
- name: upload using codecovcli
64-
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
65-
run: |
66-
make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_ORG_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_URL }}
67-
- name: upload using codecovcli staging
68-
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
69-
run: |
70-
make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_ORG_TOKEN_STAGING }} CODECOV_URL=${{ secrets.CODECOV_STAGING_URL }}
71-
- name: upload using codecovcli qa
72-
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
73-
run: |
74-
make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_QA_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_QA_URL }}
75-
- name: upload using codecovcli public qa
76-
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
77-
run: |
78-
make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_PUBLIC_QA_URL }}
78+
79+
- uses: actions/upload-artifact@v4
80+
if: ${{ !cancelled() }}
81+
with:
82+
name: coveragefiles-${{ matrix.group }}
83+
path: ./*.coverage.xml
84+
85+
- uses: actions/upload-artifact@v4
86+
if: ${{ !cancelled() }}
87+
with:
88+
name: junitfiles-${{ matrix.group }}
89+
path: ./*junit*.xml
90+
91+
upload:
92+
name: Upload to Codecov
93+
runs-on: ubuntu-latest
94+
needs: [test]
95+
strategy:
96+
matrix:
97+
include:
98+
- codecov_url_secret: CODECOV_URL
99+
codecov_token_secret: CODECOV_ORG_TOKEN
100+
name: prod
101+
- codecov_url_secret: CODECOV_STAGING_URL
102+
codecov_token_secret: CODECOV_ORG_TOKEN_STAGING
103+
name: staging
104+
- codecov_url_secret: CODECOV_QA_URL
105+
codecov_token_secret: CODECOV_QA_ORG
106+
name: qa
107+
- codecov_url_secret: CODECOV_PUBLIC_QA_URL
108+
codecov_token_secret: CODECOV_PUBLIC_QA_TOKEN
109+
name: public qa
110+
111+
steps:
112+
- name: Checkout
113+
uses: actions/checkout@v4
114+
with:
115+
fetch-depth: 0
116+
117+
- name: Download coverage
118+
uses: actions/download-artifact@v4
119+
with:
120+
pattern: coveragefiles-*
121+
merge_multiple: true
122+
123+
- name: Download test results
124+
uses: actions/download-artifact@v4
125+
with:
126+
pattern: junitfiles-*
127+
merge_multiple: true
128+
129+
- name: Uploading unit test coverage (${{ matrix.name }})
130+
uses: codecov/codecov-action@v5
131+
with:
132+
files: ./unit.*.coverage.xml
133+
flags: ${{ format('{0}unit', inputs.flag_prefix) }}
134+
disable_search: true
135+
token: ${{ secrets[matrix.codecov_token_secret] }}
136+
url: ${{ secrets[matrix.codecov_url_secret] }}
137+
138+
- name: Uploading integration test coverage (${{ matrix.name }})
139+
if: ${{ inputs.run_integration == true }}
140+
uses: codecov/codecov-action@v5
141+
with:
142+
files: ./integration.*.coverage.xml
143+
flags: ${{ format('{0}integration', inputs.flag_prefix) }}
144+
disable_search: true
145+
token: ${{ secrets[matrix.codecov_token_secret] }}
146+
url: ${{ secrets[matrix.codecov_url_secret] }}
147+
148+
- name: Uploading unit test results (${{ matrix.name }})
149+
uses: codecov/test-results-action@v1
150+
with:
151+
files: ./unit.*.junit.xml
152+
flags: ${{ format('{0}unit', inputs.flag_prefix) }}
153+
disable_search: true
154+
token: ${{ secrets[matrix.codecov_token_secret] }}
155+
url: ${{ secrets[matrix.codecov_url_secret] }}
156+
157+
- name: Uploading integration test results (${{ matrix.name }})
158+
if: ${{ inputs.run_integration == true }}
159+
uses: codecov/test-results-action@v1
160+
with:
161+
files: ./integration.*.junit.xml
162+
flags: ${{ format('{0}integration', inputs.flag_prefix) }}
163+
disable_search: true
164+
token: ${{ secrets[matrix.codecov_token_secret] }}
165+
url: ${{ secrets[matrix.codecov_url_secret] }}

.github/workflows/run-tests.yml

Lines changed: 83 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
repo:
1111
type: string
1212
required: true
13+
flag_prefix:
14+
type: string
15+
default: ''
1316
env:
1417
AR_REPO: ${{ inputs.repo }}
1518

@@ -52,30 +55,89 @@ jobs:
5255
if: ${{ !cancelled() && inputs.run_integration == true }}
5356
run: |
5457
make test_env.run_integration
58+
59+
- uses: actions/upload-artifact@v4
60+
if: ${{ !cancelled() }}
61+
with:
62+
name: coveragefiles
63+
path: ./*.coverage.xml
64+
5565
- uses: actions/upload-artifact@v4
5666
if: ${{ !cancelled() }}
5767
with:
5868
name: junitfiles
5969
path: ./*junit*.xml
60-
## Don't upload on forks for now.
61-
- name: upload using codecovcli
62-
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
63-
run: |
64-
make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_ORG_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_URL }}
65-
- name: upload using codecovcli staging
66-
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
67-
run: |
68-
make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_ORG_TOKEN_STAGING }} CODECOV_URL=${{ secrets.CODECOV_STAGING_URL }}
69-
- name: upload using codecovcli qa
70-
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
71-
run: |
72-
make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_QA_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_QA_URL }}
73-
- name: upload using codecovcli public qa
74-
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
75-
run: |
76-
make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_PUBLIC_QA_URL }}
77-
- name: run basic-test-results
78-
if: ${{ !cancelled() && github.ref && contains(github.ref, 'pull') && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
79-
uses: codecov/basic-test-results@v1
70+
71+
upload:
72+
name: Upload to Codecov
73+
runs-on: ubuntu-latest
74+
needs: [test]
75+
strategy:
76+
matrix:
77+
include:
78+
- codecov_url_secret: CODECOV_URL
79+
codecov_token_secret: CODECOV_ORG_TOKEN
80+
name: prod
81+
- codecov_url_secret: CODECOV_STAGING_URL
82+
codecov_token_secret: CODECOV_ORG_TOKEN_STAGING
83+
name: staging
84+
- codecov_url_secret: CODECOV_QA_URL
85+
codecov_token_secret: CODECOV_QA_ORG
86+
name: qa
87+
- codecov_url_secret: CODECOV_PUBLIC_QA_URL
88+
codecov_token_secret: CODECOV_PUBLIC_QA_TOKEN
89+
name: public qa
90+
91+
steps:
92+
- name: Checkout
93+
uses: actions/checkout@v4
94+
with:
95+
fetch-depth: 0
96+
97+
- name: Download coverage
98+
uses: actions/download-artifact@v4
99+
with:
100+
name: coveragefiles
101+
102+
- name: Download test results
103+
uses: actions/download-artifact@v4
104+
with:
105+
name: junitfiles
106+
107+
- name: Uploading unit test coverage (${{ matrix.name }})
108+
uses: codecov/codecov-action@v5
109+
with:
110+
files: ./unit.coverage.xml
111+
flags: ${{ format('{0}unit', inputs.flag_prefix) }}
112+
disable_search: true
113+
token: ${{ secrets[matrix.codecov_token_secret] }}
114+
url: ${{ secrets[matrix.codecov_url_secret] }}
115+
116+
- name: Uploading integration test coverage (${{ matrix.name }})
117+
if: ${{ inputs.run_integration == true }}
118+
uses: codecov/codecov-action@v5
119+
with:
120+
files: ./integration.coverage.xml
121+
flags: ${{ format('{0}integration', inputs.flag_prefix) }}
122+
disable_search: true
123+
token: ${{ secrets[matrix.codecov_token_secret] }}
124+
url: ${{ secrets[matrix.codecov_url_secret] }}
125+
126+
- name: Uploading unit test results (${{ matrix.name }})
127+
uses: codecov/test-results-action@v1
128+
with:
129+
files: ./unit.junit.xml
130+
flags: ${{ format('{0}unit', inputs.flag_prefix) }}
131+
disable_search: true
132+
token: ${{ secrets[matrix.codecov_token_secret] }}
133+
url: ${{ secrets[matrix.codecov_url_secret] }}
134+
135+
- name: Uploading integration test results (${{ matrix.name }})
136+
if: ${{ inputs.run_integration == true }}
137+
uses: codecov/test-results-action@v1
80138
with:
81-
github-token: ${{ secrets.GITHUB_TOKEN }}
139+
files: ./integration.junit.xml
140+
flags: ${{ format('{0}integration', inputs.flag_prefix) }}
141+
disable_search: true
142+
token: ${{ secrets[matrix.codecov_token_secret] }}
143+
url: ${{ secrets[matrix.codecov_url_secret] }}

0 commit comments

Comments
 (0)