Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into add-sentry-to-yari
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMcA committed Sep 18, 2024
2 parents bfff095 + 1b3a718 commit 8935b60
Show file tree
Hide file tree
Showing 43 changed files with 1,587 additions and 1,274 deletions.
100 changes: 100 additions & 0 deletions .github/workflows/pr-bundlesize-compare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Compare bundle size

on:
pull_request:

jobs:
# Build current and upload stats.json
build-head:
name: "Build head"
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: yarn

- name: Cache @vscode/ripgrep bin
uses: actions/cache@v4
with:
key: vscode-ripgrep-bin-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('yarn.lock') }}
path: node_modules/@vscode/ripgrep/bin/

- name: Install all yarn packages
run: yarn --frozen-lockfile
env:
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build
run: yarn build:client
env:
ANALYZE_BUNDLE_PR: true

- name: Upload stats.json
uses: actions/upload-artifact@v4
with:
name: head-stats
path: ./client/build/stats.json

# Build base for comparison and upload stats.json
build-base:
name: "Build base"
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: yarn

- name: Cache @vscode/ripgrep bin
uses: actions/cache@v4
with:
key: vscode-ripgrep-bin-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('yarn.lock') }}
path: node_modules/@vscode/ripgrep/bin/

- name: Install all yarn packages
run: yarn --frozen-lockfile
env:
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build
run: yarn build:client
env:
ANALYZE_BUNDLE_PR: true

- name: Upload stats.json
uses: actions/upload-artifact@v4
with:
name: base-stats
path: ./client/build/stats.json

# run the action against the stats.json files
compare:
name: "Compare base & head bundle sizes"
runs-on: ubuntu-latest
needs: [build-base, build-head]
permissions:
pull-requests: write
steps:
- uses: actions/download-artifact@v4
- uses: github/webpack-bundlesize-compare-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
current-stats-json-path: ./head-stats/stats.json
base-stats-json-path: ./base-stats/stats.json
4 changes: 3 additions & 1 deletion .github/workflows/prod-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ jobs:
- name: Deploy Function
if: ${{ ! vars.SKIP_FUNCTION }}
run: |-
set -eo pipefail
for region in europe-west1 us-west1 asia-east1; do
gcloud beta functions deploy mdn-prod-prod-$region \
--gen2 \
Expand All @@ -371,7 +373,7 @@ jobs:
--set-env-vars="ORIGIN_PLAY=mdnplay.dev" \
--set-env-vars="SOURCE_CONTENT=https://storage.googleapis.com/${{ vars.GCP_BUCKET_NAME }}/main/" \
--set-env-vars="SOURCE_API=https://api.developer.mozilla.org/" \
--set-env-vars="ORIGIN_TRIAL_TOKEN=A9YWJd0eN0+JyqsF5/4sYlFePcOgkAIKtGSnrERJ7zmzK65fqcrdYjmHUlxAV79Fphmwt96Gkyw2F1WmMEUEztgAAABdeyJvcmlnaW4iOiJodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZyIsImZlYXR1cmUiOiJQcml2YXRlQXR0cmlidXRpb24iLCJleHBpcnkiOjE3NDk3NDMyNjF9" \
--set-env-vars="ORIGIN_TRIAL_TOKEN=AxVILwizhbMjxFeHOn1P3R8niO1RJY/smaK4B4d1rLzc1gTaxtXMSaTi+FoigYgCw40uFRDwFcEAeqDR+vVLOW4AAABfeyJvcmlnaW4iOiJodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZyIsImZlYXR1cmUiOiJQcml2YXRlQXR0cmlidXRpb25WMiIsImV4cGlyeSI6MTc0MjA3OTYwMH0=" \
--set-env-vars="BSA_ENABLED=true" \
--set-env-vars="SENTRY_DSN=${{ secrets.SENTRY_DSN_CLOUD_FUNCTION }}" \
--set-env-vars="SENTRY_ENVIRONMENT=prod" \
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/stage-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ jobs:
- name: Deploy Function
if: ${{ ! vars.SKIP_FUNCTION }}
run: |-
set -eo pipefail
for region in europe-west1 us-west1 asia-east1; do
gcloud beta functions deploy mdn-nonprod-stage-$region \
--gen2 \
Expand All @@ -387,7 +389,7 @@ jobs:
--set-env-vars="ORIGIN_PLAY=mdnyalp.dev" \
--set-env-vars="SOURCE_CONTENT=https://storage.googleapis.com/${{ vars.GCP_BUCKET_NAME }}/main/" \
--set-env-vars="SOURCE_API=https://api.developer.allizom.org/" \
--set-env-vars="ORIGIN_TRIAL_TOKEN=A708kbzhofFLGMe7BHKr3aym5saxaywBDqhAzxv4vU9sM6B49iYwec+xy2Y3Imt0+nhR03/jmbuNY0BRvM+Ng5cAAABdeyJvcmlnaW4iOiJodHRwczovL2RldmVsb3Blci5hbGxpem9tLm9yZyIsImZlYXR1cmUiOiJQcml2YXRlQXR0cmlidXRpb24iLCJleHBpcnkiOjE3NDk3NDMzMDB9" \
--set-env-vars="ORIGIN_TRIAL_TOKEN=AwIRl96ZjeFFEsdas+GXmpHvd3ARcQPYgBIGhQzZtyG9PpESvUi8ea4gpiQq9QsYRsVAWBeeBgBYqp/oLQPna0YAAABfeyJvcmlnaW4iOiJodHRwczovL2RldmVsb3Blci5hbGxpem9tLm9yZyIsImZlYXR1cmUiOiJQcml2YXRlQXR0cmlidXRpb25WMiIsImV4cGlyeSI6MTc0MjA3OTYwMH0=" \
--set-env-vars="BSA_ENABLED=true" \
--set-env-vars="SENTRY_DSN=${{ secrets.SENTRY_DSN_CLOUD_FUNCTION }}" \
--set-env-vars="SENTRY_ENVIRONMENT=stage" \
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ jobs:
- name: Deploy Function
if: ${{ ! vars.SKIP_FUNCTION }}
run: |-
set -eo pipefail
for region in europe-west3; do
gcloud beta functions deploy mdn-nonprod-test-$region \
--gen2 \
Expand All @@ -270,13 +272,15 @@ jobs:
--set-env-vars="ORIGIN_PLAY=test.mdnyalp.dev" \
--set-env-vars="SOURCE_CONTENT=https://storage.googleapis.com/${{ vars.GCP_BUCKET_NAME }}/main/" \
--set-env-vars="SOURCE_API=https://api.developer.allizom.org/" \
--set-env-vars="BSA_ENABLED=true" \
--set-env-vars="SENTRY_DSN=${{ secrets.SENTRY_DSN_CLOUD_FUNCTION }}" \
--set-env-vars="SENTRY_ENVIRONMENT=test" \
--set-env-vars="SENTRY_TRACES_SAMPLE_RATE=${{ vars.SENTRY_TRACES_SAMPLE_RATE }}" \
--set-env-vars="SENTRY_RELEASE=${{ github.sha }}" \
--set-secrets="KEVEL_SITE_ID=projects/${{ secrets.GCP_PROJECT_NAME }}/secrets/stage-kevel-site-id/versions/latest" \
--set-secrets="KEVEL_NETWORK_ID=projects/${{ secrets.GCP_PROJECT_NAME }}/secrets/stage-kevel-network-id/versions/latest" \
--set-secrets="SIGN_SECRET=projects/${{ secrets.GCP_PROJECT_NAME }}/secrets/stage-sign-secret/versions/latest" \
--set-secrets="BSA_ZONE_KEYS=projects/${{ secrets.GCP_PROJECT_NAME }}/secrets/stage-bsa-zone-keys/versions/latest" \
2>&1 | sed "s/^/[$region] /" &
pids+=($!)
done
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ yarn-error.log*
/server/*.js
/server/*.js.map
/ssr/dist/
/ssr/*.js
!/ssr/mozilla.dnthelper.min.js
!/ssr/webpack.config.js
/ssr/*.js.map
/tool/*.js
/tool/*.js.map
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.63.0"
".": "2.63.1"
}
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
# Changelog

## [2.63.1](https://github.com/mdn/yari/compare/v2.63.0...v2.63.1) (2024-09-16)


### Bug Fixes

* **build:** use pipefail to fail function deployments ([#11806](https://github.com/mdn/yari/issues/11806)) ([5141019](https://github.com/mdn/yari/commit/5141019b54e24d8df6db8619dd1585c8fb1a7587))
* **placement:** use variable for horizontal banner ([#11795](https://github.com/mdn/yari/issues/11795)) ([d880aaf](https://github.com/mdn/yari/commit/d880aaf8116f1fe692452f68107e173d042e5cb9))
* **sidebar:** reuse icon margin for non-nested entries ([#11786](https://github.com/mdn/yari/issues/11786)) ([2294df0](https://github.com/mdn/yari/commit/2294df00ba8be26bf0767b78c02a0abad5c7894e))


### Enhancements

* **ad-free:** hide all banners completely ([#11787](https://github.com/mdn/yari/issues/11787)) ([f93b850](https://github.com/mdn/yari/commit/f93b85005b8f921e9f27266d02750af0363e1d06))


### Miscellaneous

* **deps-dev:** bump @playwright/test from 1.47.0 to 1.47.1 ([#11812](https://github.com/mdn/yari/issues/11812)) ([8e698db](https://github.com/mdn/yari/commit/8e698db7231a8ce0f87630bc50f19667b0deb136))
* **deps-dev:** bump @swc/core from 1.7.24 to 1.7.25 ([#11791](https://github.com/mdn/yari/issues/11791)) ([0e30971](https://github.com/mdn/yari/commit/0e309719d5193d4dcc193cfd997dbd591475e590))
* **deps-dev:** bump @swc/core from 1.7.25 to 1.7.26 ([#11793](https://github.com/mdn/yari/issues/11793)) ([51c07ba](https://github.com/mdn/yari/commit/51c07ba14af4d142b9ea16315a92fe65e35999c8))
* **deps-dev:** bump @types/jest from 29.5.12 to 29.5.13 in the types group ([#11801](https://github.com/mdn/yari/issues/11801)) ([fc79d49](https://github.com/mdn/yari/commit/fc79d49564ba9bbb0fb7edff63c77947532e97d1))
* **deps-dev:** bump @types/react from 18.3.5 to 18.3.6 in the types group ([#11808](https://github.com/mdn/yari/issues/11808)) ([9baf777](https://github.com/mdn/yari/commit/9baf777611cf9f3f7c0f65e5ece25d577290e856))
* **deps-dev:** bump babel-loader from 9.1.3 to 9.2.0 ([#11811](https://github.com/mdn/yari/issues/11811)) ([fc35868](https://github.com/mdn/yari/commit/fc3586803901ea4d3a3fc66d0b6c18e57d025545))
* **deps-dev:** bump eslint-plugin-react from 7.35.2 to 7.36.1 ([#11805](https://github.com/mdn/yari/issues/11805)) ([35fc136](https://github.com/mdn/yari/commit/35fc1362f82b1d6bea60d4a0225cf4e34d5fa6a1))
* **deps-dev:** bump husky from 9.1.5 to 9.1.6 ([#11798](https://github.com/mdn/yari/issues/11798)) ([b3288e0](https://github.com/mdn/yari/commit/b3288e016c54fa41faac200e6a78be00f74509a0))
* **deps-dev:** bump postcss from 8.4.45 to 8.4.47 ([#11810](https://github.com/mdn/yari/issues/11810)) ([2497484](https://github.com/mdn/yari/commit/2497484c5e94efaf9186940e28b84e3453459d05))
* **deps-dev:** bump the types group across 1 directory with 2 updates ([#11743](https://github.com/mdn/yari/issues/11743)) ([a38975e](https://github.com/mdn/yari/commit/a38975ece5e7b4cf588964ea15b1abdb19b8c69b))
* **deps:** bump express from 4.20.0 to 4.21.0 ([#11796](https://github.com/mdn/yari/issues/11796)) ([90e5231](https://github.com/mdn/yari/commit/90e5231100588a6a65073ff1946d05fff02ab33e))
* **deps:** bump mdn-data from 2.11.0 to 2.11.1 ([#11802](https://github.com/mdn/yari/issues/11802)) ([16d9403](https://github.com/mdn/yari/commit/16d9403db82e6bb4cfa7e94e7fb36f42ce98e4c5))
* **deps:** bump openai from 4.58.2 to 4.59.0 ([#11799](https://github.com/mdn/yari/issues/11799)) ([4877d5b](https://github.com/mdn/yari/commit/4877d5bf0dcd1c6baf6cbdeaa46f64d4e2c820ca))
* **deps:** bump openai from 4.59.0 to 4.60.0 ([#11804](https://github.com/mdn/yari/issues/11804)) ([dd1c110](https://github.com/mdn/yari/commit/dd1c11065374834c0ed4dd48f20fc0a3db9d7657))
* **deps:** bump openai from 4.60.0 to 4.61.0 ([#11809](https://github.com/mdn/yari/issues/11809)) ([bcc7727](https://github.com/mdn/yari/commit/bcc7727d0be0c3eb0abcbba2a256dd718d40b47f))
* **deps:** bump the dependencies group in /deployer with 2 updates ([#11807](https://github.com/mdn/yari/issues/11807)) ([0caaee1](https://github.com/mdn/yari/commit/0caaee198887ff226a9d9d10bb48d1e5d5b6564b))
* **deps:** bump web-features from 1.2.0 to 1.3.0 ([#11800](https://github.com/mdn/yari/issues/11800)) ([39e1574](https://github.com/mdn/yari/commit/39e1574b4a21e15bc287fcd5310755a7b2f7f015))
* **deps:** run npm audit fix in /cloud-function ([#11792](https://github.com/mdn/yari/issues/11792)) ([43b307f](https://github.com/mdn/yari/commit/43b307fe9c59ee3e16eecb16be943a8dfaad6d7d))
* **deps:** run yarn upgrade ([#11789](https://github.com/mdn/yari/issues/11789)) ([2777d58](https://github.com/mdn/yari/commit/2777d58faffad32ce25e479968306331cef3b001))
* **macros:** delete DOMAttributeMethods + unimplemented_inline macros ([#11790](https://github.com/mdn/yari/issues/11790)) ([e0b7616](https://github.com/mdn/yari/commit/e0b76166d13511d773ee67c397a058eb883bb278))
* **placement:** add scrimba discount ([#11785](https://github.com/mdn/yari/issues/11785)) ([ac157ff](https://github.com/mdn/yari/commit/ac157ff0a659e10b7fed6646d105e1ed90a7ea44))
* **tools-menu:** remove "New" indicator ([#11794](https://github.com/mdn/yari/issues/11794)) ([f2bca97](https://github.com/mdn/yari/commit/f2bca97057fe51e69fb2ada1e1360767d798b531))

## [2.63.0](https://github.com/mdn/yari/compare/v2.62.0...v2.63.0) (2024-09-10)


Expand Down
4 changes: 2 additions & 2 deletions build/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
postProcessSmallerHeadingIDs,
} from "./utils.js";
import { slugToFolder } from "../libs/slug-utils/index.js";
import { syntaxHighlight } from "./syntax-highlight.js";
import { wrapCodeExamples } from "./code-headers.js";
import { wrapTables } from "./wrap-tables.js";
import { Doc } from "../libs/types/document.js";
import { extractSections } from "./extract-sections.js";
Expand Down Expand Up @@ -391,7 +391,7 @@ export async function buildPost(
doc.hasMathML = true;
}
$("div.hidden").remove();
syntaxHighlight($, doc);
wrapCodeExamples($);
injectNoTranslate($);
injectLoadingLazyAttributes($);
postProcessExternalLinks($);
Expand Down
45 changes: 45 additions & 0 deletions build/code-headers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import * as cheerio from "cheerio";

// Over the years we have accumulated some weird <pre> tags whose
// brush is more or less "junk".
// TODO: Perhaps, if you have a doc with <pre> tags that matches
// this, it should become a flaw.
const IGNORE = new Set(["none", "text", "plain", "unix"]);

/**
* Mutate the `$` instance by adding headers to <pre> tags containing code blocks.
*
*/
export function wrapCodeExamples($: cheerio.CheerioAPI) {
// Our content will be like this: `<pre class="brush:js">` or
// `<pre class="brush: js">` so we're technically not looking for an exact
// match. The wildcard would technically match `<pre class="brushetta">`
// too. But within the loop, we do a more careful regex on the class name
// and only proceed if it's something sensible.
$("pre[class*=brush]").each((_, element) => {
// The language is whatever string comes after the `brush(:)`
// portion of the class name.
const $pre = $(element);

const className = $pre.attr("class").toLowerCase();
const match = className.match(/brush:?\s*([\w_-]+)/);
if (!match) {
return;
}
const name = match[1].replace("-nolint", "");
if (IGNORE.has(name)) {
// Seems to exist a couple of these in our docs. Just bail.
return;
}
const code = $pre.text();
$pre.wrapAll(`<div class='code-example'></div>`);
if (!$pre.hasClass("hidden")) {
$(
`<div class='example-header'><span class="language-name">${name}</span></div>`
).insertBefore($pre);
}
const $code = $("<code>").text(code);

$pre.empty().append($code);
});
}
4 changes: 2 additions & 2 deletions build/curriculum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { DocParent } from "../libs/types/document.js";
import { CURRICULUM_TITLE, DEFAULT_LOCALE } from "../libs/constants/index.js";
import * as kumascript from "../kumascript/index.js";
import LANGUAGES_RAW from "../libs/languages/index.js";
import { syntaxHighlight } from "./syntax-highlight.js";
import { wrapCodeExamples } from "./code-headers.js";
import {
escapeRegExp,
injectLoadingLazyAttributes,
Expand Down Expand Up @@ -321,7 +321,7 @@ export async function buildCurriculumPage(
doc.hasMathML = true;
}
$("div.hidden").remove();
syntaxHighlight($, doc);
wrapCodeExamples($);
injectNoTranslate($);
injectLoadingLazyAttributes($);
postProcessCurriculumLinks($, (p: string | undefined) => {
Expand Down
6 changes: 3 additions & 3 deletions build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from "./flaws/index.js";
import { checkImageReferences, checkImageWidths } from "./check-images.js";
import { getPageTitle } from "./page-title.js";
import { syntaxHighlight } from "./syntax-highlight.js";
import { wrapCodeExamples } from "./code-headers.js";
import { formatNotecards } from "./format-notecards.js";
import buildOptions from "./build-options.js";
import LANGUAGES_RAW from "../libs/languages/index.js";
Expand Down Expand Up @@ -459,8 +459,8 @@ export async function buildDocument(
plainHTML = $.html();
}

// Apply syntax highlighting all <pre> tags.
syntaxHighlight($, doc);
// Add headers to all <pre> tags with code.
wrapCodeExamples($);

// Post process HTML so that the right elements gets tagged so they
// *don't* get translated by tools like Google Translate.
Expand Down
Loading

0 comments on commit 8935b60

Please sign in to comment.