Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: sync Markdownlint setup from mdn/content #8181

Merged
merged 1 commit into from
Nov 25, 2022

Conversation

nschonni
Copy link
Contributor

@nschonni nschonni commented Sep 1, 2022

Copied the setup from the upstream repo, but added a step to copy over the package.json and yarn.lock to use the same version of the tools

@nschonni nschonni requested a review from a team as a code owner September 1, 2022 03:57
@github-actions github-actions bot added the system Infrastructure and configuration for the project label Sep 1, 2022
@nschonni
Copy link
Contributor Author

nschonni commented Sep 1, 2022

Note that some of the issues will be silenced with #7778, and normally the second Markdownlint that only runs on changed markdown files will be run.

/cc @caugner @yin1999 @OnkarRuikar

.github/workflows/pr-check_markdownlint.yml Outdated Show resolved Hide resolved
.github/workflows/pr-check_markdownlint.yml Outdated Show resolved Hide resolved
@OnkarRuikar
Copy link
Contributor

OnkarRuikar commented Sep 1, 2022

We shouldn't link the linter version to the mdn/content project. Because there version gets updated after all the files are fixed.
Here also we need to make sure all the file are fixed before changing the linter version. The two projects are not linked in this regard.


We do not have to install all the content/yari dependancies to lint the translated content:

      - uses: actions/checkout@v3

      - name: Setup Node.js environment
        uses: actions/setup-node@v3
        with:
          node-version: "16"

      - name: Setup packages
        run: |
          npm init -y &> /dev/null
          # get the version from content project
          version=$( curl https://raw.githubusercontent.com/mdn/content/main/package.json 2>&1 | grep -oP "(?<=markdownlint-cli....)[\.\d]+" )
          npm install -g "markdownlint-cli@$version"

      - name: Lint markdown files
        run: |
          echo "::add-matcher::.github/workflows/markdownlint-problem-matcher.json"
          markdownlint "**/*.md"

@caugner
Copy link
Contributor

caugner commented Sep 1, 2022

We shouldn't link the linter version to the mdn/content project.

Very valid point from @OnkarRuikar, so how about having a workflow instead that opens a PR with these changes?

@nschonni
Copy link
Contributor Author

nschonni commented Sep 2, 2022

We shouldn't link the linter version to the mdn/content project. Because there version gets updated after all the files are fixed.
Here also we need to make sure all the file are fixed before changing the linter version. The two projects are not linked in this regard.

They content is synced across, so I think I'm not sure why they wouldn't use the same tools. This repo hasn't been cleaned up and is still in the process of converting to Markdown, so having the task now would help flag stuff to cleanup as it lands.

If you think it shouldn't leverage the lock/package from the other project, I think there should be a separate copy in this repo+dependabot rather than embedded versions in the action files

@OnkarRuikar
Copy link
Contributor

so I think I'm not sure why they wouldn't use the same tools.

It's not about the tools being same. It's about tool versions. The content project doesn't wait for this repo to update the tool versions.

If you think it shouldn't leverage the lock/package from the other project, I think there should be a separate copy in this repo+dependabot rather than embedded versions in the action files

I agree. We need to do npm init here and add only the required tools. And the dependabot.
To avoid accidental publish/release, set "private": true and avoid name and version props in the package.json. [ref].
For example, the mdast repo setup

@nschonni
Copy link
Contributor Author

nschonni commented Sep 2, 2022

I ran npm init --y and cleaned it up a bit. Used Yarn to match the tooling upstream

.gitignore Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@OnkarRuikar
Copy link
Contributor

In order for contributors to avoid facing errors in local environment we need to provide engine version in package.json:
The markdownlint-cli supports engines >=14:

"engines": {
    "node": ">=14"
  },

We can have the same or as we are starting a fresh we can start with the latest engine >=18.0.0 (like yari)?

@nschonni
Copy link
Contributor Author

nschonni commented Sep 2, 2022

I think CI is mostly 16 right now, so 14/16 would probably be better for now if you want to add the engine

@caugner
Copy link
Contributor

caugner commented Sep 2, 2022

I think CI is mostly 16 right now, so 14/16 would probably be better for now if you want to add the engine

Let's use the same version constraint as yari and content (after mdn/content#20240).

@nschonni
Copy link
Contributor Author

nschonni commented Sep 2, 2022

I've add the engines to match the pending PR upstream, and added the MD051/52 disable to this PR (which knocks off 3K issues)

@nschonni
Copy link
Contributor Author

nschonni commented Sep 5, 2022

@caugner I've got a bunch of PRs to cleanup a bunch of the issues, but this should be good to land

@nschonni nschonni force-pushed the markdownlint-ci branch 2 times, most recently from 23ea6dd to 01445eb Compare September 5, 2022 18:28
package.json Outdated Show resolved Hide resolved
.github/workflows/pr-check_markdownlint.yml Outdated Show resolved Hide resolved
.github/workflows/pr-check_markdownlint.yml Show resolved Hide resolved
Copy link
Contributor

@caugner caugner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nschonni
Copy link
Contributor Author

nschonni commented Sep 7, 2022

This can either land as-is, or I'll updated it to match mdn/content#20330 if that lands

@yin1999
Copy link
Member

yin1999 commented Sep 7, 2022

This can either land as-is, or I'll updated it to match mdn/content#20330 if that lands

I'm for updating to markdownlint-cli2.

@nschonni nschonni marked this pull request as draft September 7, 2022 03:38
@nschonni
Copy link
Contributor Author

nschonni commented Sep 7, 2022

Flipping to draft to switch this over to CLI2, now that the upstream PR landed

@nschonni
Copy link
Contributor Author

Ping @caugner it would be good to land so we can see if the autofix PRs work. It's OK to have the job failure right now

@nschonni
Copy link
Contributor Author

@caugner do you want me to rebase/squash the commits?

@Rumyra
Copy link
Contributor

Rumyra commented Nov 23, 2022

Yes could you @nschonni - I'll see if we can get final review and merge 👍

@bsmth
Copy link
Member

bsmth commented Nov 23, 2022

Also having a look 👀

.markdownlint-cli2.jsonc Outdated Show resolved Hide resolved
.markdownlint-cli2.jsonc Outdated Show resolved Hide resolved
Copy link
Member

@bsmth bsmth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment open about using latest GH action, but can be addressed in a follow-up.

Edit: the gh action is now bumped to tj-actions/changed-files@v34

I don't see anything wrong (aside from failing CI 😄), so also leaving a LGTM 👍🏻

@nschonni
Copy link
Contributor Author

The failures for the job can be used to test the Autofix PR job

@nschonni
Copy link
Contributor Author

There is an odd fix for the headings in blockquote that I'm going to raise upstream, but not blocking this

@schalkneethling
Copy link

There is an odd fix for the headings in blockquote that I'm going to raise upstream, but not blocking this

Are we OK with Markdownlint failing? Looking at the log there are no "errors" but there are 20 warnings.

@nschonni
Copy link
Contributor Author

Upstream, they changed it from Errors to Warning to the severity. I'm not sure I get the benefit, as the job will fail either way, but I guess it looks less scary on the reviewers.

The 20 issues are fine, as this PR includes a new job that will create PRs to fix the existing issues. I created a manual one for the Japanese texts since there are formatting issues that the autofix won't quite handle. Landing this is fine though

@OnkarRuikar
Copy link
Contributor

Are we OK with Markdownlint failing? Looking at the log there are no "errors" but there are 20 warnings.

Yes. We don't want to burden online(on Github) contributors with lint errors, cos they may not know Markdown syntax, so the lint errors are marked as warning. Also because we have a bot in place that daily autofixes the lint issues.
We purposefully fail the job on warnings because it shows the indicator in PR list. And some maintainers proactively look for the failing test PRs and fix the lint issues.

Note: Fixing lint issues has been made mandatory for those who push changes using git.

@github-actions github-actions bot added the merge conflicts 🚧 This pull request has merge conflicts that must be resolved. label Nov 25, 2022
@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions github-actions bot removed the merge conflicts 🚧 This pull request has merge conflicts that must be resolved. label Nov 25, 2022
@caugner caugner merged commit 5368b08 into mdn:main Nov 25, 2022
@nschonni nschonni deleted the markdownlint-ci branch November 25, 2022 20:28
@nschonni
Copy link
Contributor Author

Thanks @caugner ! Now to wait and see how the auto-PRs go 😄

@yin1999
Copy link
Member

yin1999 commented Nov 26, 2022

Sorry for ignoring the PAT field, should we use AUTOMERGE_TOKEN in the markdownlint-fix workflow (for triggering PR test)?

token: ${{ secrets.AUTOMERGE_TOKEN }}

@nschonni
Copy link
Contributor Author

Yeah, I guess that would be needed to have the PRs trigger subsequent CI jobs

@hochan222

This comment was marked as outdated.

@OnkarRuikar
Copy link
Contributor

OnkarRuikar commented Nov 28, 2022

@hochan222 The error is not related to the changes done in that PR; it's related to the workflow code. Try re-running the workflow. Go to the latest failing check's log and click on Re-run jobs -> Re-run all jobs.

If that fails rebase the PR's branch, which will automatically trigger all the workflows..


Linting is should not mandatory. I suggest simply merge the PR. If there are linting errors, they will be fixed by cron job next midnight UTC.

@hochan222
Copy link
Member

hochan222 commented Nov 28, 2022

@OnkarRuikar Thank you for your reply. The error I encountered in various PRs was that the markdownlint workflow failed after further changes, even though the first time passed fine. Even running the workflow again failed the same. In the end, I asked contributors to rebase or re-commit for this. (Even though there are actually no markdownlint errors(maybe..?).. just for workflow)

image

Also, In the way to merge right away... the reason I wrote it for confirmation was because I was concerned about that it was displayed as an X ​​rather than a check. I'm afraid it will set a bad precedent. Nevertheless, if it's okay, I think it's better to just merge.

@hochan222
Copy link
Member

I merged PRs that failed the workflow, but the check went well as shown below. I think just merging would be fine.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
system Infrastructure and configuration for the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants