Skip to content

Commit

Permalink
Add as a weekly job
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Mar 18, 2022
1 parent 23004ca commit ea8000b
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 47 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/bundler-friendly.yml
@@ -0,0 +1,61 @@
name: Bundler_Friendly

on:
schedule:
# “At 00:00 on Sunday.” https://crontab.guru/#0%C2%A00%C2%A0*%C2%A0*%C2%A00
- cron: "0 0 * * 0"
pull_request:
paths:
# This workflow file
- ".github/workflows/bundler-friendly.yml"

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
cache: "yarn"

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Build Package
run: yarn build

- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: dist
path: dist

webpack:
name: Bundle Prettier with webpack
runs-on: ubuntu-latest
needs: [build]
defaults:
run:
working-directory: scripts/tools/bundle-prettier-with-webpack-test
steps:
- name: Checkout
uses: actions/checkout@v2.4.0

- name: Setup Node.js
uses: actions/setup-node@v2.5.1

- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: dist
path: dist

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Test
run: yarn test
6 changes: 4 additions & 2 deletions .github/workflows/dev-package-test.yml
Expand Up @@ -2,12 +2,14 @@ name: Dev_Package_Test

on:
schedule:
- cron: "0 0 * * 1"
# “At 00:00 on Sunday.” https://crontab.guru/#0%C2%A00%C2%A0*%C2%A0*%C2%A00
- cron: "0 0 * * 0"
pull_request:
paths:
- "package.json"
- ".github/workflows/dev-package-test.yml"
- "yarn.lock"
# This workflow file
- ".github/workflows/dev-package-test.yml"

jobs:
test:
Expand Down
26 changes: 0 additions & 26 deletions .github/workflows/prod-test.yml
Expand Up @@ -169,29 +169,3 @@ jobs:

- name: Run CLI on Node.js v0.10.48
run: node dist/bin-prettier --version 2>&1 >/dev/null | grep "prettier requires at least version 10.13.0 of Node, please upgrade" || exit 1

webpack-friendly:
name: Bundle Prettier with webpack
runs-on: ubuntu-latest
needs: [build]
defaults:
run:
working-directory: scripts/tools/bundle-prettier-with-webpack-test
steps:
- name: Checkout
uses: actions/checkout@v2.4.0

- name: Setup Node.js
uses: actions/setup-node@v2.5.1

- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: dist
path: dist

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Test
run: yarn test
58 changes: 39 additions & 19 deletions scripts/tools/bundle-prettier-with-webpack-test/index.js
@@ -1,6 +1,7 @@
import { fileURLToPath } from "node:url";
import path from "node:path";
import crypto from "node:crypto";
import fs from "node:fs/promises";
import webpack from "webpack";
import { DIST_DIR } from "../../../scripts/utils/index.mjs";

Expand Down Expand Up @@ -32,24 +33,43 @@ const TEMPORARY_DIRECTORY = fileURLToPath(new URL("./.tmp", import.meta.url));

/* `require` in `parser-typescript.js`, #12338 */
(async () => {
const PROBLEMATIC_WARNING_MESSAGE =
"Critical dependency: require function is used in a way in which dependencies cannot be statically extracted";

const stats = await runWebpack({
mode: "production",
entry: path.join(DIST_DIR, "parser-typescript.js"),
output: {
path: TEMPORARY_DIRECTORY,
filename: getRandomFileName("output"),
},
});
const result = stats.toJson();
const { warnings } = result;
const error = warnings.find(
({ message }) => message === PROBLEMATIC_WARNING_MESSAGE
);
if (error) {
console.error(error);
throw new Error("Unexpected webpack warning.");
const files = await fs.readdir(DIST_DIR);
for (const file of files) {
if (
!(
file.startsWith("parser-") ||
file === "standalone.js" ||
file === "doc.js"
)
) {
continue;
}

console.log(`Testing ${file}: `);

const stats = await runWebpack({
mode: "production",
entry: path.join(DIST_DIR, file),
output: {
path: TEMPORARY_DIRECTORY,
filename: getRandomFileName(file),
},
});
const result = stats.toJson();
const warnings = result.warnings.filter(
({ message }) =>
!(
message.startsWith("entrypoint size limit:") ||
message.startsWith("asset size limit:") ||
message.startsWith("webpack performance recommendations:")
)
);

if (warnings.length > 0) {
console.log(warnings);
throw new Error("Unexpected webpack warning.");
}

console.log("Passed.");
}
})();

0 comments on commit ea8000b

Please sign in to comment.