From 2e35b25a56b35a742d782333daedc16733958498 Mon Sep 17 00:00:00 2001 From: Tyler Carrol Date: Mon, 28 Oct 2024 19:56:27 -0400 Subject: [PATCH 1/6] =?UTF-8?q?=E2=9C=A8=20feature:=20Add=20MegaLinter=20W?= =?UTF-8?q?orkflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cspell.json | 23 ++++++ .github/workflows/mega-linter.yml | 115 ++++++++++++++++++++++++++++++ .markdownlint.yaml | 12 ++++ .mega-linter.yml | 24 +++++++ 4 files changed, 174 insertions(+) create mode 100644 .cspell.json create mode 100644 .github/workflows/mega-linter.yml create mode 100644 .markdownlint.yaml create mode 100644 .mega-linter.yml diff --git a/.cspell.json b/.cspell.json new file mode 100644 index 0000000..669c7fb --- /dev/null +++ b/.cspell.json @@ -0,0 +1,23 @@ +{ + "version": "0.2", + "language": "en", + "ignorePaths": [ + "**/node_modules/**", + "**/vscode-extension/**", + "**/.git/**", + "**/.pnpm-lock.json", + ".vscode", + "package-lock.json", + "megalinter-reports" + ], + "words": [ + "nupkg", + "msbuild", + "megalinter", + "markdownlint", + "KICS", + "Carrol", + "ncipollo", + "stefanzweifel" + ] +} diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml new file mode 100644 index 0000000..361a605 --- /dev/null +++ b/.github/workflows/mega-linter.yml @@ -0,0 +1,115 @@ +# MegaLinter GitHub Action configuration file +# More info at https://megalinter.io +# https://github.com/oxsecurity/megalinter/blob/main/TEMPLATES/mega-linter.yml +--- +name: MegaLinter +run-name: >- + ${{ + format( + '{0} - MegaLinter{1}', + github.event_name == 'pull_request' + && format('PR#{0}{1}', github.event.number, github.event.pull_request.draft && ' [DRAFT]' || '') + || format('Push [{0}]', github.ref_name), + github.event_name == 'pull_request' + && format(' - [{0}-to-{1}]', github.event.pull_request.head.ref, github.event.pull_request.base.ref) + || '' + ) + }} + +on: + push: + branches: + - main + pull_request: + branches: + - main + pull_request_target: + types: + - edited + branches: + - main + +concurrency: + group: MegaLinter-${{ github.ref_name }} + cancel-in-progress: true + +jobs: + megalinter: + name: MegaLinter + runs-on: ubuntu-latest + + # Give the default GITHUB_TOKEN write permission to commit and push, comment + # issues & post new PR; remove the ones you do not need + permissions: + contents: write + issues: write + pull-requests: write + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + + - name: MegaLinter + uses: oxsecurity/megalinter@v8 + id: megalinter + env: + CONFIG_FILE: .mega-linter.yml + # Only validate the whole codebase on push to main + VALIDATE_ALL_CODEBASE: >- + ${{ + github.event_name == 'push' && + contains(fromJSON('["refs/heads/main"]'), github.ref) + }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Upload MegaLinter artifacts + - name: Archive production artifacts + uses: actions/upload-artifact@v4 + if: success() || failure() + with: + name: MegaLinter reports + path: | + megalinter-reports + mega-linter.log + + # Delete MegaLinter reports before creating PR + - name: Delete MegaLinter Reports + if: ${{ (success() || failure()) && steps.megalinter.outputs.has_updated_sources == 1 }} + run: | + sudo rm -rf megalinter-reports + sudo rm -f mega-linter.log + + # Create pull request if applicable + - name: Create Pull Request with applied fixes [${{ steps.megalinter.outputs.has_updated_sources }}] + uses: peter-evans/create-pull-request@v6 + id: create-pr + if: ${{ (success() || failure()) && steps.megalinter.outputs.has_updated_sources == 1 }} + with: + token: ${{ secrets.TJC_TOKEN || secrets.GITHUB_TOKEN }} + base: ${{ github.event.pull_request.head.ref }} + branch: MegaLinter-${{ github.event.pull_request.head.ref }} + branch-suffix: short-commit-hash + title: "🧹 chore: [MegaLinter] Apply [${{ steps.megalinter.outputs.has_updated_sources }}] automatic fixes" + commit-message: "🧹 chore: [MegaLinter] Apply [${{ steps.megalinter.outputs.has_updated_sources }}] automatic fixes" + body: >- + ${{ + format( + '[MegaLinter](.github/workflows/mega-linter.yml) - Merge [{0}] {1} for {2}', + steps.megalinter.outputs.has_updated_sources, + steps.megalinter.outputs.has_updated_sources == 1 && 'fix' || 'fixes', + github.event_name == 'pull_request' + && format('PR #{0}', github.event.pull_request.number) + || format('Push to [{0}]', github.ref_name) + ) + }} + assignees: TylerCarrol + labels: bot,linter + + - name: Create PR output + if: ${{ (success() || failure()) && steps.megalinter.outputs.has_updated_sources == 1 }} + run: | + echo "PR Number - ${{ steps.create-pr.outputs.pull-request-number }}" + echo "PR URL - ${{ steps.create-pr.outputs.pull-request-url }}" diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..52bf27b --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,12 @@ +# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml + +# Default state for all rules +default: true + +# Path to configuration file to extend +extends: null + +# MD024/no-duplicate-heading : Multiple headings with the same content +MD024: + # Only check sibling headings (to allow changelogs to have duplicate headings) + siblings_only: true diff --git a/.mega-linter.yml b/.mega-linter.yml new file mode 100644 index 0000000..c96b869 --- /dev/null +++ b/.mega-linter.yml @@ -0,0 +1,24 @@ +# Configuration file for MegaLinter +# See all available variables at: https://megalinter.io/latest/configuration/ and in linters documentation +# See .NET Flavor at: https://megalinter.io/latest/flavors/dotnet/ +APPLY_FIXES: all +ENABLE: + - REPOSITORY + - COPYPASTE + - SPELL + - ACTION + - CSHARP + - MARKDOWN + - POWERSHELL + - SQL + - HTML + - CSS + - JSON + - XML + - YAML +DISABLE_LINTERS: + - REPOSITORY_CHECKOV + - REPOSITORY_KICS + - REPOSITORY_TRIVY +PRINT_ALPACA: true +SHOW_ELAPSED_TIME: true From b655e89e12bbcddd9f1fd466e777c52f0a9a6630 Mon Sep 17 00:00:00 2001 From: Tyler Carrol Date: Mon, 28 Oct 2024 20:15:20 -0400 Subject: [PATCH 2/6] Create .jscpd.json to ignore duplication within .Tests --- .jscpd.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .jscpd.json diff --git a/.jscpd.json b/.jscpd.json new file mode 100644 index 0000000..8249127 --- /dev/null +++ b/.jscpd.json @@ -0,0 +1,3 @@ +{ + "ignore": ["*.Tests/**"] +} From cf65fc32829fa08770c1934d1b0045937a97f778 Mon Sep 17 00:00:00 2001 From: Tyler Carrol Date: Mon, 28 Oct 2024 20:29:42 -0400 Subject: [PATCH 3/6] Update .jscpd.json to include duplication threshold --- .jscpd.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.jscpd.json b/.jscpd.json index 8249127..da0f95a 100644 --- a/.jscpd.json +++ b/.jscpd.json @@ -1,3 +1,4 @@ { + "threshold": 3, "ignore": ["*.Tests/**"] } From 093bf3956e6818a8badcc3e47e821f13ada4d26f Mon Sep 17 00:00:00 2001 From: Tyler Carrol Date: Mon, 28 Oct 2024 20:43:39 -0400 Subject: [PATCH 4/6] Update .jscpd.json --- .jscpd.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.jscpd.json b/.jscpd.json index da0f95a..a23d506 100644 --- a/.jscpd.json +++ b/.jscpd.json @@ -1,4 +1,6 @@ { - "threshold": 3, + "min-tokens": 50, + "min-lines": 5, + "max-duplicate-count": 2, "ignore": ["*.Tests/**"] } From 02be096957264be01a5dca3c18d14f491c45c78e Mon Sep 17 00:00:00 2001 From: Tyler Carrol Date: Mon, 28 Oct 2024 20:56:01 -0400 Subject: [PATCH 5/6] Update .jscpd.json --- .jscpd.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jscpd.json b/.jscpd.json index a23d506..2e60a42 100644 --- a/.jscpd.json +++ b/.jscpd.json @@ -1,6 +1,6 @@ { "min-tokens": 50, "min-lines": 5, - "max-duplicate-count": 2, + "threshold": 0.1, "ignore": ["*.Tests/**"] } From d6d87a87430bf9a5d59b57294de240142f74806d Mon Sep 17 00:00:00 2001 From: Tyler Carrol Date: Mon, 28 Oct 2024 21:04:00 -0400 Subject: [PATCH 6/6] Update .jscpd.json --- .jscpd.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/.jscpd.json b/.jscpd.json index 2e60a42..3806512 100644 --- a/.jscpd.json +++ b/.jscpd.json @@ -1,6 +1,4 @@ { - "min-tokens": 50, - "min-lines": 5, "threshold": 0.1, "ignore": ["*.Tests/**"] }