Skip to content

Commit 32dd79b

Browse files
committed
chore(ci): add MegaLinter configuration and GitHub Action
- Introduced `.mega-linter.yml` for MegaLinter settings. - Added `.jscpd.json` to configure code duplication checks. - Set up GitHub Action workflow for MegaLinter to validate code on push and pull requests. - Updated `.gitignore` to exclude MegaLinter reports.
1 parent be663a0 commit 32dd79b

File tree

5 files changed

+266
-3
lines changed

5 files changed

+266
-3
lines changed

.cspell.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"ignorePaths": [
3+
"**/node_modules/**",
4+
"**/vscode-extension/**",
5+
"**/.git/**",
6+
"**/.pnpm-lock.json",
7+
".vscode",
8+
"megalinter",
9+
"package-lock.json",
10+
"report"
11+
],
12+
"language": "en",
13+
"noConfigSearch": true,
14+
"words": ["megalinter", "oxsecurity"],
15+
"version": "0.2"
16+
}

.github/workflows/mega-linter.yml

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
# MegaLinter GitHub Action configuration file
2+
# More info at https://megalinter.io
3+
---
4+
name: MegaLinter
5+
6+
# Trigger mega-linter at every push. Action will also be visible from
7+
# Pull Requests to main
8+
on:
9+
# Comment this line to trigger action only on pull-requests
10+
# (not recommended if you don't pay for GH Actions)
11+
push:
12+
13+
pull_request:
14+
branches:
15+
- main
16+
- master
17+
18+
# Comment env block if you do not want to apply fixes
19+
env:
20+
# Apply linter fixes configuration
21+
#
22+
# When active, APPLY_FIXES must also be defined as environment variable
23+
# (in github/workflows/mega-linter.yml or other CI tool)
24+
APPLY_FIXES: all
25+
26+
# Decide which event triggers application of fixes in a commit or a PR
27+
# (pull_request, push, all)
28+
APPLY_FIXES_EVENT: pull_request
29+
30+
# If APPLY_FIXES is used, defines if the fixes are directly committed (commit)
31+
# or posted in a PR (pull_request)
32+
APPLY_FIXES_MODE: commit
33+
34+
concurrency:
35+
group: ${{ github.ref }}-${{ github.workflow }}
36+
cancel-in-progress: true
37+
38+
jobs:
39+
megalinter:
40+
name: MegaLinter
41+
runs-on: ubuntu-latest
42+
43+
# Give the default GITHUB_TOKEN write permission to commit and push, comment
44+
# issues, and post new Pull Requests; remove the ones you do not need
45+
permissions:
46+
contents: write
47+
issues: write
48+
pull-requests: write
49+
50+
steps:
51+
# Git Checkout
52+
- name: Checkout Code
53+
uses: actions/checkout@v6
54+
with:
55+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
56+
57+
# If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to
58+
# improve performance
59+
fetch-depth: 0
60+
61+
# MegaLinter
62+
- name: MegaLinter
63+
64+
# You can override MegaLinter flavor used to have faster performances
65+
# More info at https://megalinter.io/latest/flavors/
66+
uses: oxsecurity/megalinter@v9
67+
68+
id: ml
69+
70+
# All available variables are described in documentation
71+
# https://megalinter.io/latest/config-file/
72+
env:
73+
# Validates all source when push on main, else just the git diff with
74+
# main. Override with true if you always want to lint all sources
75+
#
76+
# To validate the entire codebase, set to:
77+
# VALIDATE_ALL_CODEBASE: true
78+
#
79+
# To validate only diff with main, set to:
80+
# VALIDATE_ALL_CODEBASE: >-
81+
# ${{
82+
# github.event_name == 'push' &&
83+
# github.ref == 'refs/heads/main'
84+
# }}
85+
VALIDATE_ALL_CODEBASE: true
86+
87+
# Disable LLM Advisor for bot PRs (dependabot, renovate, etc.)
88+
LLM_ADVISOR_ENABLED: >-
89+
${{
90+
github.event_name != 'pull_request' ||
91+
(github.event.pull_request.user.login != 'dependabot[bot]' &&
92+
github.event.pull_request.user.login != 'renovate[bot]' &&
93+
github.event.pull_request.user.login != 'github-actions[bot]' &&
94+
!startsWith(github.event.pull_request.user.login, 'dependabot') &&
95+
!startsWith(github.event.pull_request.user.login, 'renovate'))
96+
}}
97+
98+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+
100+
# Uncomment to use ApiReporter (Grafana)
101+
# API_REPORTER: true
102+
# API_REPORTER_URL: ${{ secrets.API_REPORTER_URL }}
103+
# API_REPORTER_BASIC_AUTH_USERNAME: ${{ secrets.API_REPORTER_BASIC_AUTH_USERNAME }}
104+
# API_REPORTER_BASIC_AUTH_PASSWORD: ${{ secrets.API_REPORTER_BASIC_AUTH_PASSWORD }}
105+
# API_REPORTER_METRICS_URL: ${{ secrets.API_REPORTER_METRICS_URL }}
106+
# API_REPORTER_METRICS_BASIC_AUTH_USERNAME: ${{ secrets.API_REPORTER_METRICS_BASIC_AUTH_USERNAME }}
107+
# API_REPORTER_METRICS_BASIC_AUTH_PASSWORD: ${{ secrets.API_REPORTER_METRICS_BASIC_AUTH_PASSWORD }}
108+
# API_REPORTER_DEBUG: false
109+
110+
# ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF
111+
# .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
112+
113+
# Upload MegaLinter artifacts
114+
- name: Archive production artifacts
115+
uses: actions/upload-artifact@v4
116+
if: success() || failure()
117+
with:
118+
name: MegaLinter reports
119+
include-hidden-files: "true"
120+
path: |
121+
megalinter-reports
122+
mega-linter.log
123+
124+
# Create pull request if applicable
125+
# (for now works only on PR from same repository, not from forks)
126+
- name: Create Pull Request with applied fixes
127+
uses: peter-evans/create-pull-request@v7
128+
id: cpr
129+
if: >-
130+
steps.ml.outputs.has_updated_sources == 1 &&
131+
(
132+
env.APPLY_FIXES_EVENT == 'all' ||
133+
env.APPLY_FIXES_EVENT == github.event_name
134+
) &&
135+
env.APPLY_FIXES_MODE == 'pull_request' &&
136+
(
137+
github.event_name == 'push' ||
138+
github.event.pull_request.head.repo.full_name == github.repository
139+
) &&
140+
!contains(github.event.head_commit.message, 'skip fix')
141+
with:
142+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
143+
commit-message: "[MegaLinter] Apply linters automatic fixes"
144+
title: "[MegaLinter] Apply linters automatic fixes"
145+
labels: bot
146+
147+
- name: Create PR output
148+
if: >-
149+
steps.ml.outputs.has_updated_sources == 1 &&
150+
(
151+
env.APPLY_FIXES_EVENT == 'all' ||
152+
env.APPLY_FIXES_EVENT == github.event_name
153+
) &&
154+
env.APPLY_FIXES_MODE == 'pull_request' &&
155+
(
156+
github.event_name == 'push' ||
157+
github.event.pull_request.head.repo.full_name == github.repository
158+
) &&
159+
!contains(github.event.head_commit.message, 'skip fix')
160+
run: |
161+
echo "PR Number - ${{ steps.cpr.outputs.pull-request-number }}"
162+
echo "PR URL - ${{ steps.cpr.outputs.pull-request-url }}"
163+
164+
# Push new commit if applicable
165+
# (for now works only on PR from same repository, not from forks)
166+
- name: Prepare commit
167+
if: >-
168+
steps.ml.outputs.has_updated_sources == 1 &&
169+
(
170+
env.APPLY_FIXES_EVENT == 'all' ||
171+
env.APPLY_FIXES_EVENT == github.event_name
172+
) &&
173+
env.APPLY_FIXES_MODE == 'commit' &&
174+
github.ref != 'refs/heads/main' &&
175+
(
176+
github.event_name == 'push' ||
177+
github.event.pull_request.head.repo.full_name == github.repository
178+
) &&
179+
!contains(github.event.head_commit.message, 'skip fix')
180+
run: sudo chown -Rc $UID .git/
181+
182+
- name: Commit and push applied linter fixes
183+
uses: stefanzweifel/git-auto-commit-action@v7
184+
if: >-
185+
steps.ml.outputs.has_updated_sources == 1 &&
186+
(
187+
env.APPLY_FIXES_EVENT == 'all' ||
188+
env.APPLY_FIXES_EVENT == github.event_name
189+
) &&
190+
env.APPLY_FIXES_MODE == 'commit' &&
191+
github.ref != 'refs/heads/main' &&
192+
(
193+
github.event_name == 'push' ||
194+
github.event.pull_request.head.repo.full_name == github.repository
195+
) &&
196+
!contains(github.event.head_commit.message, 'skip fix')
197+
with:
198+
branch: >-
199+
${{
200+
github.event.pull_request.head.ref ||
201+
github.head_ref ||
202+
github.ref
203+
}}
204+
commit_message: "[MegaLinter] Apply linters fixes"
205+
commit_user_name: megalinter-bot
206+
commit_user_email: 129584137+megalinter-bot@users.noreply.github.com

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ dev-dist
33
_test/
44
schema.json
55

6+
# Sentry Config File
7+
.env.sentry-build-plugin
8+
9+
megalinter-reports/
10+
611
# Created by https://www.toptal.com/developers/gitignore/api/node,linux,macos,svelte,windows,jetbrains,sublimetext,visualstudiocode,venv
712
# Edit at https://www.toptal.com/developers/gitignore?templates=node,linux,macos,svelte,windows,jetbrains,sublimetext,visualstudiocode,venv
813

@@ -401,6 +406,3 @@ $RECYCLE.BIN/
401406
*.lnk
402407

403408
# End of https://www.toptal.com/developers/gitignore/api/node,linux,macos,svelte,windows,jetbrains,sublimetext,visualstudiocode,venv
404-
405-
# Sentry Config File
406-
.env.sentry-build-plugin

.jscpd.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"threshold": 0,
3+
"reporters": ["html", "markdown"],
4+
"ignore": [
5+
"**/node_modules/**",
6+
"**/.git/**",
7+
"**/.rbenv/**",
8+
"**/.venv/**",
9+
"**/*cache*/**",
10+
"**/.github/**",
11+
"**/.idea/**",
12+
"**/report/**",
13+
"**/*.svg"
14+
]
15+
}

.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+
#
3+
# See all available variables at https://megalinter.io/latest/config-file/ and in
4+
# linters documentation
5+
6+
# all, none, or list of linter keys
7+
APPLY_FIXES: all
8+
9+
# If you use ENABLE variable, all other languages/formats/tooling-formats will
10+
# be disabled by default
11+
# ENABLE:
12+
13+
# If you use ENABLE_LINTERS variable, all other linters will be disabled by
14+
# default
15+
# ENABLE_LINTERS:
16+
17+
# DISABLE:
18+
# - COPYPASTE # Uncomment to disable checks of excessive copy-pastes
19+
# - SPELL # Uncomment to disable checks of spelling mistakes
20+
21+
SHOW_ELAPSED_TIME: true
22+
23+
# Uncomment if you want MegaLinter to detect errors but not block CI to pass
24+
# DISABLE_ERRORS: true

0 commit comments

Comments
 (0)