# This is more or less a copy of # https://github.com/mdn/content/blob/main/.github/workflows/pr-test.yml # but done in a way that it first checks out mdn/translated-content (or # fork of) and _then_ checks out mdn/content which has the relevant # CI related tooling. name: PR Test on: pull_request: branches: - main jobs: tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 # Needed otherswise it will check out a merge commit which means # you can't get a `git diff` for this PR compared to its base. # with: # ref: ${{ github.event.pull_request.head.sha }} - uses: actions/checkout@v3 with: repository: mdn/content path: mdn/content - name: Setup Node.js environment uses: actions/setup-node@v3 with: node-version: "12" - name: Cache node_modules uses: actions/cache@v2.1.6 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' working-directory: ${{ github.workspace }}/mdn/content run: | yarn --frozen-lockfile - name: Config git core.quotePath run: | # If you don't do this, the get-diff-action won't be able to # notice files that contain non-ascii characters. # I.e. # # ▶ git status # Changes not staged for commit: # ... # modified: "files/en-us/glossary/b\303\251zier_curve/index.html" # # But after you set `core.quotePath` you get: # # ▶ git status # Changes not staged for commit: # ... # modified: "files/en-us/glossary/bézier_curve/index.html" # # Now, this gets used by the `git diff ...` inside get-diff-action. git config --global core.quotePath false - uses: technote-space/get-diff-action@v6.0.1 id: git_diff_content with: PATTERNS: files/**/*.+(html|md) 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 # 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 # Setting this to an empty string effectively means that the #