aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows
diff options
context:
space:
mode:
authorFlorian Merz <me@fiji-flo.de>2021-02-26 15:40:06 +0100
committerFlorian Merz <me@fiji-flo.de>2021-03-01 14:37:02 +0100
commita03ed6b6125921ff7f66ac6431782039d604cba4 (patch)
tree2641acd1bb8eed73e36900aa2cdbb7c6ca427b47 /.github/workflows
parent09b2b0c5dba96a586a84ee500a9745830251502d (diff)
downloadtranslated-content-a03ed6b6125921ff7f66ac6431782039d604cba4.tar.gz
translated-content-a03ed6b6125921ff7f66ac6431782039d604cba4.tar.bz2
translated-content-a03ed6b6125921ff7f66ac6431782039d604cba4.zip
add CI
Diffstat (limited to '.github/workflows')
-rw-r--r--.github/workflows/markdown-lint.yml26
-rw-r--r--.github/workflows/pr-check_redirects.yml55
-rw-r--r--.github/workflows/pr-lint.yml44
-rw-r--r--.github/workflows/pr-test.yml129
4 files changed, 254 insertions, 0 deletions
diff --git a/.github/workflows/markdown-lint.yml b/.github/workflows/markdown-lint.yml
new file mode 100644
index 0000000000..7a6fde4818
--- /dev/null
+++ b/.github/workflows/markdown-lint.yml
@@ -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
diff --git a/.github/workflows/pr-check_redirects.yml b/.github/workflows/pr-check_redirects.yml
new file mode 100644
index 0000000000..2967d0574f
--- /dev/null
+++ b/.github/workflows/pr-check_redirects.yml
@@ -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/setup-node@v2.1.4
+ 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/cache@v2.1.4
+ 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
diff --git a/.github/workflows/pr-lint.yml b/.github/workflows/pr-lint.yml
new file mode 100644
index 0000000000..5330e98619
--- /dev/null
+++ b/.github/workflows/pr-lint.yml
@@ -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/setup-node@v2.1.4
+ 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
diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml
new file mode 100644
index 0000000000..0f17a767c8
--- /dev/null
+++ b/.github/workflows/pr-test.yml
@@ -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/setup-node@v2.1.4
+ with:
+ node-version: "12"
+
+ - name: Cache node_modules
+ uses: actions/cache@v2.1.4
+ 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/get-diff-action@v4.0.5
+ 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/get-diff-action@v4.0.5
+ 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 }}