Skip to content

Commit 539b65e

Browse files
build: use codecov actions instead of CLI to upload coverage and test results (#88)
1 parent 17773f5 commit 539b65e

File tree

6 files changed

+75
-52
lines changed

6 files changed

+75
-52
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -143,39 +143,10 @@ jobs:
143143
- name: Run TSC
144144
run: pnpm run type-check
145145

146-
codecov-startup:
147-
name: Codecov Startup
148-
runs-on: ubuntu-latest
149-
needs: install
150-
steps:
151-
- name: Checkout
152-
uses: actions/checkout@v4
153-
with:
154-
fetch-depth: 2
155-
156-
- name: Install CLI
157-
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
158-
run: |
159-
pip install --no-cache-dir codecov-cli
160-
161-
- name: Run Startup
162-
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
163-
env:
164-
CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
165-
run: |
166-
codecovcli -u ${{ secrets.CODECOV_URL }} create-commit --fail-on-error
167-
codecovcli -u ${{ secrets.CODECOV_URL }} create-report --fail-on-error
168-
169-
- name: Run Startup Staging
170-
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
171-
run: |
172-
codecovcli -u ${{ secrets.CODECOV_STAGING_URL }} create-commit -t ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} --fail-on-error
173-
codecovcli -u ${{ secrets.CODECOV_STAGING_URL }} create-report -t ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} --fail-on-error
174-
175146
unit-test:
176147
name: Run Unit Tests
177148
runs-on: ubuntu-latest
178-
needs: [install, codecov-startup]
149+
needs: [install]
179150
steps:
180151
- name: Checkout
181152
uses: actions/checkout@v4
@@ -218,22 +189,33 @@ jobs:
218189
- name: Run unit tests
219190
run: pnpm run test:unit:ci --maxWorkers=2
220191

221-
- name: Install CLI
222-
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
223-
run: |
224-
pip install --no-cache-dir codecov-cli
225-
226-
- name: Upload coverage reports to Codecov
227-
## Don't upload on forks for now.
192+
- name: Upload coverage reports to codecov
228193
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
229-
run: |
230-
codecovcli -u ${{ secrets.CODECOV_URL }} do-upload -t ${{ secrets.CODECOV_ORG_TOKEN }} --fail-on-error
231-
232-
- name: Upload coverage reports to Codecov staging
233-
## Don't upload on forks for now.
194+
uses: codecov/codecov-action@v4
195+
with:
196+
token: ${{ secrets.CODECOV_ORG_TOKEN }}
197+
url: ${{ secrets.CODECOV_URL }}
198+
199+
- name: Upload coverage reports to codecov (Staging)
234200
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
235-
run: |
236-
codecovcli -u ${{ secrets.CODECOV_STAGING_URL }} do-upload -t ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} --fail-on-error
201+
uses: codecov/codecov-action@v4
202+
with:
203+
token: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }}
204+
url: ${{ secrets.CODECOV_STAGING_URL }}
205+
206+
- name: Upload test result reports to codecov
207+
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
208+
uses: codecov/test-results-action@v1
209+
with:
210+
token: ${{ secrets.CODECOV_ORG_TOKEN }}
211+
url: ${{ secrets.CODECOV_URL }}
212+
213+
- name: Upload test result reports to codecov (Staging)
214+
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
215+
uses: codecov/test-results-action@v1
216+
with:
217+
token: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }}
218+
url: ${{ secrets.CODECOV_STAGING_URL }}
237219

238220
integration-test:
239221
name: Run Integration Tests (Node ${{ matrix.node-version }})

packages/bundler-plugin-core/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"format": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --write",
3434
"format:check": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --check",
3535
"test:unit": "jest",
36-
"test:unit:ci": "jest --coverage"
36+
"test:unit:ci": "JEST_JUNIT_OUTPUT_NAME='bundler-plugin-core.junit.xml' jest --coverage --reporters=jest-junit"
3737
},
3838
"dependencies": {
3939
"chalk": "4.1.2",
@@ -47,9 +47,10 @@
4747
"@types/jest": "^29.5.11",
4848
"@types/node": "^20.11.15",
4949
"@types/semver": "^7.5.6",
50+
"codecovProdRollupPlugin": "npm:@codecov/[email protected]",
5051
"jest": "^29.7.0",
52+
"jest-junit": "^16.0.0",
5153
"msw": "^2.1.5",
52-
"codecovProdRollupPlugin": "npm:@codecov/[email protected]",
5354
"testdouble": "^3.20.1",
5455
"testdouble-jest": "^2.0.0",
5556
"ts-node": "^10.9.2",

packages/rollup-plugin/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"format": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --write",
4040
"format:check": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --check",
4141
"test:unit": "jest",
42-
"test:unit:ci": "jest --coverage"
42+
"test:unit:ci": "JEST_JUNIT_OUTPUT_NAME='rollup-plugin.junit.xml' jest --coverage --reporters=jest-junit"
4343
},
4444
"dependencies": {
4545
"@codecov/bundler-plugin-core": "workspace:^"
@@ -49,9 +49,10 @@
4949
"@swc/jest": "^0.2.33",
5050
"@types/jest": "^29.5.11",
5151
"@types/node": "^20.11.15",
52+
"codecovProdRollupPlugin": "npm:@codecov/[email protected]",
5253
"jest": "^29.7.0",
54+
"jest-junit": "^16.0.0",
5355
"msw": "^2.1.5",
54-
"codecovProdRollupPlugin": "npm:@codecov/[email protected]",
5556
"rollup": "4.9.6",
5657
"ts-node": "^10.9.2",
5758
"typescript": "^5.3.3",

packages/vite-plugin/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"format": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --write",
4040
"format:check": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --check",
4141
"test:unit": "jest",
42-
"test:unit:ci": "jest --coverage"
42+
"test:unit:ci": "JEST_JUNIT_OUTPUT_NAME='vite-plugin.junit.xml' jest --coverage --reporters=jest-junit"
4343
},
4444
"dependencies": {
4545
"@codecov/bundler-plugin-core": "workspace:^"
@@ -49,9 +49,10 @@
4949
"@swc/jest": "^0.2.33",
5050
"@types/jest": "^29.5.11",
5151
"@types/node": "^20.11.15",
52+
"codecovProdRollupPlugin": "npm:@codecov/[email protected]",
5253
"jest": "^29.7.0",
54+
"jest-junit": "^16.0.0",
5355
"msw": "^2.1.5",
54-
"codecovProdRollupPlugin": "npm:@codecov/[email protected]",
5556
"ts-node": "^10.9.2",
5657
"typescript": "^5.3.3",
5758
"unbuild": "^2.0.0",

packages/webpack-plugin/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"format": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --write",
4040
"format:check": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --check",
4141
"test:unit": "jest",
42-
"test:unit:ci": "jest --coverage"
42+
"test:unit:ci": "JEST_JUNIT_OUTPUT_NAME='webpack-plugin.junit.xml' jest --coverage --reporters=jest-junit"
4343
},
4444
"dependencies": {
4545
"@codecov/bundler-plugin-core": "workspace:^"
@@ -50,9 +50,10 @@
5050
"@types/jest": "^29.5.11",
5151
"@types/node": "^20.10.0",
5252
"@types/webpack": "^5.28.5",
53+
"codecovProdRollupPlugin": "npm:@codecov/[email protected]",
5354
"jest": "^29.7.0",
55+
"jest-junit": "^16.0.0",
5456
"msw": "^2.1.5",
55-
"codecovProdRollupPlugin": "npm:@codecov/[email protected]",
5657
"ts-node": "^10.9.2",
5758
"typescript": "^5.3.3",
5859
"unbuild": "^2.0.0",

pnpm-lock.yaml

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)