Skip to content

Commit

Permalink
Merge branch 'main' into draft-invokers-api-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
keithamus authored Jan 16, 2024
2 parents 8573d44 + f72ba69 commit daeba33
Show file tree
Hide file tree
Showing 6,522 changed files with 82,642 additions and 52,313 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
14 changes: 13 additions & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
system:
- package.json
- yarn.lock
- .github/**/*
- .husky/**/*
- .vscode/**/*
- .*
- scripts/**/*
- tests/**/*
- jest.config.json
- front-matter-config.json

Content:Accessibility:
- files/en-us/web/accessibility/**/*
Content:CSS:
Expand Down Expand Up @@ -41,7 +53,7 @@ Content:Learn:Client-side:
Content:Learn:Cross-Browser-Testing:
- files/en-us/learn/tools_and_testing/cross_browser_testing/**/*
Content:Learn:CSS:
- files/en-us/learn/css
- files/en-us/learn/css/**/*
Content:Learn:Django:
- files/en-us/learn/server-side/django/**/*
Content:Learn:Express:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create Markdownlint auto-fix PR
name: Create content auto-fix PR

on:
schedule:
Expand All @@ -11,31 +11,34 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

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

- 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 }}
HUSKY: 0
run: yarn --frozen-lockfile

- name: Lint markdown files
run: |
yarn content fix-flaws
yarn fix:md
yarn fix:fm
- name: Create PR with only fixable issues
if: success()
uses: peter-evans/create-pull-request@v5
with:
commit-message: "chore: auto-fix Markdownlint issues"
commit-message: "chore: auto-fix Markdownlint, Prettier, and front-matter issues"
branch: markdownlint-auto-cleanup
title: "Markdownlint auto-cleanup"
title: "fix: auto-cleanup by bot"
author: mdn-bot <108879845+mdn-bot@users.noreply.github.com>
body: |
All issues auto-fixed
Expand All @@ -45,9 +48,9 @@ jobs:
if: failure()
uses: peter-evans/create-pull-request@v5
with:
commit-message: "chore: auto-fix Markdownlint issues"
commit-message: "chore: auto-fix Markdownlint, Prettier, and front-matter issues"
branch: markdownlint-auto-cleanup
title: "Markdownlint auto-cleanup"
title: "fix: auto-cleanup by bot"
author: mdn-bot <108879845+mdn-bot@users.noreply.github.com>
body: |
Auto-fix was run, but additional issues found.
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/interfacedata-updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"

- name: Checkout content
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: mdn-content
ref: main

- name: Setup node.js
uses: actions/setup-node@v4
with:
node-version-file: "mdn-content/.nvmrc"

- name: Checkout webref
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: w3c/webref
path: webref
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-regex-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
issue-labeler:
runs-on: ubuntu-latest
steps:
- uses: github/issue-labeler@v3.1
- uses: github/issue-labeler@v3.3
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/issue-regex-labeler.yml
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

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

- 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: Lint markdown files
run: |
Expand Down
27 changes: 12 additions & 15 deletions .github/workflows/on-demand-preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

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

- 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 content
env:
Expand All @@ -51,17 +54,8 @@ jobs:
# we set this to disable that stuff.
REACT_APP_CRUD_MODE_READONLY: true

# Setting this to an empty string effectively means that the
# <iframe> src will end up being the relative URL of the current
# document as a base.
# I.e. like this, if the current document is '/en-US/docs/Foo':
# <iframe src="/en-US/docs/Foo/_samples_/index.html">
# ...for example.
# Yes, it's potentially "insecure" because the iframe will execute
# whatever code is inserted into the code example. But since the
# whole (possible) domain for PR builds will never be somewhere
# where there are interesting cookies, it's a safe choice.
BUILD_LIVE_SAMPLES_BASE_URL: ""
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.
Expand All @@ -70,6 +64,9 @@ jobs:
# 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
Expand Down Expand Up @@ -105,7 +102,7 @@ jobs:

- name: Install Python
id: setup-python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.8"

Expand All @@ -132,7 +129,7 @@ jobs:
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('.github/workflows/pr-review-companion.yml') }}

- name: Checkout Yari
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: mdn/yari
path: yari
Expand Down
156 changes: 156 additions & 0 deletions .github/workflows/pr-check-lint_content.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: Lint and review content files

on:
pull_request_target:
branches:
- main
paths:
- .nvmrc
- "*.md"
- "files/**/*.md"

permissions:
pull-requests: write

concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
lint-and-review-docs:
runs-on: ubuntu-latest

steps:
- name: Checkout BASE
uses: actions/checkout@v4

- name: Get changed files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
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/${{ env.BASE_SHA }}...${{ env.HEAD_SHA }} \
--jq '.files | .[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) | .filename')
# filter out files that are not markdown
DIFF_DOCUMENTS=$(echo "${DIFF_DOCUMENTS}" | egrep -i "^files/.*\.md$" | xargs)
echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV
- name: Checkout HEAD
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 }}
run: |
git config --global user.email "108879845+mdn-bot@users.noreply.github.com"
git config --global user.name "mdn-bot"
rm -r files *.md
mv pr_head/files pr_head/*.md .
rm -r pr_head
# To avoid contents of PR getting into the diff that we are going to generate
# after running the linters, here we make a dummy commit.
# Note, this commit is not getting pushed.
git add .
git commit -m "Code from PR head"
- name: Setup Node.js environment
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 }}
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 }}
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="${{ env.DIFF_DOCUMENTS }}"
echo "Running markdownlint --fix"
MD_LINT_FAILED=false
MD_LINT_LOG=$(yarn markdownlint-cli2 --fix ${files_to_lint} 2>&1) || MD_LINT_FAILED=true
echo "MD_LINT_LOG<<${EOF}" >> $GITHUB_ENV
echo "${MD_LINT_LOG}" >> $GITHUB_ENV
echo "${EOF}" >> $GITHUB_ENV
echo "MD_LINT_FAILED=${MD_LINT_FAILED}" >> $GITHUB_ENV
echo "Linting front-matter"
FM_LINT_FAILED=false
FM_LINT_LOG=$(node scripts/front-matter_linter.js --fix true ${files_to_lint} 2>&1) || FM_LINT_FAILED=true
echo "FM_LINT_LOG<<${EOF}" >> $GITHUB_ENV
echo "${FM_LINT_LOG}" >> $GITHUB_ENV
echo "${EOF}" >> $GITHUB_ENV
echo "FM_LINT_FAILED=${FM_LINT_FAILED}" >> $GITHUB_ENV
echo "Running Prettier"
yarn prettier -w ${files_to_lint}
if [[ -n $(git diff) ]]; then
echo "FILES_MODIFIED=true" >> $GITHUB_ENV
fi
# info for troubleshooting
echo MD_LINT_FAILED=${MD_LINT_FAILED}
echo FM_LINT_FAILED=${FM_LINT_FAILED}
git diff
- name: Setup reviewdog
if: env.FILES_MODIFIED == 'true' || env.MD_LINT_FAILED == 'true'
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest

- name: Suggest changes using diff
if: env.FILES_MODIFIED == 'true'
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TMPFILE=$(mktemp)
git diff >"${TMPFILE}"
git stash -u && git stash drop
reviewdog \
-name="mdn-linter" \
-f=diff \
-f.diff.strip=1 \
-reporter=github-pr-review < "${TMPFILE}"
- name: Add reviews for markdownlint errors
if: env.MD_LINT_FAILED == 'true'
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "${{ env.MD_LINT_LOG }}" | \
reviewdog \
-efm="%f:%l:%c %m" \
-efm="%f:%l %m" \
-name="markdownlint" \
-diff="git diff" \
-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'
run: |
echo -e "\nLogs from markdownlint:"
echo "${{ env.MD_LINT_LOG }}"
echo -e "\nLogs from front-matter linter:"
echo "${{ env.FM_LINT_LOG }}"
echo -e "\nPlease fix all the linting issues mentioned in above logs and in the review comments."
exit 1
7 changes: 5 additions & 2 deletions .github/workflows/pr-check_javascript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

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

- 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: Lint JavaScript files
run: yarn lint:js
Loading

0 comments on commit daeba33

Please sign in to comment.