Skip to content

Commit 562ac0c

Browse files
authored
build: Setup example repos to send data to staging (#53)
Setup a workflow to upload example stats data to staging env.
1 parent 45a6890 commit 562ac0c

File tree

16 files changed

+521
-55
lines changed

16 files changed

+521
-55
lines changed

.changeset/pretty-ghosts-arrive.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@codecov/webpack-plugin": patch
3+
"@codecov/rollup-plugin": patch
4+
"@codecov/vite-plugin": patch
5+
"@codecov/bundler-plugin-core": patch
6+
---
7+
8+
Adjust peer dep versions to use x-range instead of caret

.github/workflows/ci.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -246,23 +246,3 @@ jobs:
246246

247247
- name: Run e2e tests
248248
run: pnpm run test:e2e --maxWorkers=2
249-
250-
251-
# fossa:
252-
# name: Run Fossa
253-
# runs-on: ubuntu-latest
254-
# needs: install
255-
# if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
256-
# steps:
257-
# - name: Checkout
258-
# uses: actions/checkout@v4
259-
260-
# - name: Setup Node
261-
# uses: actions/setup-node@v3
262-
# with:
263-
# node-version: '18.8.0'
264-
265-
# - name: Run Fossa
266-
# uses: fossas/fossa-action@v1.3.1
267-
# with:
268-
# api-key: ${{secrets.FOSSA_API_KEY}}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Upload Example Stats
2+
3+
# Temp only dispatch on manual dispatch
4+
on:
5+
workflow_dispatch:
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9+
10+
jobs:
11+
install:
12+
name: Install deps
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Setup node
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: 18
24+
25+
- name: Install pnpm
26+
uses: pnpm/action-setup@v2
27+
with:
28+
version: 8
29+
run_install: false
30+
31+
- name: Get pnpm store directory
32+
shell: bash
33+
run: |
34+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
35+
36+
- name: Cache node_modules
37+
id: cache-node-modules
38+
uses: actions/cache@v3
39+
env:
40+
cache-name: cache-codecov-js-bundle-plugin-node-modules
41+
with:
42+
path: ${{ env.STORE_PATH }}
43+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
44+
restore-keys: |
45+
${{ runner.os }}-${{ env.cache-name }}-
46+
47+
- name: Install dependencies
48+
run: pnpm install
49+
50+
build-and-upload-stats-data:
51+
name: Build and upload ${{ matrix.example }} stats data
52+
runs-on: ubuntu-latest
53+
needs: install
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
example: [
58+
"next-js",
59+
"rollup",
60+
"vite",
61+
"webpack",
62+
]
63+
steps:
64+
- name: Checkout
65+
uses: actions/checkout@v4
66+
with:
67+
fetch-depth: 0
68+
- name: Setup node
69+
uses: actions/setup-node@v3
70+
with:
71+
node-version: 18
72+
73+
- name: Install pnpm
74+
uses: pnpm/action-setup@v2
75+
with:
76+
version: 8
77+
run_install: false
78+
79+
- name: Get pnpm store directory
80+
shell: bash
81+
run: |
82+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
83+
84+
- name: Cache node_modules
85+
id: cache-node-modules
86+
uses: actions/cache@v3
87+
env:
88+
cache-name: cache-codecov-js-bundle-plugin-node-modules
89+
with:
90+
path: ${{ env.STORE_PATH }}
91+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
92+
restore-keys: |
93+
${{ runner.os }}-${{ env.cache-name }}-
94+
95+
- name: Install dependencies
96+
run: pnpm install
97+
98+
- name: Build plugins
99+
run: pnpm run build
100+
101+
- name: Install built plugins
102+
run: pnpm install
103+
104+
- name: Build ${{ matrix.example }} app
105+
working-directory: ./examples/${{ matrix.example }}
106+
env:
107+
NEXT_UPLOAD_TOKEN: ${{ env.CODECOV_ORG_TOKEN_STAGING }}
108+
NEXT_API_URL: ${{ env.CODECOV_STAGING_API_URL }}
109+
ROLLUP_UPLOAD_TOKEN: ${{ env.CODECOV_ORG_TOKEN_STAGING }}
110+
ROLLUP_API_URL: ${{ env.CODECOV_STAGING_API_URL }}
111+
VITE_UPLOAD_TOKEN: ${{ env.CODECOV_ORG_TOKEN_STAGING }}
112+
VITE_API_URL: ${{ env.CODECOV_STAGING_API_URL }}
113+
WEBPACK_UPLOAD_TOKEN: ${{ env.CODECOV_ORG_TOKEN_STAGING }}
114+
WEBPACK_API_URL: ${{ env.CODECOV_STAGING_API_URL }}
115+
run: pnpm run build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ yarn-debug.log*
66
yarn-error.log*
77
lerna-debug.log*
88
.pnpm-debug.log*
9+
local-upload.sh
910

1011
# Diagnostic reports (https://nodejs.org/api/report.html)
1112
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

examples/next-js/next.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ const { codecovWebpackPlugin } = require("@codecov/webpack-plugin");
44
const nextConfig = {
55
webpack: (config, options) => {
66
config.plugins.push(
7-
codecovWebpackPlugin({ enableBundleAnalysis: true, dryRun: true }),
7+
codecovWebpackPlugin({
8+
enableBundleAnalysis: true,
9+
bundleName: "example-next-app",
10+
uploadToken: process.env.NEXT_UPLOAD_TOKEN,
11+
apiUrl: process.env.NEXT_API_URL,
12+
}),
813
);
914

1015
return config;

examples/rollup/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"start": "serve public"
1010
},
1111
"dependencies": {
12-
"@codecov/rollup-plugin": "workspace:^",
1312
"date-fns": "^2.16.1"
1413
},
1514
"devDependencies": {
15+
"@codecov/rollup-plugin": "workspace:^",
1616
"@rollup/plugin-commonjs": "^17.0.0",
1717
"@rollup/plugin-node-resolve": "^11.1.0",
1818
"npm-run-all": "^4.1.5",

examples/rollup/rollup.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ export default defineConfig({
1919
resolve(), // tells Rollup how to find date-fns in node_modules
2020
commonjs(), // converts date-fns to ES modules
2121
production && terser(), // minify, but only in production
22-
codecovRollupPlugin({ enableBundleAnalysis: true, dryRun: true }),
22+
codecovRollupPlugin({
23+
enableBundleAnalysis: true,
24+
bundleName: "example-rollup-app",
25+
apiUrl: process.env.ROLLUP_API_URL,
26+
uploadToken: process.env.ROLLUP_UPLOAD_TOKEN,
27+
}),
2328
],
2429
});

examples/vite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"react-dom": "^18.2.0"
1515
},
1616
"devDependencies": {
17+
"@codecov/vite-plugin": "workspace:^",
1718
"@types/react": "^18.2.15",
1819
"@types/react-dom": "^18.2.7",
1920
"@typescript-eslint/eslint-plugin": "^6.0.0",
@@ -23,7 +24,6 @@
2324
"eslint-plugin-react-hooks": "^4.6.0",
2425
"eslint-plugin-react-refresh": "^0.4.3",
2526
"rollup": "^4.1.4",
26-
"@codecov/vite-plugin": "workspace:^",
2727
"typescript": "^5.0.2",
2828
"vite": "^4.4.5"
2929
},

examples/vite/vite.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ export default defineConfig({
1616
react(),
1717
codecovVitePlugin({
1818
enableBundleAnalysis: true,
19-
dryRun: true,
20-
globalUploadToken: "super-cool-token",
19+
bundleName: "example-vite-app",
20+
uploadToken: process.env.VITE_UPLOAD_TOKEN,
21+
apiUrl: process.env.VITE_API_URL,
2122
}),
2223
],
2324
});

examples/webpack/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
"scripts": {
66
"build": "webpack --config webpack.config.js"
77
},
8+
"dependencies": {
9+
"lodash": "^4.17.21"
10+
},
811
"devDependencies": {
12+
"@codecov/webpack-plugin": "workspace:^",
913
"webpack": "^5.89.0",
1014
"webpack-cli": "^5.1.4"
1115
},
12-
"dependencies": {
13-
"@codecov/webpack-plugin": "workspace:^",
14-
"lodash": "^4.17.21"
15-
},
1616
"engines": {
1717
"node": ">=18.0.0"
1818
},

0 commit comments

Comments
 (0)