Skip to content

Commit d28a2e4

Browse files
authored
build: Upload stats data and coverage reports to staging (#61)
Regularly upload stats data for the example apps to staging, and upload coverage reports to staging.
1 parent 803897e commit d28a2e4

File tree

6 files changed

+121
-125
lines changed

6 files changed

+121
-125
lines changed

.changeset/grumpy-icons-hammer.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@codecov/bundler-plugin-core": patch
3+
"@codecov/rollup-plugin": patch
4+
"@codecov/vite-plugin": patch
5+
"@codecov/webpack-plugin": patch
6+
---
7+
8+
Break from retry loop when the response is ok

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const config = {
2929
],
3030
},
3131
rules: {
32+
"no-console": ["error"],
3233
"@typescript-eslint/no-unused-vars": [
3334
"error",
3435
{ argsIgnorePattern: "^_", destructuredArrayIgnorePattern: "^_" },

.github/workflows/ci.yml

Lines changed: 109 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,39 @@ 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+
146175
unit-test:
147176
name: Run Unit Tests
148177
runs-on: ubuntu-latest
149-
needs: install
178+
needs: [install, codecov-startup]
150179
steps:
151180
- name: Checkout
152181
uses: actions/checkout@v4
@@ -189,10 +218,22 @@ jobs:
189218
- name: Run unit tests
190219
run: pnpm run test:unit:ci --maxWorkers=2
191220

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+
192226
- name: Upload coverage reports to Codecov
193-
uses: codecov/codecov-action@v3
194-
env:
195-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
227+
## Don't upload on forks for now.
228+
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.
234+
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
196237
197238
integration-test:
198239
name: Run Integration Tests (Node ${{ matrix.node-version }})
@@ -201,10 +242,7 @@ jobs:
201242
strategy:
202243
fail-fast: false
203244
matrix:
204-
node-version: [
205-
"18.x",
206-
"20.x"
207-
]
245+
node-version: ["18.x", "20.x"]
208246
steps:
209247
- name: Checkout
210248
uses: actions/checkout@v4
@@ -246,3 +284,66 @@ jobs:
246284

247285
- name: Run e2e tests
248286
run: pnpm run test:e2e --maxWorkers=2
287+
288+
upload-stats-data-to-staging:
289+
name: Build and upload ${{ matrix.example }} stats data to staging
290+
runs-on: ubuntu-latest
291+
needs: [install, unit-test, integration-test]
292+
strategy:
293+
fail-fast: false
294+
matrix:
295+
example: ["next-js", "rollup", "vite", "webpack"]
296+
steps:
297+
- name: Checkout
298+
uses: actions/checkout@v4
299+
with:
300+
fetch-depth: 0
301+
302+
- name: Setup node
303+
uses: actions/setup-node@v3
304+
with:
305+
node-version: 18
306+
307+
- name: Install pnpm
308+
uses: pnpm/action-setup@v2
309+
with:
310+
version: 8
311+
run_install: false
312+
313+
- name: Get pnpm store directory
314+
shell: bash
315+
run: |
316+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
317+
318+
- name: Cache node_modules
319+
id: cache-node-modules
320+
uses: actions/cache@v3
321+
env:
322+
cache-name: cache-codecov-js-bundle-plugin-node-modules
323+
with:
324+
path: ${{ env.STORE_PATH }}
325+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
326+
restore-keys: |
327+
${{ runner.os }}-${{ env.cache-name }}-
328+
329+
- name: Install dependencies
330+
run: pnpm install
331+
332+
- name: Build plugins
333+
run: pnpm run build
334+
335+
- name: Install built plugins
336+
run: pnpm install
337+
338+
- name: Build ${{ matrix.example }} app
339+
working-directory: ./examples/${{ matrix.example }}
340+
env:
341+
NEXT_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }}
342+
NEXT_API_URL: ${{ secrets.CODECOV_STAGING_API_URL }}
343+
ROLLUP_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }}
344+
ROLLUP_API_URL: ${{ secrets.CODECOV_STAGING_API_URL }}
345+
VITE_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }}
346+
VITE_API_URL: ${{ secrets.CODECOV_STAGING_API_URL }}
347+
WEBPACK_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }}
348+
WEBPACK_API_URL: ${{ secrets.CODECOV_STAGING_API_URL }}
349+
run: pnpm run build

.github/workflows/upload_example_stats.yml

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

packages/bundler-plugin-core/src/utils/fetchWithRetry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const fetchWithRetry = async ({
2727
if (!response.ok) {
2828
throw new BadResponseError("Response not ok");
2929
}
30+
break;
3031
} catch (err) {
3132
debug(`${name} fetch attempt ${i} failed`);
3233
const isLastAttempt = i + 1 === retryCount;
@@ -35,7 +36,6 @@ export const fetchWithRetry = async ({
3536
red(`${name} failed after ${i} attempts`);
3637

3738
if (!(err instanceof BadResponseError)) {
38-
console.debug("ahh");
3939
throw err;
4040
}
4141
return response;

packages/bundler-plugin-core/src/utils/logging.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export function prepareMessage(msg: unknown): string {
1111
}
1212

1313
export function l(msg: string): void {
14+
// Required to properly log to the console
15+
// eslint-disable-next-line no-console
1416
console.log(msg);
1517
}
1618

0 commit comments

Comments
 (0)