-
Notifications
You must be signed in to change notification settings - Fork 22.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mdn:main' into branch-III
- Loading branch information
Showing
824 changed files
with
33,214 additions
and
2,973 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,14 +39,14 @@ jobs: | |
echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV | ||
- name: Checkout HEAD | ||
if: ${{ env.DIFF_DOCUMENTS }} | ||
if: env.DIFF_DOCUMENTS | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
path: pr_head | ||
|
||
- name: Get changed content from HEAD | ||
if: ${{ env.DIFF_DOCUMENTS }} | ||
if: env.DIFF_DOCUMENTS | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "mdn-bot" | ||
|
@@ -62,28 +62,36 @@ jobs: | |
git commit -m "Code from PR head" | ||
- name: Setup Node.js environment | ||
if: ${{ env.DIFF_DOCUMENTS }} | ||
if: env.DIFF_DOCUMENTS | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: ".nvmrc" | ||
cache: yarn | ||
|
||
- name: Install all yarn packages | ||
if: ${{ env.DIFF_DOCUMENTS }} | ||
if: env.DIFF_DOCUMENTS | ||
run: yarn --frozen-lockfile | ||
env: | ||
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Lint and format markdown files | ||
if: ${{ env.DIFF_DOCUMENTS }} | ||
if: env.DIFF_DOCUMENTS | ||
run: | | ||
# Generate random delimiter | ||
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings | ||
EOF="$(openssl rand -hex 8)" | ||
files_to_lint="$DIFF_DOCUMENTS" | ||
echo "crlf line ending check" | ||
CRLF_FAILED=true | ||
CRLF_LOG=$(git ls-files --eol ${files_to_lint} | grep -E 'w/(mixed|crlf)') || CRLF_FAILED=false | ||
echo "CRLF_LOG<<${EOF}" >> $GITHUB_ENV | ||
echo "${CRLF_LOG}" >> $GITHUB_ENV | ||
echo "${EOF}" >> $GITHUB_ENV | ||
echo "CRLF_FAILED=${CRLF_FAILED}" >> $GITHUB_ENV | ||
echo "Running markdownlint --fix" | ||
MD_LINT_FAILED=false | ||
MD_LINT_LOG=$(yarn markdownlint-cli2 --fix ${files_to_lint} 2>&1) || MD_LINT_FAILED=true | ||
|
@@ -101,15 +109,23 @@ jobs: | |
echo "FM_LINT_FAILED=${FM_LINT_FAILED}" >> $GITHUB_ENV | ||
echo "Running Prettier" | ||
PRETTIER_FAILED=false | ||
PRETTIER_LOG=$(yarn prettier --check ${files_to_lint} 2>&1) || PRETTIER_FAILED=true | ||
echo "PRETTIER_LOG<<${EOF}" >> $GITHUB_ENV | ||
echo "${PRETTIER_LOG}" >> $GITHUB_ENV | ||
echo "${EOF}" >> $GITHUB_ENV | ||
echo "PRETTIER_FAILED=${PRETTIER_FAILED}" >> $GITHUB_ENV | ||
yarn prettier -w ${files_to_lint} | ||
if [[ -n $(git diff) ]]; then | ||
echo "FILES_MODIFIED=true" >> $GITHUB_ENV | ||
fi | ||
# info for troubleshooting | ||
echo CRLF_FAILED=${CRLF_FAILED} | ||
echo MD_LINT_FAILED=${MD_LINT_FAILED} | ||
echo FM_LINT_FAILED=${FM_LINT_FAILED} | ||
echo PRETTIER_FAILED=${PRETTIER_FAILED} | ||
git diff | ||
- name: Setup reviewdog | ||
|
@@ -147,11 +163,40 @@ jobs: | |
-reporter="github-pr-review" | ||
- name: Fail if any issues pending | ||
if: env.FILES_MODIFIED == 'true' || env.MD_LINT_FAILED == 'true' || env.FM_LINT_FAILED == 'true' | ||
if: env.FILES_MODIFIED == 'true' || env.CRLF_FAILED == 'true' || env.MD_LINT_FAILED == 'true' || env.FM_LINT_FAILED == 'true' | ||
env: | ||
CRLF_FAILED: ${{ env.CRLF_FAILED }} | ||
MD_LINT_FAILED: ${{ env.MD_LINT_FAILED }} | ||
FM_LINT_FAILED: ${{ env.FM_LINT_FAILED }} | ||
PRETTIER_FAILED: ${{ env.PRETTIER_FAILED }} | ||
CRLF_LOG: ${{ env.CRLF_LOG }} | ||
MD_LINT_LOG: ${{ env.MD_LINT_LOG }} | ||
FM_LINT_LOG: ${{ env.FM_LINT_LOG }} | ||
PRETTIER_LOG: ${{ env.PRETTIER_LOG }} | ||
run: | | ||
echo -e "\nLogs from markdownlint:" | ||
echo "${MD_LINT_LOG}" | ||
echo -e "\nLogs from front-matter linter:" | ||
echo "${FM_LINT_LOG}" | ||
echo -e "\nPlease fix all the linting issues mentioned in above logs and in the review comments." | ||
echo -e "\nPlease fix all the linting issues mentioned in the following logs and in the PR review comments." | ||
if [[ ${CRLF_FAILED} == 'true' ]]; then | ||
echo -e "\n\n🪵 In the following files make sure all the lines end with only Line Feed (LF) character and not with Carriage Return Line Feed (CRLF) characters:" | ||
echo "${CRLF_LOG}" | ||
echo "For more information refer https://gist.github.com/LunarLambda/3df0840b336a5e314e4ffdac03cbf619 ." | ||
echo "You may use https://app.execeratics.com/LFandCRLFonline/?l=en online tool to convert line endings from CRLF to LF." | ||
fi | ||
if [[ ${MD_LINT_FAILED} == 'true' ]]; then | ||
echo -e "\n\n🪵 Logs from markdownlint:" | ||
echo "${MD_LINT_LOG}" | ||
fi | ||
if [[ ${FM_LINT_FAILED} == 'true' ]]; then | ||
echo -e "\n\n🪵 Logs from front-matter linter:" | ||
echo "${FM_LINT_LOG}" | ||
fi | ||
if [[ ${PRETTIER_FAILED} == 'true' ]]; then | ||
echo -e "\n\n🪵 Logs from Prettier formatter:" | ||
echo "${PRETTIER_LOG}" | ||
echo -e "\nYou can use Prettier playground to format the files online (configuration pre-filled): https://prettier.io/playground/#N4Igxg9gdgLgprEAuEBiABABwIYGd7owAWc6CMAlgE6kBmFANqSTSADQgSaXS7KjYqVCAHcACoIR8U2BiOwBPPhwBGVbGADWcGAGVsAWzgAZClDjIYVAK5xV6rTt04wZgOaWbdkLjgGKnrYccAAemHBUFEawsgAqEVCCFHDStLK+HLjuTACK1hDwyGkMGSAAVrghutlweQUWSMWlAI758GLCmNIgeAC05nAAJkPsIFbYjO4AwhAGBtjIPQwMo1lQbkwAgjBWFCrW7RGm5kXp3kQwBgwA6kQU8LgucLpS9xQAbvcKi2C4yiDvWwASSgw1gujAkW4m1BuhgCiYpxK3kwwl813UmEWqJSEXeFg4Zl8VBgHWwbnmSNKOCoxMW8yomkGoigo1RZhg1wog2IyAAHAAGDg0VrUOBkikLRpnDgwbAqLk8ojIABMHGsvli8tSMpAfhUQ2Gg2M2HW1nJcAAYhAqPMdu5FtgDhAQABfV1AA \n" | ||
fi | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,14 +7,14 @@ name: PR review companion | |
|
||
on: | ||
workflow_run: | ||
workflows: ["PR Test"] | ||
workflows: ["PR Test", "PR Test Legacy"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
review: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
if: github.event.workflow_run.conclusion == 'success' | ||
steps: | ||
- name: "Download artifact" | ||
uses: actions/download-artifact@v4 | ||
|
@@ -26,26 +26,26 @@ jobs: | |
run-id: ${{ github.event.workflow_run.id }} | ||
|
||
- name: Check for artifacts | ||
if: ${{ hashFiles('build/') != '' }} | ||
if: hashFiles('build/') != '' | ||
run: | | ||
echo "HAS_ARTIFACT=true" >> "$GITHUB_ENV" | ||
- uses: actions/checkout@v4 | ||
if: ${{ env.HAS_ARTIFACT }} | ||
if: env.HAS_ARTIFACT | ||
with: | ||
repository: mdn/yari | ||
path: yari | ||
|
||
- name: Install Python | ||
if: ${{ env.HAS_ARTIFACT }} | ||
if: env.HAS_ARTIFACT | ||
id: setup-python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
|
||
# See https://www.peterbe.com/plog/install-python-poetry-github-actions-faster | ||
- name: Load cached ~/.local | ||
if: ${{ env.HAS_ARTIFACT }} | ||
if: env.HAS_ARTIFACT | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.local | ||
|
@@ -54,14 +54,14 @@ jobs: | |
key: dotlocal-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-0 | ||
|
||
- name: Install Python poetry | ||
if: ${{ env.HAS_ARTIFACT }} | ||
if: env.HAS_ARTIFACT | ||
uses: snok/[email protected] | ||
with: | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
|
||
- name: Load cached venv | ||
if: ${{ env.HAS_ARTIFACT }} | ||
if: env.HAS_ARTIFACT | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
|
@@ -71,19 +71,19 @@ jobs: | |
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-${{ steps.setup-python.outputs.python-version }}-0 | ||
|
||
- name: Install poetry dependencies | ||
if: ${{ env.HAS_ARTIFACT && steps.cached-poetry-dependencies.outputs.cache-hit != 'true' }} | ||
if: env.HAS_ARTIFACT && steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | ||
run: | | ||
cd yari/deployer | ||
poetry install --no-interaction --no-root | ||
- name: Install Deployer | ||
if: ${{ env.HAS_ARTIFACT }} | ||
if: env.HAS_ARTIFACT | ||
run: | | ||
cd yari/deployer | ||
poetry install --no-interaction | ||
- name: Deploy and analyze built content | ||
if: ${{ env.HAS_ARTIFACT }} | ||
if: env.HAS_ARTIFACT | ||
env: | ||
BUILD_OUT_ROOT: ${{ github.workspace }}/build | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# This file tests more or less everything related to a pull request. All | ||
# in one big job. At the end, if all the testing passes, it proceeds | ||
# to upload all the files that were built to our Dev environment. | ||
# This way, if the tests passed, you'll be able to review the built | ||
# pages on a public URL. | ||
|
||
name: PR Test Legacy | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
tests: | ||
if: github.repository == 'mdn/content' | ||
runs-on: ubuntu-latest | ||
# Set the permissions to `read-all`, preventing the workflow from | ||
# any accidental write access to the repository. | ||
permissions: read-all | ||
env: | ||
BASE_SHA: ${{ github.event.pull_request.base.sha }} | ||
HEAD_SHA: ${{ github.event.pull_request.head.sha }} | ||
# This is the directory where the built files will be placed. | ||
# It's also hardcoded in the `yarn build` command in package.json. | ||
# If you change it here, you must also make the same change in | ||
# package.json. | ||
BUILD_OUT_ROOT: build | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Get changed files | ||
run: | | ||
# Use the GitHub API to get the list of changed files | ||
# documentation: https://docs.github.com/rest/commits/commits#compare-two-commits | ||
DIFF_DOCUMENTS=$(gh api repos/{owner}/{repo}/compare/${BASE_SHA}...${HEAD_SHA} \ | ||
--jq '.files | .[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) | .filename') | ||
# filter out files that are not markdown files | ||
GIT_DIFF_CONTENT=$(echo "${DIFF_DOCUMENTS}" | egrep -i "^files/.*\.(md)$" | xargs) | ||
echo "GIT_DIFF_CONTENT=${GIT_DIFF_CONTENT}" >> $GITHUB_ENV | ||
# filter out files that are not attachments | ||
GIT_DIFF_FILES=$(echo "${DIFF_DOCUMENTS}" | egrep -i "^files/.*\.(png|jpeg|jpg|gif|svg|webp)$" | xargs) | ||
echo "GIT_DIFF_FILES=${GIT_DIFF_FILES}" >> $GITHUB_ENV | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Setup Node.js environment | ||
if: env.GIT_DIFF_CONTENT || env.GIT_DIFF_FILES | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: ".nvmrc" | ||
cache: yarn | ||
|
||
- name: Install all yarn packages | ||
if: env.GIT_DIFF_CONTENT || env.GIT_DIFF_FILES | ||
run: yarn --frozen-lockfile | ||
env: | ||
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build changed content | ||
id: build-content | ||
if: env.GIT_DIFF_CONTENT | ||
env: | ||
CONTENT_ROOT: ${{ github.workspace }}/files | ||
|
||
# This is so that if there's a single 'unsafe_html' flaw, it | ||
# completely fails the build. | ||
# But all other flaws should be 'warn', so that we can include | ||
# information about the flaws when we analyze the built PR. | ||
BUILD_FLAW_LEVELS: "unsafe_html: error, *:warn" | ||
|
||
# Because we build these pages in a way that you get a toolbar, | ||
# so the flaws can be displayed, but we don't want any of the | ||
# other toolbar features like "Fix fixable flaws" or "Quick-edit" | ||
# we set this to disable that stuff. | ||
REACT_APP_CRUD_MODE_READONLY: true | ||
|
||
BUILD_LIVE_SAMPLES_BASE_URL: https://live.mdnyalp.dev | ||
BUILD_LEGACY_LIVE_SAMPLES_BASE_URL: https://live-samples.mdn.allizom.net | ||
|
||
# In these builds, we never care for or need the ability to sign in. | ||
# This environment variable will disable that functionality entirely. | ||
REACT_APP_DISABLE_AUTH: true | ||
|
||
# TODO: This should be implicit when `CI=true` | ||
BUILD_NO_PROGRESSBAR: true | ||
|
||
# Playground | ||
REACT_APP_PLAYGROUND_BASE_HOST: mdnyalp.dev | ||
|
||
run: | | ||
# The reason this script isn't in `package.json` is because | ||
# you don't need that script as a writer. It's only used in CI | ||
# and it can't use the default CONTENT_ROOT that gets set in | ||
# package.json. | ||
yarn build $GIT_DIFF_CONTENT | ||
echo "Disk usage size of the build" | ||
du -sh $BUILD_OUT_ROOT | ||
# Save the PR number into the build | ||
echo ${{ github.event.number }} > ${BUILD_OUT_ROOT}/NR | ||
# Download the raw diff blob and store that inside the build | ||
# directory. | ||
# The purpose of this is for the PR Review Companion to later | ||
# be able to use this raw diff file for the benefit of analyzing. | ||
wget https://github.com/${{ github.repository }}/compare/${BASE_SHA}...${HEAD_SHA}.diff -O ${BUILD_OUT_ROOT}/DIFF | ||
- name: Merge static assets with built documents | ||
if: env.GIT_DIFF_CONTENT | ||
run: | | ||
# Exclude the .map files, as they're used for debugging JS and CSS. | ||
rsync -a --exclude "*.map" node_modules/@mdn/yari/client/build/ $BUILD_OUT_ROOT | ||
# Show the final disk usage size of the build. | ||
du -sh $BUILD_OUT_ROOT | ||
- uses: actions/upload-artifact@v4 | ||
if: env.GIT_DIFF_CONTENT | ||
with: | ||
name: build | ||
path: ${{ env.BUILD_OUT_ROOT }} | ||
|
||
- name: Check changed files | ||
if: env.GIT_DIFF_FILES | ||
run: | | ||
echo $GIT_DIFF_FILES | ||
export CONTENT_ROOT=$(pwd)/files | ||
yarn filecheck $GIT_DIFF_FILES |
Oops, something went wrong.