Skip to content

Commit ff73735

Browse files
committed
feat: add mega-linter
1 parent e5fe46f commit ff73735

File tree

5 files changed

+249
-4
lines changed

5 files changed

+249
-4
lines changed

.cspell.json

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

.editorconfig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ root = true
33
[*]
44
charset = utf-8
55
end_of_line = lf
6-
indent_size = 4
6+
indent_size = 2
77
indent_style = space
88
insert_final_newline = true
99
max_line_length = 160
10-
tab_width = 4
10+
tab_width = 2
1111
trim_trailing_whitespace = true
1212

13-
[*.{json, md, yaml, yml, proto}]
14-
indent_size = 2
13+
[*.{toml,rs}]
14+
indent_size = 4
15+
tab_width = 4
1516

.github/workflows/mega-linter.yml

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

.jscpd.json

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

.mega-linter.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
FILEIO_REPORTER: false
24+
25+
# Uncomment if you want MegaLinter to detect errors but not block CI to pass
26+
# DISABLE_ERRORS: true

0 commit comments

Comments
 (0)