From d9d47108e9947b16185192eece4403da8effad0c Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Thu, 27 Jul 2023 16:55:53 -0700 Subject: [PATCH 01/15] feat(ci): Add Reviewdog for Prettier formatting --- .github/workflows/reviewdog.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/reviewdog.yml diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml new file mode 100644 index 000000000000000..f25bc513b5004cf --- /dev/null +++ b/.github/workflows/reviewdog.yml @@ -0,0 +1,24 @@ +name: reviewdog / Prettier + +on: + - pull_request + +jobs: + prettier: + name: runner / prettier + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: EPMatt/reviewdog-action-prettier@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + # Change reviewdog reporter if you need + # [github-pr-check,github-check,github-pr-review]. + # More about reviewdog reporters at + # https://github.com/reviewdog/reviewdog#reporters + reporter: github-pr-review + # Change reporter level if you need + # [info,warning,error]. + # More about reviewdog reporter level at + # https://github.com/reviewdog/reviewdog#reporters + level: warning From 7b7d6d10aeb31917b2e97ff46b17c67b2c96c60f Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Thu, 27 Jul 2023 17:03:54 -0700 Subject: [PATCH 02/15] Apply bad formatting to test Reviewdog --- .github/workflows/reviewdog.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index f25bc513b5004cf..14638f4050fbbc7 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -1,7 +1,7 @@ name: reviewdog / Prettier on: - - pull_request + - pull_request jobs: prettier: From 4e7d4182671a1fbdcc04bf7482a11919710da7df Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Thu, 27 Jul 2023 17:07:23 -0700 Subject: [PATCH 03/15] Use reviewdog/action-suggester@v1 instead --- .github/workflows/reviewdog.yml | 38 ++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 14638f4050fbbc7..58c00d630566450 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -1,24 +1,32 @@ -name: reviewdog / Prettier +name: reviewdog on: - pull_request jobs: prettier: - name: runner / prettier + name: prettier runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: EPMatt/reviewdog-action-prettier@v1 + - uses: actions/checkout@v3 + + - name: Setup Node.js environment + uses: actions/setup-node@v3 + 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: Format changed content + if: ${{ env.GIT_DIFF_CONTENT }} + run: | + yarn prettier --write ${{ env.GIT_DIFF_CONTENT }} + - name: Submit suggestion + uses: reviewdog/action-suggester@v1 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - # Change reviewdog reporter if you need - # [github-pr-check,github-check,github-pr-review]. - # More about reviewdog reporters at - # https://github.com/reviewdog/reviewdog#reporters - reporter: github-pr-review - # Change reporter level if you need - # [info,warning,error]. - # More about reviewdog reporter level at - # https://github.com/reviewdog/reviewdog#reporters - level: warning + tool_name: prettier From d037b7b8117cc3af3d3d5eb74b0a5d56ac4ffdcd Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Thu, 27 Jul 2023 17:10:40 -0700 Subject: [PATCH 04/15] Remove redundant step --- .github/workflows/reviewdog.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 58c00d630566450..6e5fce37ee9ed41 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -1,7 +1,7 @@ name: reviewdog on: - - pull_request + - pull_request jobs: prettier: @@ -22,10 +22,6 @@ jobs: # https://github.com/microsoft/vscode-ripgrep#github-api-limit-note GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Format changed content - if: ${{ env.GIT_DIFF_CONTENT }} - run: | - yarn prettier --write ${{ env.GIT_DIFF_CONTENT }} - name: Submit suggestion uses: reviewdog/action-suggester@v1 with: From c9bfaa5116ab614e55cabae79b26468285bc0da0 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 01:19:29 -0700 Subject: [PATCH 05/15] Update .github/workflows/reviewdog.yml Co-authored-by: Brian Thomas Smith --- .github/workflows/reviewdog.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 6e5fce37ee9ed41..54127040e5168d4 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -5,6 +5,8 @@ on: jobs: prettier: + # do not run on forks + if: github.repository == 'mdn/content' name: prettier runs-on: ubuntu-latest steps: From 8a14c11b25e05184146e8045ff52fc3c66dc5c00 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 21:06:13 -0700 Subject: [PATCH 06/15] Fix Reviewdog workflow --- .github/workflows/reviewdog.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 54127040e5168d4..02878b00d3b0eb0 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -12,6 +12,18 @@ jobs: steps: - uses: actions/checkout@v3 + - 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 + # documenation: 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') + echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV + - name: Setup Node.js environment uses: actions/setup-node@v3 with: @@ -24,7 +36,11 @@ jobs: # https://github.com/microsoft/vscode-ripgrep#github-api-limit-note GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Perform linting + run: yarn prettier --ignore-unknown --write "${{ env.DIFF_DOCUMENTS }}" + - name: Submit suggestion uses: reviewdog/action-suggester@v1 with: + github_token: ${{ secrets.GITHUB_TOKEN }} tool_name: prettier From 1b80441c5a2e3e80015f6d0e81de6a611b269900 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 21:24:00 -0700 Subject: [PATCH 07/15] Apply bad formatting to test workflow --- .github/workflows/reviewdog.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 02878b00d3b0eb0..2113dae74b3b348 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -1,7 +1,7 @@ name: reviewdog on: - - pull_request + - pull_request jobs: prettier: From a9b1b614a8655fbf4b389605fe6fbb2487b0bcd4 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 21:48:00 -0700 Subject: [PATCH 08/15] Try with different bad formatting --- .github/workflows/reviewdog.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 2113dae74b3b348..2f6bbeb3ba51eac 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -1,7 +1,7 @@ name: reviewdog on: - - pull_request + - pull_request jobs: prettier: @@ -14,9 +14,9 @@ jobs: - 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 }} + 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 # documenation: https://docs.github.com/rest/commits/commits#compare-two-commits From 3ec43f591a4440b12a144d0145dd03da37450e77 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 22:05:12 -0700 Subject: [PATCH 09/15] Update .github/workflows/reviewdog.yml Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .github/workflows/reviewdog.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 2f6bbeb3ba51eac..02878b00d3b0eb0 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -14,9 +14,9 @@ jobs: - 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 }} + 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 # documenation: https://docs.github.com/rest/commits/commits#compare-two-commits From c51c27a3ed1c64a84e4002aff1069e2a2c19ba3d Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 22:11:21 -0700 Subject: [PATCH 10/15] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 95ba16c0ae0a053..00fa0be0c16d987 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -223,7 +223,7 @@ To ensure that all MDN documents follow the same formatting, we use both [Pretti If you have a [local checkout](#forking-and-cloning-the-repository) of the repository and have [installed the dependencies](#preparing-the-project), or you are using [github.dev](https://github.dev), a pre-commit hook will be installed which automatically runs while making a commit. To save some headache and improve your work flow while authoring, you may wish to [configure your editor to automatically run Prettier](https://prettier.io/docs/en/editors.html). Alternatively, you may run `yarn fix:md` in the command line to manually format all Markdown files. -> **Note:** Automatically formatting changes does not work for pull requests opened using the GitHub Web UI as described in the ["Simple changes" section](#simple-changes). This may result in failed status checks on pull requests. If you're not sure about how to fix this, [get in touch with us](/en-US/docs/MDN/Community/Communication_channels) for help. +> **Note:** An automatic review bot will submit a review with code suggestions if modified files don't match Prettier formatting. This was primarily implemented for contributors using the GitHub Web UI as described in the ["Simple changes" section](#simple-changes). ### Adding a new document From 710015408de0eed2ce0dd8fbc71f5dfb2e74ae53 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 22:14:47 -0700 Subject: [PATCH 11/15] Add an unrelated change to mitigate non-running tests issue --- files/en-us/learn/css/building_blocks/cascade_layers/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/learn/css/building_blocks/cascade_layers/index.md b/files/en-us/learn/css/building_blocks/cascade_layers/index.md index 3b70fc3d068b8c9..f8d93ad719c2497 100644 --- a/files/en-us/learn/css/building_blocks/cascade_layers/index.md +++ b/files/en-us/learn/css/building_blocks/cascade_layers/index.md @@ -279,7 +279,7 @@ If you nest a block `@layer` at-rule inside another block `@layer` at-rule, with Let's look at the following example: -``` +```css @import url("components-lib.css") layer(components); @import url("narrowtheme.css") layer(components.narrow); ``` From 3c0502ddd766b49b31468c1e972006b839f084ca Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 22:20:07 -0700 Subject: [PATCH 12/15] Pipe modified files list to xargs --- .github/workflows/reviewdog.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 02878b00d3b0eb0..f25647039977b29 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -21,7 +21,7 @@ jobs: # Use the GitHub API to get the list of changed files # documenation: 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') + --jq '.files | .[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) | .filename') | xargs echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV - name: Setup Node.js environment From d8a2d919bf0c032820cd09493154f1722168bb29 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 22:29:17 -0700 Subject: [PATCH 13/15] Test workflow one last time --- .github/workflows/reviewdog.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index f25647039977b29..108b935c98327da 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -27,8 +27,8 @@ jobs: - name: Setup Node.js environment uses: actions/setup-node@v3 with: - node-version-file: ".nvmrc" - cache: yarn + node-version-file: ".nvmrc" + cache: yarn - name: Install all yarn packages run: yarn --frozen-lockfile From c7293b923b073908ec874eb3e7e7715571e7ad2f Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 22:44:19 -0700 Subject: [PATCH 14/15] Update .github/workflows/reviewdog.yml Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .github/workflows/reviewdog.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 108b935c98327da..f25647039977b29 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -27,8 +27,8 @@ jobs: - name: Setup Node.js environment uses: actions/setup-node@v3 with: - node-version-file: ".nvmrc" - cache: yarn + node-version-file: ".nvmrc" + cache: yarn - name: Install all yarn packages run: yarn --frozen-lockfile From bba4feeb1efe5acb0527483c5c3f63b6ca35d35d Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 22:49:24 -0700 Subject: [PATCH 15/15] Fix placement of xargs pipe --- .github/workflows/reviewdog.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index f25647039977b29..731b9cbc21ff765 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -20,8 +20,7 @@ jobs: run: | # Use the GitHub API to get the list of changed files # documenation: 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') | xargs + 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' | xargs) echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV - name: Setup Node.js environment @@ -37,7 +36,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Perform linting - run: yarn prettier --ignore-unknown --write "${{ env.DIFF_DOCUMENTS }}" + run: yarn prettier --ignore-unknown --write ${{ env.DIFF_DOCUMENTS }} - name: Submit suggestion uses: reviewdog/action-suggester@v1