Skip to content

Commit 635aba0

Browse files
committed
ci: update megalinter
1 parent c9a3775 commit 635aba0

4 files changed

Lines changed: 167 additions & 38 deletions

File tree

.cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"**/node_modules/**",
44
"**/vscode-extension/**",
55
"**/.git/**",
6+
"**/.pnpm-lock.json",
67
".vscode",
78
"megalinter",
89
"package-lock.json",

.github/workflows/mega-linter.yml

Lines changed: 146 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,196 @@
1-
---
21
# MegaLinter GitHub Action configuration file
3-
# More info at https://megalinter.github.io
2+
# More info at https://megalinter.io
3+
---
44
name: MegaLinter
55

6+
# Trigger mega-linter at every push. Action will also be visible from
7+
# Pull Requests to main
68
on:
7-
# Trigger mega-linter at every push. Action will also be visible from Pull Requests to master
8-
push: # Comment this line to trigger action only on pull-requests (not recommended if you don't pay for GH Actions)
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+
913
pull_request:
10-
branches: [master, main]
14+
branches:
15+
- main
16+
- master
1117

12-
env: # Comment env block if you do not want to apply fixes
18+
# Comment env block if you do not want to apply fixes
19+
env:
1320
# Apply linter fixes configuration
14-
APPLY_FIXES: all # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool)
15-
APPLY_FIXES_EVENT: pull_request # Decide which event triggers application of fixes in a commit or a PR (pull_request, push, all)
16-
APPLY_FIXES_MODE: commit # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) or posted in a PR (pull_request)
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
1733

1834
concurrency:
1935
group: ${{ github.ref }}-${{ github.workflow }}
2036
cancel-in-progress: true
2137

2238
jobs:
23-
build:
39+
megalinter:
2440
name: MegaLinter
2541
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+
2650
steps:
2751
# Git Checkout
2852
- name: Checkout Code
29-
uses: actions/checkout@v2
53+
uses: actions/checkout@v4
3054
with:
3155
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
56+
57+
# If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to
58+
# improve performance
3259
fetch-depth: 0
3360

3461
# MegaLinter
3562
- name: MegaLinter
36-
id: ml
63+
3764
# You can override MegaLinter flavor used to have faster performances
38-
# More info at https://megalinter.github.io/flavors/
39-
uses: megalinter/megalinter@v5
65+
# More info at https://megalinter.io/latest/flavors/
66+
uses: oxsecurity/megalinter@v8
67+
68+
id: ml
69+
70+
# All available variables are described in documentation
71+
# https://megalinter.io/latest/config-file/
4072
env:
41-
# All available variables are described in documentation
42-
# https://megalinter.github.io/configuration/
43-
VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
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: >-
86+
${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
87+
4488
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45-
# ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
89+
90+
# Uncomment to use ApiReporter (Grafana)
91+
# API_REPORTER: true
92+
# API_REPORTER_URL: ${{ secrets.API_REPORTER_URL }}
93+
# API_REPORTER_BASIC_AUTH_USERNAME: ${{ secrets.API_REPORTER_BASIC_AUTH_USERNAME }}
94+
# API_REPORTER_BASIC_AUTH_PASSWORD: ${{ secrets.API_REPORTER_BASIC_AUTH_PASSWORD }}
95+
# API_REPORTER_METRICS_URL: ${{ secrets.API_REPORTER_METRICS_URL }}
96+
# API_REPORTER_METRICS_BASIC_AUTH_USERNAME: ${{ secrets.API_REPORTER_METRICS_BASIC_AUTH_USERNAME }}
97+
# API_REPORTER_METRICS_BASIC_AUTH_PASSWORD: ${{ secrets.API_REPORTER_METRICS_BASIC_AUTH_PASSWORD }}
98+
# API_REPORTER_DEBUG: false
99+
100+
# ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF
101+
# .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
46102

47103
# Upload MegaLinter artifacts
48104
- name: Archive production artifacts
49-
if: ${{ success() }} || ${{ failure() }}
50-
uses: actions/upload-artifact@v2
105+
uses: actions/upload-artifact@v4
106+
if: success() || failure()
51107
with:
52108
name: MegaLinter reports
109+
include-hidden-files: "true"
53110
path: |
54-
report
111+
megalinter-reports
55112
mega-linter.log
56113
57-
# Create pull request if applicable (for now works only on PR from same repository, not from forks)
114+
# Create pull request if applicable
115+
# (for now works only on PR from same repository, not from forks)
58116
- name: Create Pull Request with applied fixes
117+
uses: peter-evans/create-pull-request@v6
59118
id: cpr
60-
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
61-
uses: peter-evans/create-pull-request@v3
119+
if: >-
120+
steps.ml.outputs.has_updated_sources == 1 &&
121+
(
122+
env.APPLY_FIXES_EVENT == 'all' ||
123+
env.APPLY_FIXES_EVENT == github.event_name
124+
) &&
125+
env.APPLY_FIXES_MODE == 'pull_request' &&
126+
(
127+
github.event_name == 'push' ||
128+
github.event.pull_request.head.repo.full_name == github.repository
129+
) &&
130+
!contains(github.event.head_commit.message, 'skip fix')
62131
with:
63132
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
64133
commit-message: "[MegaLinter] Apply linters automatic fixes"
65134
title: "[MegaLinter] Apply linters automatic fixes"
66135
labels: bot
136+
67137
- name: Create PR output
68-
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
138+
if: >-
139+
steps.ml.outputs.has_updated_sources == 1 &&
140+
(
141+
env.APPLY_FIXES_EVENT == 'all' ||
142+
env.APPLY_FIXES_EVENT == github.event_name
143+
) &&
144+
env.APPLY_FIXES_MODE == 'pull_request' &&
145+
(
146+
github.event_name == 'push' ||
147+
github.event.pull_request.head.repo.full_name == github.repository
148+
) &&
149+
!contains(github.event.head_commit.message, 'skip fix')
69150
run: |
70-
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
71-
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
151+
echo "PR Number - ${{ steps.cpr.outputs.pull-request-number }}"
152+
echo "PR URL - ${{ steps.cpr.outputs.pull-request-url }}"
72153
73-
# Push new commit if applicable (for now works only on PR from same repository, not from forks)
154+
# Push new commit if applicable
155+
# (for now works only on PR from same repository, not from forks)
74156
- name: Prepare commit
75-
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
157+
if: >-
158+
steps.ml.outputs.has_updated_sources == 1 &&
159+
(
160+
env.APPLY_FIXES_EVENT == 'all' ||
161+
env.APPLY_FIXES_EVENT == github.event_name
162+
) &&
163+
env.APPLY_FIXES_MODE == 'commit' &&
164+
github.ref != 'refs/heads/main' &&
165+
(
166+
github.event_name == 'push' ||
167+
github.event.pull_request.head.repo.full_name == github.repository
168+
) &&
169+
!contains(github.event.head_commit.message, 'skip fix')
76170
run: sudo chown -Rc $UID .git/
171+
77172
- name: Commit and push applied linter fixes
78-
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
79-
uses: stefanzweifel/git-auto-commit-action@v4
173+
uses: stefanzweifel/git-auto-commit-action@v5
174+
if: >-
175+
steps.ml.outputs.has_updated_sources == 1 &&
176+
(
177+
env.APPLY_FIXES_EVENT == 'all' ||
178+
env.APPLY_FIXES_EVENT == github.event_name
179+
) &&
180+
env.APPLY_FIXES_MODE == 'commit' &&
181+
github.ref != 'refs/heads/main' &&
182+
(
183+
github.event_name == 'push' ||
184+
github.event.pull_request.head.repo.full_name == github.repository
185+
) &&
186+
!contains(github.event.head_commit.message, 'skip fix')
80187
with:
81-
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
188+
branch: >-
189+
${{
190+
github.event.pull_request.head.ref ||
191+
github.head_ref ||
192+
github.ref
193+
}}
82194
commit_message: "[MegaLinter] Apply linters fixes"
195+
commit_user_name: megalinter-bot
196+
commit_user_email: 129584137+megalinter-bot@users.noreply.github.com

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
*_bibertool.bib
66
*.aux
77
bib2html*
8+
9+
megalinter-reports/

.mega-linter.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
# Configuration file for MegaLinter
2-
# See all available variables at https://megalinter.github.io/configuration/ and in linters documentation
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:
316

4-
APPLY_FIXES: all # all, none, or list of linter keys
5-
# ENABLE: # If you use ENABLE variable, all other languages/formats/tooling-formats will be disabled by default
6-
# ENABLE_LINTERS: # If you use ENABLE_LINTERS variable, all other linters will be disabled by default
717
# DISABLE:
818
# - COPYPASTE # Uncomment to disable checks of excessive copy-pastes
919
# - SPELL # Uncomment to disable checks of spelling mistakes
20+
1021
SHOW_ELAPSED_TIME: true
11-
FILEIO_REPORTER: false
12-
# DISABLE_ERRORS: true # Uncomment if you want MegaLinter to detect errors but not block CI to pass
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)