Skip to content

Commit

Permalink
Merge pull request #14341 from artsy/DIA-793-generate-bundle-size-rep…
Browse files Browse the repository at this point in the history
…ort-for-pull-requests

feat: adds relative-ci agent
  • Loading branch information
dzucconi authored Aug 16, 2024
2 parents f33f232 + 859f1ef commit ea59206
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 13 deletions.
18 changes: 18 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,17 @@ jobs:
- store_artifacts:
path: cypress/screenshots

bundle-stats:
docker:
- image: 585031190124.dkr.ecr.us-east-1.amazonaws.com/force:$CIRCLE_SHA1-builder
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
working_directory: /app
steps:
- run: yarn bundle-report:client --json webpack-stats.json
- run: npx relative-ci-agent

not_main_or_staging_or_release: &not_main_or_staging_or_release
filters:
branches:
Expand Down Expand Up @@ -330,6 +341,12 @@ workflows:
requires:
- electron-runner-image-push

- bundle-stats:
<<: *not_staging_or_release
context: hokusai
requires:
- builder-image-push

# Staging
- artsy-remote-docker/buildkit-build:
<<: *only_main
Expand All @@ -349,6 +366,7 @@ workflows:
- type-check
- relay-check
- acceptance
- bundle-stats
- production-image-build

- hokusai/deploy-staging:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Webpack stats
stats*.json
webpack-stats.json

# DLL
manifest-legacy-artwork-dll.json
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ COPY data ./data
COPY patches ./patches
COPY src ./src
COPY webpack ./webpack
COPY .git ./.git
COPY .env.oss \
.env.test \
.eslintrc.js \
Expand All @@ -118,6 +119,7 @@ COPY .env.oss \
jest.config.js \
package.json \
relay.config.js \
relativeci.config.js \
tsconfig.json \
yarn.lock \
./
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
"@loadable/babel-plugin": "5.13.2",
"@loadable/webpack-plugin": "5.15.2",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
"@relative-ci/agent": "^4.2.10",
"@storybook/addon-actions": "6.5.13",
"@storybook/addon-essentials": "6.5.13",
"@storybook/addon-links": "6.5.13",
Expand Down
11 changes: 11 additions & 0 deletions relativeci.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
// Get current commit message (`git log -1 --pretty=%B`) and send it to RelativeCI as part of the build informatin
includeCommitMessage: true,
// Save agent payload to disk for debugging
// @example './relative-ci-payload.json',
payloadFilepath: undefined,
webpack: {
// Path to Webpack stats JSON file
stats: "./webpack-stats.json",
},
}
13 changes: 9 additions & 4 deletions webpack/envs/clientProductionConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import HtmlWebpackPlugin from "html-webpack-plugin"
import LoadablePlugin from "@loadable/webpack-plugin"
import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer"
import { WebpackManifestPlugin } from "webpack-manifest-plugin"
import { basePath, webpackEnv } from "../webpackEnv"
import { basePath } from "../webpackEnv"
import { sharedPlugins } from "../sharedPlugins"
import { splitChunks } from "../bundleSplitting"

import { babelLoader, ejsLoader, mjsLoader } from "../sharedLoaders"

import {
Expand Down Expand Up @@ -43,10 +42,18 @@ const clientProductionConfig = () => {
path: path.resolve(basePath, "public/assets"),
publicPath: "/assets/",
},
stats: process.env.RELATIVE_CI_KEY
? {
assets: true,
chunks: true,
modules: true,
}
: stats,
plugins: [
...sharedPlugins(),
new LoadablePlugin({
filename: "loadable-stats.json",
// @ts-ignore
path: path.resolve(basePath, "public", "assets"),
}),
new WebpackManifestPlugin({
Expand All @@ -63,15 +70,13 @@ const clientProductionConfig = () => {
},
template: path.resolve(basePath, "src/html.ejs"),
}),

process.env.WEBPACK_BUNDLE_REPORT &&
new BundleAnalyzerPlugin({
analyzerMode: "static",
defaultSizes: "gzip",
}),
].filter(Boolean),
resolve,
stats,
}
}

Expand Down
Loading

0 comments on commit ea59206

Please sign in to comment.