Skip to content
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

Add new flavor definition style, add bioinformatics flavor #4257

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .automation/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ def generate_all_flavors():
# Automatically generate Dockerfile , action.yml and upgrade all_flavors.json
def generate_flavor(flavor, flavor_info):
descriptor_and_linters = []
flavor_descriptors = []
flavor_linters = []
flavor_descriptors = flavor_info.get("descriptors", [])
flavor_linters = flavor_info.get("linters", [])
# Get install instructions at descriptor level
descriptor_files = megalinter.linter_factory.list_descriptor_files()
for descriptor_file in descriptor_files:
Expand All @@ -179,6 +179,11 @@ def generate_flavor(flavor, flavor_info):
flavor_linters += [linter.name]
if linter.cli_docker_image is not None:
requires_docker = True

# Remove duplicate entries without sorting
flavor_descriptors = list(dict.fromkeys(flavor_descriptors))
flavor_linters = list(dict.fromkeys(flavor_linters))

# Initialize Dockerfile
if flavor == "all":
dockerfile = f"{REPO_HOME}/Dockerfile"
Expand Down Expand Up @@ -621,6 +626,12 @@ def match_flavor(item, flavor, flavor_info):
and flavor in item["descriptor_flavors_exclude"]
):
return False

elif (item.get("descriptor_id") in flavor_info.get("descriptors", [])
or item.get("name") in flavor_info.get("linters", [])):
# Short-circuit if the flavor explicitly supplied these details
return True

# Flavor all
elif flavor == "all":
return True
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-linter.yml file, or with `oxsecurity/megalinter:beta` docker image

- Core
- Allow flavors to be completely defined in `flavor_factory.py`

- New linters

Expand Down Expand Up @@ -36,6 +37,7 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
- Update DevSkim documentation to show a valid exclusion config file

- Flavors
- Add bioinformatics flavor

- CI
- Also prune volumes before pulling and pushing to docker hub
Expand Down
15 changes: 15 additions & 0 deletions megalinter/flavor_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ def list_megalinter_flavors():
"security": {"label": "Optimized for security", "strict": True},
"swift": {"label": "Optimized for SWIFT based projects"},
"terraform": {"label": "Optimized for TERRAFORM based projects"},
"bioinformatics": {
"label": "Optimized for bioinformatics projects",
"strict": True,
"descriptors": [
"ACTION",
"BASH",
"GROOVY",
"JAVASCRIPT",
"JSON",
"PERL",
"PYTHON",
"R",
"YAML",
]
},
}
return flavors

Expand Down
Loading