Skip to content

Commit 077495f

Browse files
authored
✨ feature: Add MegaLinter Workflow (#75)
* ✨ feature: Add MegaLinter Workflow * Create .jscpd.json to ignore duplication within .Tests * Update .jscpd.json to include duplication threshold
1 parent 22293e6 commit 077495f

5 files changed

Lines changed: 178 additions & 0 deletions

File tree

.cspell.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"version": "0.2",
3+
"language": "en",
4+
"ignorePaths": [
5+
"**/node_modules/**",
6+
"**/vscode-extension/**",
7+
"**/.git/**",
8+
"**/.pnpm-lock.json",
9+
".vscode",
10+
"package-lock.json",
11+
"megalinter-reports"
12+
],
13+
"words": [
14+
"nupkg",
15+
"msbuild",
16+
"megalinter",
17+
"markdownlint",
18+
"KICS",
19+
"Carrol",
20+
"ncipollo",
21+
"stefanzweifel"
22+
]
23+
}

.github/workflows/mega-linter.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# MegaLinter GitHub Action configuration file
2+
# More info at https://megalinter.io
3+
# https://github.com/oxsecurity/megalinter/blob/main/TEMPLATES/mega-linter.yml
4+
---
5+
name: MegaLinter
6+
run-name: >-
7+
${{
8+
format(
9+
'{0} - MegaLinter{1}',
10+
github.event_name == 'pull_request'
11+
&& format('PR#{0}{1}', github.event.number, github.event.pull_request.draft && ' [DRAFT]' || '')
12+
|| format('Push [{0}]', github.ref_name),
13+
github.event_name == 'pull_request'
14+
&& format(' - [{0}-to-{1}]', github.event.pull_request.head.ref, github.event.pull_request.base.ref)
15+
|| ''
16+
)
17+
}}
18+
19+
on:
20+
push:
21+
branches:
22+
- main
23+
pull_request:
24+
branches:
25+
- main
26+
pull_request_target:
27+
types:
28+
- edited
29+
branches:
30+
- main
31+
32+
concurrency:
33+
group: MegaLinter-${{ github.ref_name }}
34+
cancel-in-progress: true
35+
36+
jobs:
37+
megalinter:
38+
name: MegaLinter
39+
runs-on: ubuntu-latest
40+
41+
# Give the default GITHUB_TOKEN write permission to commit and push, comment
42+
# issues & post new PR; remove the ones you do not need
43+
permissions:
44+
contents: write
45+
issues: write
46+
pull-requests: write
47+
48+
steps:
49+
- name: Checkout Code
50+
uses: actions/checkout@v4
51+
with:
52+
token: ${{ secrets.GITHUB_TOKEN }}
53+
fetch-depth: 0
54+
55+
- name: MegaLinter
56+
uses: oxsecurity/megalinter@v8
57+
id: megalinter
58+
env:
59+
CONFIG_FILE: .mega-linter.yml
60+
# Only validate the whole codebase on push to main
61+
VALIDATE_ALL_CODEBASE: >-
62+
${{
63+
github.event_name == 'push' &&
64+
contains(fromJSON('["refs/heads/main"]'), github.ref)
65+
}}
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
68+
# Upload MegaLinter artifacts
69+
- name: Archive production artifacts
70+
uses: actions/upload-artifact@v4
71+
if: success() || failure()
72+
with:
73+
name: MegaLinter reports
74+
path: |
75+
megalinter-reports
76+
mega-linter.log
77+
78+
# Delete MegaLinter reports before creating PR
79+
- name: Delete MegaLinter Reports
80+
if: ${{ (success() || failure()) && steps.megalinter.outputs.has_updated_sources == 1 }}
81+
run: |
82+
sudo rm -rf megalinter-reports
83+
sudo rm -f mega-linter.log
84+
85+
# Create pull request if applicable
86+
- name: Create Pull Request with applied fixes [${{ steps.megalinter.outputs.has_updated_sources }}]
87+
uses: peter-evans/create-pull-request@v6
88+
id: create-pr
89+
if: ${{ (success() || failure()) && steps.megalinter.outputs.has_updated_sources == 1 }}
90+
with:
91+
token: ${{ secrets.TJC_TOKEN || secrets.GITHUB_TOKEN }}
92+
base: ${{ github.event.pull_request.head.ref }}
93+
branch: MegaLinter-${{ github.event.pull_request.head.ref }}
94+
branch-suffix: short-commit-hash
95+
title: "🧹 chore: [MegaLinter] Apply [${{ steps.megalinter.outputs.has_updated_sources }}] automatic fixes"
96+
commit-message: "🧹 chore: [MegaLinter] Apply [${{ steps.megalinter.outputs.has_updated_sources }}] automatic fixes"
97+
body: >-
98+
${{
99+
format(
100+
'[MegaLinter](.github/workflows/mega-linter.yml) - Merge [{0}] {1} for {2}',
101+
steps.megalinter.outputs.has_updated_sources,
102+
steps.megalinter.outputs.has_updated_sources == 1 && 'fix' || 'fixes',
103+
github.event_name == 'pull_request'
104+
&& format('PR #{0}', github.event.pull_request.number)
105+
|| format('Push to [{0}]', github.ref_name)
106+
)
107+
}}
108+
assignees: TylerCarrol
109+
labels: bot,linter
110+
111+
- name: Create PR output
112+
if: ${{ (success() || failure()) && steps.megalinter.outputs.has_updated_sources == 1 }}
113+
run: |
114+
echo "PR Number - ${{ steps.create-pr.outputs.pull-request-number }}"
115+
echo "PR URL - ${{ steps.create-pr.outputs.pull-request-url }}"

.jscpd.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"threshold": 0.1,
3+
"ignore": ["*.Tests/**"]
4+
}

.markdownlint.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
2+
3+
# Default state for all rules
4+
default: true
5+
6+
# Path to configuration file to extend
7+
extends: null
8+
9+
# MD024/no-duplicate-heading : Multiple headings with the same content
10+
MD024:
11+
# Only check sibling headings (to allow changelogs to have duplicate headings)
12+
siblings_only: true

.mega-linter.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Configuration file for MegaLinter
2+
# See all available variables at: https://megalinter.io/latest/configuration/ and in linters documentation
3+
# See .NET Flavor at: https://megalinter.io/latest/flavors/dotnet/
4+
APPLY_FIXES: all
5+
ENABLE:
6+
- REPOSITORY
7+
- COPYPASTE
8+
- SPELL
9+
- ACTION
10+
- CSHARP
11+
- MARKDOWN
12+
- POWERSHELL
13+
- SQL
14+
- HTML
15+
- CSS
16+
- JSON
17+
- XML
18+
- YAML
19+
DISABLE_LINTERS:
20+
- REPOSITORY_CHECKOV
21+
- REPOSITORY_KICS
22+
- REPOSITORY_TRIVY
23+
PRINT_ALPACA: true
24+
SHOW_ELAPSED_TIME: true

0 commit comments

Comments
 (0)