-
-
Notifications
You must be signed in to change notification settings - Fork 269
Implements custom MegaLinter flavor support #5779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for defining and building custom MegaLinter flavors to produce smaller, tailored Docker images for users.
- Introduces a new
--custom-flavor-setup
runner command and agenerate_custom_flavor_file
method to scaffold and produce amegalinter-custom-flavor.yml
. - Implements Dockerfile generation logic (
generate_custom_flavor_dockerfile
) and a builder image for custom flavors. - Updates documentation, schemas, and CI workflows to guide users through custom flavor creation and publishing.
Reviewed Changes
Copilot reviewed 44 out of 47 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
megalinter/custom_flavor_factory.py | Adds Dockerfile generation from megalinter-custom-flavor.yml . |
megalinter/MegaLinter.py | Generates megalinter-custom-flavor.yml based on used linters. |
mega-linter-runner/lib/runner.js | Adds --custom-flavor-setup option and corresponding setup logic. |
test_custom_flavor.py | Basic test for custom flavor file generation. |
docs/custom-flavors.md | Documentation for the custom flavor workflow. |
Comments suppressed due to low confidence (2)
test_custom_flavor.py:61
- Instead of returning True/False, use assertions (e.g.,
assert os.path.exists(custom_flavor_file)
) so pytest can detect failures automatically.
return True
.github/workflows/deploy-RELEASE.yml:110
- This workflow is building the custom flavor Dockerfile instead of the flavor-builder image. Update to use the correct builder Dockerfile (e.g.,
Dockerfile-flavor-builder
).
file: Dockerfile-custom-flavor
required_fields = ["flavor_name", "flavor_description", "linters", "docker_image"] | ||
for field in required_fields: | ||
if field not in custom_flavor_config: | ||
logging.error(f"Missing required field '{field}' in custom flavor configuration") | ||
return False | ||
|
Copilot
AI
Jul 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key flavor_description
does not match the test YAML which uses description
. Either update the schema and test file to use flavor_description
or accept description
in the code.
required_fields = ["flavor_name", "flavor_description", "linters", "docker_image"] | |
for field in required_fields: | |
if field not in custom_flavor_config: | |
logging.error(f"Missing required field '{field}' in custom flavor configuration") | |
return False | |
required_fields = ["flavor_name", "linters", "docker_image"] | |
for field in required_fields: | |
if field not in custom_flavor_config: | |
logging.error(f"Missing required field '{field}' in custom flavor configuration") | |
return False | |
# Check for flavor description | |
if "flavor_description" not in custom_flavor_config and "description" not in custom_flavor_config: | |
logging.error("Missing required field 'flavor_description' or 'description' in custom flavor configuration") | |
return False | |
Copilot uses AI. Check for mistakes.
// Build MegaLinter docker image name with flavor and release version | ||
const release = options.release in ["stable"] ? DEFAULT_RELEASE : options.release; | ||
const release = | ||
options.release in ["stable"] ? DEFAULT_RELEASE : options.release; |
Copilot
AI
Jul 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the in
operator checks for property names, not array membership. Replace with ['stable'].includes(options.release)
to properly test if options.release
equals 'stable'
.
options.release in ["stable"] ? DEFAULT_RELEASE : options.release; | |
["stable"].includes(options.release) ? DEFAULT_RELEASE : options.release; |
Copilot uses AI. Check for mistakes.
🦙 MegaLinter status: ❌ ERROR❌ SPELL / cspell - 1 error
🤖 AI-Powered Fix Suggestions for SPELL_CSPELL (by openai gpt-4.1-mini)
Example {
"words": ["myuser"]
} This will suppress the warning for "myuser" in all files. ❌ PYTHON / flake8 - 5 errors
🤖 AI-Powered Fix Suggestions for PYTHON_FLAKE8 (by openai gpt-4.1-mini)
Example fix for E501: # Original line too long
result = some_function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
# Fixed by breaking into multiple lines
result = some_function(
arg1, arg2, arg3, arg4,
arg5, arg6, arg7, arg8
) Address the syntax error first, then fix line lengths and import order for clean, PEP8-compliant code. ❌ PYTHON / mypy - 1 error
🤖 AI-Powered Fix Suggestions for PYTHON_MYPY (by openai gpt-4.1-mini)
Example fix: # Before (missing closing parenthesis)
result = some_function(arg1, arg2
# After (added closing parenthesis)
result = some_function(arg1, arg2) Ensuring all parentheses are balanced will allow mypy to parse and type-check the file correctly. ❌ PYTHON / pylint - 28 errors
🤖 AI-Powered Fix Suggestions for PYTHON_PYLINT (by openai gpt-4.1-mini)
Example fix for syntax error: # Before (unclosed '(')
some_function_call(arg1, arg2
# After (closed '(')
some_function_call(arg1, arg2) Example fix for missing member: class MockLinter:
def __init__(self):
self.apply_fixes = False
self.master = None
# define other missing members similarly Prioritize fixing the syntax error first, as it blocks imports and causes many downstream errors. ❌ PYTHON / ruff - 2 errors
🤖 AI-Powered Fix Suggestions for PYTHON_RUFF (by openai gpt-4.1-mini)
Example fix for F823: import os # Add this at the top of the file
def generate_custom_flavor_dockerfile(custom_flavor_file):
if not os.path.exists(custom_flavor_file):
logging.error(f"Custom flavor file not found: {custom_flavor_file}")
return False Addressing these will resolve the critical parsing and reference errors blocking linting.
|
Implements the generation of custom MegaLinter flavor Dockerfiles based on a configuration file. This allows users to define their own flavors with specific linters and dependencies. The changes include: - Adds logic to parse a custom flavor configuration file (YAML) to specify linters, dependencies, and other configurations. - Creates a Dockerfile based on the configuration, including installing the necessary linters and setting up the environment. - Includes a build system that can be run from any repo. - Adds validation to ensure that required configuration fields are present.
This pull request introduces functionality for users to define and build custom MegaLinter flavors, resulting in smaller, more efficient Docker images.
Key changes:
custom-flavor
command to the runner to initialize custom flavor files.megalinter-custom-flavor.yml
).