From 5ee0c14532e24580b01a991e4f5b1d91b5fb856e Mon Sep 17 00:00:00 2001 From: Nicholas Wiltsie Date: Fri, 15 Nov 2024 09:40:50 -0800 Subject: [PATCH 1/3] Add logic to allow flavors to be specified centrally --- .automation/build.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.automation/build.py b/.automation/build.py index f37bbd689b3..6f920534988 100644 --- a/.automation/build.py +++ b/.automation/build.py @@ -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: @@ -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" @@ -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 From 3ed599ae9223d47d5091726a6b821cb1b5e04a31 Mon Sep 17 00:00:00 2001 From: Nicholas Wiltsie Date: Fri, 15 Nov 2024 09:42:17 -0800 Subject: [PATCH 2/3] Add bioinformatics flavor --- megalinter/flavor_factory.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/megalinter/flavor_factory.py b/megalinter/flavor_factory.py index fbef15e4fcc..b1c4eecb708 100644 --- a/megalinter/flavor_factory.py +++ b/megalinter/flavor_factory.py @@ -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 From a1028d76664fc13b2eb7d358f3ec2b5ee184d9fb Mon Sep 17 00:00:00 2001 From: Nicholas Wiltsie Date: Fri, 15 Nov 2024 12:24:28 -0800 Subject: [PATCH 3/3] Update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eab9213d52..f951a4f4c18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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