From 369a3ded9a2ee5540c7aea741a75a4cb61df8d62 Mon Sep 17 00:00:00 2001 From: Nate W Date: Wed, 21 Aug 2024 15:28:06 -0700 Subject: [PATCH] adding basic tooling: link, spell, & formatting checks adding CI/infra label Signed-off-by: Nate W --- .cspell.yml | 33 +++++++++++++++++++++++ .github/settings.yml | 3 +++ .github/workflows/format-check.yml | 29 ++++++++++++++++++++ .github/workflows/link-check.yml | 18 +++++++++++++ .github/workflows/spell-check.yml | 18 +++++++++++++ .gitignore | 3 +++ .markdown-link-check.json | 19 +++++++++++++ .markdownlint.yaml | 5 ++++ .nvmrc | 1 + package.json | 43 ++++++++++++++++++++++++++++++ 10 files changed, 172 insertions(+) create mode 100644 .cspell.yml create mode 100644 .github/workflows/format-check.yml create mode 100644 .github/workflows/link-check.yml create mode 100644 .github/workflows/spell-check.yml create mode 100644 .gitignore create mode 100644 .markdown-link-check.json create mode 100644 .markdownlint.yaml create mode 100644 .nvmrc create mode 100644 package.json diff --git a/.cspell.yml b/.cspell.yml new file mode 100644 index 00000000..8b5c029f --- /dev/null +++ b/.cspell.yml @@ -0,0 +1,33 @@ +# cSpell:ignore textlintrc +# For settings, see +# https://www.streetsidesoftware.com/vscode-spell-checker/docs/configuration/ +version: '0.2' +caseSensitive: true +#ignorePaths: + # Temporary + # - /assessments/ +# patterns: +# - name: CodeBlock +# pattern: | +# / +# ^(\s*[~`]{3,}) # code-block start +# .* # all languages and options, e.g. shell {hl_lines=[12]} +# [\s\S]*? # content +# \1 # code-block end +# /igmx # cspell:disable-line +# languageSettings: +# - languageId: markdown +# ignoreRegExpList: +# - CodeBlock +words: + - backstore + - CNCF + - Docsy + - keda + - kedacore + - mentee + - mentees + - summerofcode + - outreachy + - techdocs + - toto diff --git a/.github/settings.yml b/.github/settings.yml index 435791ae..95ba0f96 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -11,6 +11,9 @@ repository: homepage: https://mentoring.cncf.io labels: + - name: CI/infra + description: CI & infrastructure + color: #696969 - name: lfx mentorship color: a2dcf2 - name: enhancement diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml new file mode 100644 index 00000000..ec4f130a --- /dev/null +++ b/.github/workflows/format-check.yml @@ -0,0 +1,29 @@ +name: Format checks + +on: + pull_request: + +jobs: + format-check: + name: FILE FORMAT + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: npm + cache-dependency-path: package.json + - run: npm run check:format + + markdown-linter: + name: MARKDOWN linter + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: npm + cache-dependency-path: package.json + - run: npm run check:markdown diff --git a/.github/workflows/link-check.yml b/.github/workflows/link-check.yml new file mode 100644 index 00000000..5d4cb70a --- /dev/null +++ b/.github/workflows/link-check.yml @@ -0,0 +1,18 @@ +name: Link checks + +on: + pull_request: + +jobs: + link-check: + name: LINK checking + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: npm + cache-dependency-path: package.json + - name: Check file format + run: npm run check:links diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml new file mode 100644 index 00000000..dc1bfb9f --- /dev/null +++ b/.github/workflows/spell-check.yml @@ -0,0 +1,18 @@ +name: Spelling checks + +on: + pull_request: + +jobs: + spelling-check: + name: SPELLING check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: npm + cache-dependency-path: package.json + - name: Check file format + run: npm run check:spelling diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..7807fd3a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# npm assets +node_modules/ +package-lock.json diff --git a/.markdown-link-check.json b/.markdown-link-check.json new file mode 100644 index 00000000..b315dfe6 --- /dev/null +++ b/.markdown-link-check.json @@ -0,0 +1,19 @@ +{ + "ignorePatterns": [ + { + "pattern": "^http://localhost" + }, + { + "pattern": "^#" + }, + { + "pattern": "^https://(www|docs).tremor.rs" + }, + { + "pattern": "\\?no-link-check$" + } + ], + "timeout": "3s", + "retryOn429": true, + "aliveStatusCodes": [200, 206] +} diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 00000000..6eb808e6 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,5 @@ +# See https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md +# and https://github.com/DavidAnson/markdownlint/blob/main/README.md + +list-marker-space: false +no-inline-html: false diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..b009dfb9 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +lts/* diff --git a/package.json b/package.json new file mode 100644 index 00000000..37a8dbda --- /dev/null +++ b/package.json @@ -0,0 +1,43 @@ +{ + "name": "mentoring", + "version": "0.0.0", + "description": "Resources provided for and by the CNCF Mentoring community", + "scripts": { + "_check:format:any": "npx prettier --check --ignore-path ''", + "_check:format:delta": "npm run _check:format:any -- $(npm run -s _list:git:delta)", + "_check:format": "npx prettier --check .", + "_check:links": "npx markdown-link-check --config .markdown-link-check.json", + "_check:markdown:all": "npm run -s _list:check:md | xargs -I {} -P 4 npx -p markdownlint-cli markdownlint -c .markdownlint.yaml {}", + "_check:markdown:delta": "npm run -s _list:git:delta | xargs -I {} npx -p markdownlint-cli markdownlint -c .markdownlint.yaml {}", + "_check:markdown:1": "npx -p markdownlint-cli markdownlint -c .markdownlint.yaml", + "_list:git:delta": "git diff --name-only --diff-filter=ACMR | grep -E '\\.(js|md|scss|yml|yaml)$'", + "_list:check:md:no-analysis": "find . -name '*.md' -not -path '*/node_modules/*' -a -not -path '*/.?*' -a -not -path '*/00*'", + "_list:check:md": "find . -name '*.md' -not -path '*/node_modules/*' -a -not -path '*/.?*' | grep -Eve '/000|/0010|/0011'", + "_list:check:*": "npm run --loglevel=warn | grep -Ee '^\\s*check:[^:]+$'", + "_list:fix:*": "npm run --loglevel=warn | grep -Ee '^\\s*fix:[^:]+$' | grep -v 'fix:all'", + "check:format": "npm run _check:format || (echo '[help] Run: npm run fix:format'; exit 1)", + "check:links": "bash -c 'for f in *.md `find docs analyses -name \"*.md\"`; do npx markdown-link-check --config .markdown-link-check.json $f || exit 1; done'", + "check:markdown": "npm run _check:markdown:all", + "check:spelling": "npx cspell --no-progress -c .cspell.yml **/*.md", + "check": "npm run seq -- $(npm run -s _list:check:*)", + "fix:format": "npm run _check:format -- --write", + "fix": "npm run seq -- $(npm -s run _list:fix:*)", + "seq": "bash -c 'for cmd in \"$@\"; do npm run $cmd || exit 1; done' - ", + "test": "npm run check" + }, + "author": "CNCF", + "license": "CC-BY-4.0", + "devDependencies": { + "cspell": "^8.8.4", + "markdown-link-check": "^3.12.2", + "markdownlint": "^0.34.0", + "markdownlint-cli": "^0.41.0", + "prettier": "^3.3.2" + }, + "private": true, + "spelling": "cSpell:ignore ACMR loglevel -", + "prettier": { + "proseWrap": "always", + "singleQuote": true + } +}