From 2c548620af0799a5b7c7661339104bdc87f6fd2e Mon Sep 17 00:00:00 2001 From: Marco Ferrari Date: Tue, 12 Dec 2023 08:41:41 +0100 Subject: [PATCH] Move instructions from the wiki to docs (#4957) * Move instructions from the wiki to docs * Add missing code * Fix linting errors * Fix indentation * Don't add deleted docs back * Remove slim readme --- .github/ISSUE_TEMPLATE/feature_request.yml | 2 +- .github/linters/.sqlfluff | 4 +- TEMPLATES/.sqlfluff | 4 +- TEMPLATES/phpcs.xml | 2 +- docs/add-new-linter.md | 100 +++++++++++++++++++++ docs/release-process.md | 2 +- slim/README.md | 34 ------- 7 files changed, 107 insertions(+), 41 deletions(-) create mode 100644 docs/add-new-linter.md delete mode 100644 slim/README.md diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index f53f7c15..41e9a04c 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -9,7 +9,7 @@ body: value: | Thanks for taking the time to fill out this feature request! If this is a request to add a new language, after submitting this issue - check out [the wiki](https://github.com/super-linter/super-linter/wiki/Adding-new-language-support-to-Super-Linter) + check out [the instructions](https://github.com/super-linter/super-linter/blob/main/docs/add-new-linter.md) for more information on how to accomplish that. - type: checkboxes attributes: diff --git a/.github/linters/.sqlfluff b/.github/linters/.sqlfluff index 27216cf8..12543527 100644 --- a/.github/linters/.sqlfluff +++ b/.github/linters/.sqlfluff @@ -1,8 +1,8 @@ ## This /.sqlfluff file can be used to configure the SQLFluff linter when -## used via the GitHub Super Linter. Copy it to the .github/linters folder of +## used via the Super Linter. Copy it to the .github/linters folder of ## your repo, and uncomment the necessary lines to configure the Super Linter. ## -## IMPORTANT NOTE: The GitHub Super Linter configuration file for SQLFluff +## IMPORTANT NOTE: The Super Linter configuration file for SQLFluff ## supersedes any local configuration files you might have in within your ## codebase. For this reason it should only be used when you want the same ## configuration for your entire code base. If you need different configuration diff --git a/TEMPLATES/.sqlfluff b/TEMPLATES/.sqlfluff index 27216cf8..12543527 100644 --- a/TEMPLATES/.sqlfluff +++ b/TEMPLATES/.sqlfluff @@ -1,8 +1,8 @@ ## This /.sqlfluff file can be used to configure the SQLFluff linter when -## used via the GitHub Super Linter. Copy it to the .github/linters folder of +## used via the Super Linter. Copy it to the .github/linters folder of ## your repo, and uncomment the necessary lines to configure the Super Linter. ## -## IMPORTANT NOTE: The GitHub Super Linter configuration file for SQLFluff +## IMPORTANT NOTE: The Super Linter configuration file for SQLFluff ## supersedes any local configuration files you might have in within your ## codebase. For this reason it should only be used when you want the same ## configuration for your entire code base. If you need different configuration diff --git a/TEMPLATES/phpcs.xml b/TEMPLATES/phpcs.xml index db39fed5..27cefdd2 100644 --- a/TEMPLATES/phpcs.xml +++ b/TEMPLATES/phpcs.xml @@ -1,6 +1,6 @@ - The default coding standard for usage with GitHub Super-Linter. It just includes PSR12. + The default coding standard for usage with Super-Linter. It just includes PSR12. diff --git a/docs/add-new-linter.md b/docs/add-new-linter.md new file mode 100644 index 00000000..27e4cf68 --- /dev/null +++ b/docs/add-new-linter.md @@ -0,0 +1,100 @@ +# How to add support for a new tool to super-linter + +If you want to propose a *Pull Request* to add **new** language support or a +new tool, it should include: + +- Update documentation: + - `README.md` +- Provide test cases: + + 1. Create the `.automation/test/` directory. + 2. Provide at least one test case with a file that is supposed to pass validation: `.automation/test//-good.ext` + 3. Provide at least one test case with a file that is supposed to fail validation: `.automation/test//-bad.ext` + +- Update the test suite to check for installed packages, the commands that your new tool needs in the `PATH`, and the expected version command: + + - `test/inspec/super-linter/controls/super_linter.rb` + +- Install the tool by pointing to specific package or container image versions: + + - If there are PyPi packages, create a text file named `dependencies/python/.txt` + and list the packages there. + - If there are npm packages, update `dependencies/package.json` and `dependencies/package-lock.json`. + by adding the new packages. + - If there are Ruby Gems, update `dependencies/Gemfile` and `dependencies/Gemfile.lock` + - If there are Maven or Java packages: + + 1. Create a directory named `dependencies/`. + 2. Create a `dependencies//build.gradle` file with the following contents: + + ```gradle + repositories { + mavenLocal() + mavenCentral() + } + + // Hold this dependency here so we can get automated updates using DependaBot + dependencies { + implementation 'your:dependency-here:version' + } + + group 'com.github.super-linter' + version '1.0.0-SNAPSHOT' + ``` + + 3. Update the `dependencies` section in `dependencies//build.gradle` to + install your dependencies. + 4. Add the following content to the `Dockerfile`: + + ```dockerfile + COPY scripts/install-.sh / + RUN --mount=type=secret,id=GITHUB_TOKEN /.sh && rm -rf /.sh + ``` + + 5. Create `scripts/install-.sh`, and implement the logic to install your tool. + You get the version of a dependency from `build.gradle`. Example: + + ```sh + GOOGLE_JAVA_FORMAT_VERSION="$(grep <"google-java-format/build.gradle" "google-java-format" | awk -F ':' '{print $3}' | tr -d "'")" + ``` + + 6. Add the new to DependaBot configuration: + + ```yaml + - package-ecosystem: "gradle" + directory: "/dependencies/" + schedule: + interval: "weekly" + open-pull-requests-limit: 10 + ``` + + - If there is a container (Docker) image: + + 1. Add a new build stage to get the image: + + ```dockerfile + FROM your/image:version as + ``` + + 1. Copy the necessary binaries and libraries to the relevant locations. Example: + + ```sh + COPY --from= /usr/local/bin/ /usr/bin/ + ``` + +- Configure the new tool: + + - Provide a default configuration file only if the tool cannot function without one: `TEMPLATES/