Skip to content

Commit 09e062e

Browse files
authored
build: Add plugins to plugins (#83)
Use the plugins to analyze the plugins, also add in a dependabot config to check for the Codecov rollup plugin to update it when a new version is released.
1 parent da9b990 commit 09e062e

File tree

15 files changed

+235
-9
lines changed

15 files changed

+235
-9
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
4+
version: 2
5+
updates:
6+
- package-ecosystem: "npm" # See documentation for possible values
7+
directory: "/" # Location of package manifests
8+
schedule:
9+
interval: "daily"
10+
allow:
11+
- dependency-name: "@codecov/rollup-plugin"

.github/workflows/ci.yml

Lines changed: 132 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ jobs:
290290
- name: Run e2e tests
291291
run: pnpm run test:e2e
292292

293-
upload-build-stats-production:
294-
name: Build and upload ${{ matrix.example }} stats data to production
293+
upload-example-build-stats-production:
294+
name: Build and upload ${{ matrix.example }} example stats data to production
295295
runs-on: ubuntu-latest
296296
needs: [install, unit-test, integration-test]
297297
strategy:
@@ -340,7 +340,7 @@ jobs:
340340
- name: Install built plugins
341341
run: pnpm install
342342

343-
- name: Build ${{ matrix.example }} app for staging
343+
- name: Build ${{ matrix.example }} app for production
344344
working-directory: ./examples/${{ matrix.example }}
345345
env:
346346
NEXT_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
@@ -353,8 +353,8 @@ jobs:
353353
WEBPACK_API_URL: ${{ secrets.CODECOV_API_URL }}
354354
run: pnpm run build
355355

356-
upload-build-stats-staging:
357-
name: Build and upload ${{ matrix.example }} stats data to staging
356+
upload-example-build-stats-staging:
357+
name: Build and upload ${{ matrix.example }} example stats data to staging
358358
runs-on: ubuntu-latest
359359
needs: [install, unit-test, integration-test]
360360
strategy:
@@ -415,3 +415,130 @@ jobs:
415415
WEBPACK_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }}
416416
WEBPACK_API_URL: ${{ secrets.CODECOV_STAGING_API_URL }}
417417
run: pnpm run build
418+
419+
upldate-plugin-stats-production:
420+
name: Build and upload ${{ matrix.package }} stats data to production
421+
runs-on: ubuntu-latest
422+
needs: [install, unit-test, integration-test]
423+
strategy:
424+
fail-fast: false
425+
matrix:
426+
package:
427+
[
428+
"bundler-plugin-core",
429+
"rollup-plugin",
430+
"vite-plugin",
431+
"webpack-plugin",
432+
]
433+
steps:
434+
- name: Checkout
435+
uses: actions/checkout@v4
436+
with:
437+
fetch-depth: 0
438+
439+
- name: Setup node
440+
uses: actions/setup-node@v3
441+
with:
442+
node-version: 18
443+
444+
- name: Install pnpm
445+
uses: pnpm/action-setup@v2
446+
with:
447+
version: 8
448+
run_install: false
449+
450+
- name: Get pnpm store directory
451+
shell: bash
452+
run: |
453+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
454+
455+
- name: Cache node_modules
456+
id: cache-node-modules
457+
uses: actions/cache@v3
458+
env:
459+
cache-name: cache-codecov-js-bundle-plugin-node-modules
460+
with:
461+
path: ${{ env.STORE_PATH }}
462+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
463+
restore-keys: |
464+
${{ runner.os }}-${{ env.cache-name }}-
465+
466+
- name: Install dependencies
467+
run: pnpm install
468+
469+
- name: Build plugins
470+
run: pnpm run build
471+
472+
- name: Install plugins
473+
run: pnpm install
474+
475+
- name: Build ${{ matrix.package }} to collect stats for production
476+
working-directory: ./packages/${{ matrix.package }}
477+
env:
478+
PLUGIN_CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
479+
PLUGIN_CODECOV_API_URL: ${{ secrets.CODECOV_API_URL }}
480+
run: pnpm run build
481+
482+
483+
upldate-plugin-stats-staging:
484+
name: Build and upload ${{ matrix.package }} stats data to staging
485+
runs-on: ubuntu-latest
486+
needs: [install, unit-test, integration-test]
487+
strategy:
488+
fail-fast: false
489+
matrix:
490+
package:
491+
[
492+
"bundler-plugin-core",
493+
"rollup-plugin",
494+
"vite-plugin",
495+
"webpack-plugin",
496+
]
497+
steps:
498+
- name: Checkout
499+
uses: actions/checkout@v4
500+
with:
501+
fetch-depth: 0
502+
503+
- name: Setup node
504+
uses: actions/setup-node@v3
505+
with:
506+
node-version: 18
507+
508+
- name: Install pnpm
509+
uses: pnpm/action-setup@v2
510+
with:
511+
version: 8
512+
run_install: false
513+
514+
- name: Get pnpm store directory
515+
shell: bash
516+
run: |
517+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
518+
519+
- name: Cache node_modules
520+
id: cache-node-modules
521+
uses: actions/cache@v3
522+
env:
523+
cache-name: cache-codecov-js-bundle-plugin-node-modules
524+
with:
525+
path: ${{ env.STORE_PATH }}
526+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
527+
restore-keys: |
528+
${{ runner.os }}-${{ env.cache-name }}-
529+
530+
- name: Install dependencies
531+
run: pnpm install
532+
533+
- name: Build plugins
534+
run: pnpm run build
535+
536+
- name: Install plugins
537+
run: pnpm install
538+
539+
- name: Build ${{ matrix.package }} to collect stats for staging
540+
working-directory: ./packages/${{ matrix.package }}
541+
env:
542+
PLUGIN_CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }}
543+
PLUGIN_CODECOV_API_URL: ${{ secrets.CODECOV_STAGING_API_URL }}
544+
run: pnpm run build

examples/next-js/next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const nextConfig = {
66
config.plugins.push(
77
codecovWebpackPlugin({
88
enableBundleAnalysis: true,
9-
bundleName: "example-next-app",
9+
bundleName: "@codecov/example-next-app",
1010
uploadToken: process.env.NEXT_UPLOAD_TOKEN,
1111
apiUrl: process.env.NEXT_API_URL,
1212
}),

examples/rollup/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default defineConfig({
1919
commonjs(), // converts date-fns to ES modules
2020
codecovRollupPlugin({
2121
enableBundleAnalysis: true,
22-
bundleName: "example-rollup-app",
22+
bundleName: "@codecov/example-rollup-app",
2323
apiUrl: process.env.ROLLUP_API_URL,
2424
uploadToken: process.env.ROLLUP_UPLOAD_TOKEN,
2525
}),

examples/vite/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default defineConfig({
1616
react(),
1717
codecovVitePlugin({
1818
enableBundleAnalysis: true,
19-
bundleName: "example-vite-app",
19+
bundleName: "@codecov/example-vite-app",
2020
uploadToken: process.env.VITE_UPLOAD_TOKEN,
2121
apiUrl: process.env.VITE_API_URL,
2222
}),

examples/webpack/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = {
1111
plugins: [
1212
codecovWebpackPlugin({
1313
enableBundleAnalysis: true,
14-
bundleName: "example-webpack-app",
14+
bundleName: "@codecov/example-webpack-app",
1515
uploadToken: process.env.WEBPACK_UPLOAD_TOKEN,
1616
apiUrl: process.env.WEBPACK_API_URL,
1717
}),

packages/bundler-plugin-core/build.config.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { defineBuildConfig } from "unbuild";
2+
import { codecovRollupPlugin } from "codecovProdRollupPlugin";
23

34
export default defineBuildConfig({
45
entries: ["./src/index"],
@@ -16,4 +17,21 @@ export default defineBuildConfig({
1617
minify: true,
1718
},
1819
},
20+
hooks: {
21+
"rollup:options": (_ctx, opts) => {
22+
if (process.env.PLUGIN_CODECOV_TOKEN && Array.isArray(opts.plugins)) {
23+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
24+
opts.plugins = [
25+
...opts.plugins,
26+
codecovRollupPlugin({
27+
enableBundleAnalysis:
28+
typeof process.env.PLUGIN_CODECOV_TOKEN === "string",
29+
bundleName: "@codecov/bundler-plugin-core",
30+
uploadToken: process.env.PLUGIN_CODECOV_TOKEN,
31+
apiUrl: process.env.PLUGIN_CODECOV_API_URL,
32+
}),
33+
];
34+
}
35+
},
36+
},
1937
});

packages/bundler-plugin-core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"@types/semver": "^7.5.6",
5050
"jest": "^29.7.0",
5151
"msw": "^2.1.5",
52+
"codecovProdRollupPlugin": "npm:@codecov/rollup-plugin@0.0.1-beta.2",
5253
"testdouble": "^3.20.1",
5354
"testdouble-jest": "^2.0.0",
5455
"ts-node": "^10.9.2",

packages/rollup-plugin/build.config.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { defineBuildConfig } from "unbuild";
2+
import { codecovRollupPlugin } from "codecovProdRollupPlugin";
23

34
export default defineBuildConfig({
45
entries: ["./src/index"],
@@ -17,4 +18,21 @@ export default defineBuildConfig({
1718
minify: true,
1819
},
1920
},
21+
hooks: {
22+
"rollup:options": (_ctx, opts) => {
23+
if (process.env.PLUGIN_CODECOV_TOKEN && Array.isArray(opts.plugins)) {
24+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
25+
opts.plugins = [
26+
...opts.plugins,
27+
codecovRollupPlugin({
28+
enableBundleAnalysis:
29+
typeof process.env.PLUGIN_CODECOV_TOKEN === "string",
30+
bundleName: "@codecov/rollup-plugin",
31+
uploadToken: process.env.PLUGIN_CODECOV_TOKEN,
32+
apiUrl: process.env.PLUGIN_CODECOV_API_URL,
33+
}),
34+
];
35+
}
36+
},
37+
},
2038
});

packages/rollup-plugin/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"@types/node": "^20.11.15",
5252
"jest": "^29.7.0",
5353
"msw": "^2.1.5",
54+
"codecovProdRollupPlugin": "npm:@codecov/rollup-plugin@0.0.1-beta.2",
5455
"rollup": "4.9.6",
5556
"ts-node": "^10.9.2",
5657
"typescript": "^5.3.3",

0 commit comments

Comments
 (0)