Skip to content

Commit

Permalink
Switch to MegaLinter for linting
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Aug 22, 2024
1 parent 6922727 commit 09069be
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 45 deletions.
79 changes: 35 additions & 44 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,52 @@
---
#################################
#################################
## Super Linter GitHub Actions ##
#################################
#################################
name: Lint Code Base

#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#

#############################
# Start the job on all push #
#############################
# MegaLinter GitHub Action configuration file
# More info at https://megalinter.io
name: MegaLinter
on:
push:
#branches-ignore: [master, main]
# Remove the line above to run when pushing to master
branches: master
pull_request:
branches: [master, main]

###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Lint Code Base
# Set the agent to run on
megalinter:
name: MegaLinter
runs-on: ubuntu-latest

##################
# Load all steps #
##################
permissions:
# Give the linter write permission to comment on PRs (if PR is not from fork)
issues: write
pull-requests: write
steps:
##########################
# Checkout the code base #
##########################
# Git Checkout
- name: Checkout Code
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

################################
# Run Linter against code base #
################################
- name: Lint Code Base
uses: github/super-linter/slim@v6
# MegaLinter
- name: MegaLinter
id: ml
# You can override MegaLinter flavor used to have faster performances
# More info at https://megalinter.io/flavors/
uses: oxsecurity/megalinter/flavors/python@v7
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: master
# All available variables are described in documentation
# https://megalinter.io/configuration/
ENABLE_LINTERS: PYTHON_BLACK,PYTHON_FLAKE8
# Make workflow fail even on non blocking errors
FORMATTERS_DISABLE_ERRORS: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_PYTHON_BLACK: true
VALIDATE_PYTHON_FLAKE8: true
# Validate whole codebase on pushes and only changes on pull requests
VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' }}
# Tell the linter the location of the configuration file (pyproject.toml)
LINTER_RULES_PATH: /
PYTHON_BLACK_CONFIG_FILE: pyproject.toml
PYTHON_FLAKE8_CONFIG_FILE: tox.ini
FILTER_REGEX_EXCLUDE: .*python/nav/smidumps/.*
# Upload MegaLinter artifacts
- name: Archive production artifacts
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: MegaLinter reports
path: |
megalinter-reports
mega-linter.log
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ where = ["python"]
[tool.black]
skip-string-normalization=true
line-length = 88
exclude = '''
# Exclude files even when passed directly as argument (for MegaLinter)
force-exclude = '''
(
/(
\.eggs # exclude a few common directories in the
Expand Down

0 comments on commit 09069be

Please sign in to comment.