diff options
author | Florian Dieminger <me@fiji-flo.de> | 2021-03-02 07:17:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-02 07:17:24 +0100 |
commit | dd4d0ee7043b92b2aadf45152205442efb9ded84 (patch) | |
tree | 99a5ac1b088091924d6c9a7813fbed0e9ea413f6 | |
parent | 09b2b0c5dba96a586a84ee500a9745830251502d (diff) | |
parent | df10f843d51886fc6f14ed529d1eec7d9e10cd26 (diff) | |
download | translated-content-dd4d0ee7043b92b2aadf45152205442efb9ded84.tar.gz translated-content-dd4d0ee7043b92b2aadf45152205442efb9ded84.tar.bz2 translated-content-dd4d0ee7043b92b2aadf45152205442efb9ded84.zip |
Merge pull request #78 from fiji-flo/main
add CI
-rw-r--r-- | .github/workflows/markdown-lint.yml | 26 | ||||
-rw-r--r-- | .github/workflows/pr-check_redirects.yml | 51 | ||||
-rw-r--r-- | .github/workflows/pr-lint.yml | 37 | ||||
-rw-r--r-- | .github/workflows/pr-test.yml | 125 |
4 files changed, 239 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..05f463bc57 --- /dev/null +++ b/.github/workflows/pr-check_redirects.yml @@ -0,0 +1,51 @@ +name: Check Redirects + +on: + pull_request: + branches: + - main + paths: + - files/**/_redirects.txt + - files/**/index.html + - .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 + + - 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 + working-directory: ${{ github.workspace }}/mdn/content + run: | + yarn --frozen-lockfile + + - name: Check redirects file(s) + env: + CONTENT_ROOT: ${{ github.workspace }}/mdn/content/files + CONTENT_TRANSLATED_ROOT: ${{ github.workspace }}/files + working-directory: ${{ github.workspace }}/mdn/content + run: | + 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..6b32fe1168 --- /dev/null +++ b/.github/workflows/pr-lint.yml @@ -0,0 +1,37 @@ +# 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 + + - name: Setup Node.js environment + uses: actions/setup-node@v2.1.4 + with: + node-version: "12" + + - name: Install all yarn packages + working-directory: ${{ github.workspace }}/mdn/content/pr-lint + run: | + yarn --frozen-lockfile + + - name: Run checks + working-directory: ${{ github.workspace }}/mdn/content/pr-lint + run: | + yarn run check diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml new file mode 100644 index 0000000000..af6fada9aa --- /dev/null +++ b/.github/workflows/pr-test.yml @@ -0,0 +1,125 @@ +# 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 + + - 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') }}-1 + + - name: Install all yarn packages + if: steps.cached-node_modules.outputs.cache-hit != 'true' + working-directory: ${{ github.workspace }}/mdn/content + run: | + 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 }} + env: + CONTENT_ROOT: ${{ github.workspace }}/mdn/content/files + CONTENT_TRANSLATED_ROOT: ${{ github.workspace }}/files + working-directory: ${{ github.workspace }}/mdn/content + run: | + echo ${{ env.GIT_DIFF_CONTENT }} + + # 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. + + 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 }} + env: + CONTENT_ROOT: ${{ github.workspace }}/mdn/content/files + CONTENT_TRANSLATED_ROOT: ${{ github.workspace }}/files + working-directory: ${{ github.workspace }}/mdn/content + run: | + echo ${{ env.GIT_DIFF_FILES }} + + yarn filecheck ${{ env.GIT_DIFF_FILES }} |