-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
254 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Markdown lint (project files) | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- '*.md' | ||
- .github/workflows/markdown-lint.yml | ||
|
||
|
||
jobs: | ||
docs: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup Node.js environment | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "12" | ||
|
||
- name: Lint markdown files | ||
run: | | ||
npx markdownlint-cli '*.md' -i LICENSE.md -i CODE_OF_CONDUCT.md |
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,55 @@ | ||
name: Check Redirects | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- files/**/_redirects.txt | ||
- .github/workflows/pr-check_redirects.yml | ||
|
||
jobs: | ||
check_redirects: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/checkout@v2 | ||
with: | ||
repository: mdn/content | ||
path: mdn/content | ||
# Yes, this means fetch EVERY COMMIT EVER. | ||
# It's probably not sustainable in the far future (e.g. past 2021) | ||
# but for now it's good enough. We'll need all the history | ||
# so we can figure out each document's last-modified date. | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node.js environment | ||
uses: actions/[email protected] | ||
with: | ||
node-version: "12" | ||
|
||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
- uses: actions/[email protected] | ||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Install all yarn packages | ||
run: | | ||
cd $GITHUB_WORKSPACE/mdn/content/ | ||
yarn --frozen-lockfile | ||
- name: Check redirects file(s) | ||
run: | | ||
export CONTENT_ROOT=$GITHUB_WORKSPACE/mdn/content/files | ||
export CONTENT_TRANSLATED_ROOT=$GITHUB_WORKSPACE/files | ||
cd $GITHUB_WORKSPACE/mdn/content/ | ||
yarn content validate-redirects --strict |
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,44 @@ | ||
# Checks the PR itself for hygiene things. | ||
|
||
name: PR Lint | ||
|
||
on: | ||
pull_request: | ||
# Necessary to re-run if someone edits the PR without a new pushed commit. | ||
types: [opened, edited, synchronize, reopened] | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
path: mdn/translated-content | ||
|
||
- uses: actions/checkout@v2 | ||
with: | ||
repository: mdn/content | ||
path: mdn/content | ||
# Yes, this means fetch EVERY COMMIT EVER. | ||
# It's probably not sustainable in the far future (e.g. past 2021) | ||
# but for now it's good enough. We'll need all the history | ||
# so we can figure out each document's last-modified date. | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node.js environment | ||
uses: actions/[email protected] | ||
with: | ||
node-version: "12" | ||
|
||
- name: Install all yarn packages | ||
run: | | ||
cd $GITHUB_WORKSPACE/mdn/content/ | ||
cd pr-lint | ||
yarn --frozen-lockfile | ||
- name: Run checks | ||
run: | | ||
cd $GITHUB_WORKSPACE/mdn/content/ | ||
cd pr-lint | ||
yarn run check |
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,129 @@ | ||
# Note that this workflow uses `get-diff-action` which is important. | ||
# It gives us an environment variable called `GIT_DIFF` which is a string | ||
# that is a list of file paths. | ||
# If you want to do what this workflow does on your laptop you can simulate | ||
# it like this: | ||
# | ||
# export GIT_DIFF=`git diff --name-only main... | grep 'files/' | grep '\.html$'` | ||
# node content build --no-progressbar --files="${GIT_DIFF}" | ||
# | ||
# That way, you can behave on your laptop like, this action behaves here. | ||
|
||
name: PR Test | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/checkout@v2 | ||
with: | ||
repository: mdn/content | ||
path: mdn/content | ||
# Yes, this means fetch EVERY COMMIT EVER. | ||
# It's probably not sustainable in the far future (e.g. past 2021) | ||
# but for now it's good enough. We'll need all the history | ||
# so we can figure out each document's last-modified date. | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node.js environment | ||
uses: actions/[email protected] | ||
with: | ||
node-version: "12" | ||
|
||
- name: Cache node_modules | ||
uses: actions/[email protected] | ||
id: cached-node_modules | ||
with: | ||
path: | | ||
{{ github.workspace }}/mdn/content/node_modules | ||
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} | ||
|
||
- name: Install all yarn packages | ||
if: steps.cached-node_modules.outputs.cache-hit != 'true' | ||
run: | | ||
cd $GITHUB_WORKSPACE/mdn/content/ | ||
yarn --frozen-lockfile | ||
- uses: technote-space/[email protected] | ||
id: git_diff_content | ||
with: | ||
PATTERNS: files/**/*.html | ||
SET_ENV_NAME: GIT_DIFF_CONTENT | ||
|
||
- name: Build changed content | ||
if: ${{ env.GIT_DIFF_CONTENT }} | ||
run: | | ||
echo ${{ env.GIT_DIFF_CONTENT }} | ||
export CONTENT_ROOT=$GITHUB_WORKSPACE/mdn/content/files | ||
export CONTENT_TRANSLATED_ROOT=$GITHUB_WORKSPACE/files | ||
# Some day, when our number of flaws have reached 0 we'll change | ||
# this to "*:error" which means the slightest flaw in the build | ||
# will break the build. | ||
# See https://github.com/mdn/yari/issues/715 | ||
export BUILD_FLAW_LEVELS="*:ignore" | ||
# Note, it might be interesting to explore building *some* | ||
# pages in a PR build if the diff doesn't have any index.html | ||
# files changed. | ||
# Instead of building the git diff, you build some known typical | ||
# folders that you know don't take too long and do cover a lot | ||
# of interesting macros etc. | ||
# This way, when an edit to the source code comes in, perhaps the | ||
# functional tests have a gap in them but actually building | ||
# real content exposes it. | ||
# 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. | ||
export BUILD_LIVE_SAMPLES_BASE_URL= | ||
# In these builds we never care for or need the ability to sign in. | ||
# This environment variable will disable that functionality entirely. | ||
export REACT_APP_DISABLE_AUTH=true | ||
# If we don't do this the built files will end up in | ||
# `node_modules/@mdn/yari/client/build/` and we don't want that | ||
# to get pushed into the cache. | ||
export BUILD_OUT_ROOT=/tmp/ | ||
export BUILD_NO_PROGRESSBAR=true | ||
# 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. | ||
cd $GITHUB_WORKSPACE/mdn/content/ | ||
yarn build ${{ env.GIT_DIFF_CONTENT }} | ||
- uses: technote-space/[email protected] | ||
with: | ||
PATTERNS: files/**/*.+(png|jpeg|jpg|gif|svg|webp) | ||
ABSOLUTE: true | ||
SET_ENV_NAME: GIT_DIFF_FILES | ||
|
||
- name: Check changed files | ||
if: ${{ env.GIT_DIFF_FILES }} | ||
run: | | ||
echo ${{ env.GIT_DIFF_FILES }} | ||
export CONTENT_ROOT=$GITHUB_WORKSPACE/mdn/content/files | ||
export TRANSLATED_CONTENT_ROOT=$GITHUB_WORKSPACE/files | ||
cd $GITHUB_WORKSPACE/mdn/content/ | ||
yarn filecheck ${{ env.GIT_DIFF_FILES }} |