diff --git a/.automation/cleanup-docker.sh b/.automation/cleanup-docker.sh index 77b86ab3..ba2cb758 100755 --- a/.automation/cleanup-docker.sh +++ b/.automation/cleanup-docker.sh @@ -16,7 +16,7 @@ ########### # Globals # ########### -GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace +GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # GitHub Workspace DOCKER_USERNAME="${DOCKER_USERNAME}" # Username to login to DockerHub DOCKER_PASSWORD="${DOCKER_PASSWORD}" # Password to login to DockerHub IMAGE_REPO="${IMAGE_REPO}" # Image repo to upload the image @@ -32,7 +32,7 @@ Header() { echo "" echo "-------------------------------------------------------" - echo "----- Github Actions remove image from DockerHub ------" + echo "----- GitHub Actions remove image from DockerHub ------" echo "-------------------------------------------------------" echo "" } diff --git a/.automation/test/ansible/ghe-initialize/defaults/main.yml b/.automation/test/ansible/ghe-initialize/defaults/main.yml index 6e8741f0..62e30a3a 100644 --- a/.automation/test/ansible/ghe-initialize/defaults/main.yml +++ b/.automation/test/ansible/ghe-initialize/defaults/main.yml @@ -62,7 +62,7 @@ core_expire_sessions: "false" core_package_version: "null" ####################### -# Default Github Vars # +# Default GitHub Vars # ####################### github_ssl_enabled: "true" github_ssl_tls_mode: "tlsv12" diff --git a/.automation/test/ansible/ghe-initialize/tasks/ghe-initial-configuration.yml b/.automation/test/ansible/ghe-initialize/tasks/ghe-initial-configuration.yml index d078873e..91865d3c 100644 --- a/.automation/test/ansible/ghe-initialize/tasks/ghe-initial-configuration.yml +++ b/.automation/test/ansible/ghe-initialize/tasks/ghe-initial-configuration.yml @@ -74,7 +74,7 @@ ################################### # Set the GHE Admin Password fact # ################################### - - name: Set the Github Admin password fact + - name: Set the GitHub Admin password fact set_fact: github_admin_password: "{{ github_admin_password }}" diff --git a/.automation/test/python/python_bad_1.py b/.automation/test/python/python_bad_1.py index 843aad50..369a7224 100644 --- a/.automation/test/python/python_bad_1.py +++ b/.automation/test/python/python_bad_1.py @@ -89,7 +89,7 @@ def delete_label(label_id): Delete the specified label :param label_id: Label's node id. :type label_id: str - :return: Github API request response. + :return: GitHub API request response. """ query_variables = { diff --git a/.automation/test/python/python_good_1.py b/.automation/test/python/python_good_1.py index f808c297..e894c36f 100644 --- a/.automation/test/python/python_good_1.py +++ b/.automation/test/python/python_good_1.py @@ -88,7 +88,7 @@ def delete_label(label_id): Delete the specified label :param label_id: Label's node id. :type label_id: str - :return: Github API request response. + :return: GitHub API request response. """ query_variables = { diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index e6f42be1..644bee8d 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -17,7 +17,7 @@ ########### # Globals # ########### -GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace +GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # GitHub Workspace DOCKER_USERNAME="${DOCKER_USERNAME}" # Username to login to DockerHub DOCKER_PASSWORD="${DOCKER_PASSWORD}" # Password to login to DockerHub IMAGE_REPO="${IMAGE_REPO}" # Image repo to upload the image @@ -33,7 +33,7 @@ Header() { echo "" echo "-------------------------------------------------------" - echo "------ Github Actions Upload image to DockerHub -------" + echo "------ GitHub Actions Upload image to DockerHub -------" echo "-------------------------------------------------------" echo "" } diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 960b4afe..f553dcfc 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -40,6 +40,6 @@ If you are the current maintainer of this action: - [Using Pull Requests](https://help.github.com/articles/about-pull-requests/) - [GitHub Help](https://help.github.com) -[pulls]: https://github.com/github/github-demo-stack/pulls -[pr]: https://github.com/github/github-demo-stack/compare -[fork]: https://github.com/github/github-demo-stack/fork +[pulls]: https://github.com/github/super-linter/pulls +[pr]: https://github.com/github/super-linter/compare +[fork]: https://github.com/github/super-linter/fork diff --git a/Dockerfile b/Dockerfile index 36e25542..7f655c31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ FROM python:alpine # Label the instance and set maintainer # ######################################### LABEL com.github.actions.name="GitHub Super-Linter" \ - com.github.actions.description="Lint your code base with Github Actions" \ + com.github.actions.description="Lint your code base with GitHub Actions" \ com.github.actions.icon="code" \ com.github.actions.color="red" \ maintainer="GitHub DevOps " @@ -43,7 +43,7 @@ RUN npm config set package-lock false \ && npm -g --no-cache install \ markdownlint-cli \ jsonlint prettyjson \ - coffeelint \ + @coffeelint/cli \ typescript eslint \ standard \ babel-eslint \ @@ -55,7 +55,7 @@ RUN npm config set package-lock false \ && npm --no-cache install \ markdownlint-cli \ jsonlint prettyjson \ - coffeelint \ + @coffeelint/cli \ typescript eslint \ standard \ babel-eslint \ @@ -93,7 +93,7 @@ RUN wget -qO- "https://github.com/koalaman/shellcheck/releases/download/stable/s ##################### # Install Go Linter # ##################### -ARG GO_VERSION='v1.23.7' +ARG GO_VERSION='v1.27.0' RUN wget -O- -nvq https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s "$GO_VERSION" ################## @@ -103,11 +103,12 @@ RUN curl -Ls "$(curl -Ls https://api.github.com/repos/terraform-linters/tflint/r && mv "tflint" /usr/bin/ ########################################### -# Load GitHub Env Vars for Github Actions # +# Load GitHub Env Vars for GitHub Actions # ########################################### ENV GITHUB_SHA=${GITHUB_SHA} \ GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH} \ GITHUB_WORKSPACE=${GITHUB_WORKSPACE} \ + DEFAULT_BRANCH=${DEFAULT_BRANCH} \ VALIDATE_ALL_CODEBASE=${VALIDATE_ALL_CODEBASE} \ VALIDATE_YAML=${VALIDATE_YAML} \ VALIDATE_JSON=${VALIDATE_JSON} \ diff --git a/README.md b/README.md index 85a10a5f..b0074dc7 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This repository is for the **GitHub Action** to run a **Super-Linter**. It is a simple combination of various linters, written in `bash`, to help validate your source code. The end goal of this tool: -- Prevent broken code from being uploaded to *master* branches +- Prevent broken code from being uploaded to the default branch (Usually `master`) - Help establish coding best practices across multiple languages - Build guidelines for code layout and format - Automate the process to help streamline code reviews @@ -19,8 +19,8 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | *Language* | *Linter* | | --- | --- | | **Ansible** | [ansible-lint](https://github.com/ansible/ansible-lint) | -| **CoffeeScript** | [coffeelint](http://www.coffeelint.org/) | -| **CSS** | [stylelint](https://stylelint.io/) | +| **CSS** | [stylelint](https://stylelint.io/) | +| **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) | | **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) | | **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | | **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | @@ -28,7 +28,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) | | **Perl** | [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) | | **Python3** | [pylint](https://www.pylint.org/) | -| **Ruby** | [Rubocop](https://github.com/rubocop-hq/rubocop) | +| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) | | **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) | | **Terraform** | [tflint](https://github.com/terraform-linters/tflint) | | **TypeScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | @@ -114,6 +114,7 @@ and won't run anything unexpected. | **ENV VAR** | **Default Value** | **Notes** | | --- | --- | --- | | **VALIDATE_ALL_CODEBASE** | `true` | Will parse the entire repository and find all files to validate across all types. **NOTE:** When set to `false`, only **new** or **edited** files will be parsed for validation. | +| **DEFAULT_BRANCH** | `master` | The name of the repository default branch. | | **VALIDATE_YAML** | `true` |Flag to enable or disable the linting process of the language. | | **VALIDATE_JSON** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_XML** | `true` | Flag to enable or disable the linting process of the language. | @@ -134,6 +135,7 @@ and won't run anything unexpected. | **VALIDATE_CSS** | `true` | Flag to enable or disable the linting process of the language. | | **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s). | | **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. | +| **DEFAULT_WORKSPACE** | `/tmp/lint` | The location containing files to lint if you are running locally. | ### Template rules files You can use the **GitHub** **Super-Linter** *with* or *without* your own personal rules sets. This allows for greater flexibility for each individual code base. The Template rules all try to follow the standards we believe should be enabled at the basic level. @@ -144,7 +146,7 @@ You can use the **GitHub** **Super-Linter** *with* or *without* your own persona If you need to disable certain *rules* and *functionality*, you can view [Disable Rules](https://github.com/github/super-linter/blob/master/docs/disabling-linters.md) ## Docker Hub -The **Docker** container that is built from this repository is located at `https://hub.docker.com/r/admiralawkbar/super-linter` +The **Docker** container that is built from this repository is located at `https://hub.docker.com/r/github/super-linter` ## Running Super-Linter locally (troubleshooting/debugging/enhancements) If you find that you need to run super-linter locally, you can follow the documentation at [Running super-linter locally](https://github.com/github/super-linter/blob/master/docs/run-linter-locally.md) diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index d425f078..92187192 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -27,20 +27,20 @@ Below is examples and documentation for each language and the various methods to -------------------------------------------------------------------------------- ## Ruby -- [Rubocop](https://github.com/rubocop-hq/rubocop) +- [RuboCop](https://github.com/rubocop-hq/rubocop) -### Rubocop Config file +### RuboCop Config file - `.github/linters/.ruby-lint.yml` - You can pass multiple rules and overwrite default rules - File should be located at: `.github/linters/.ruby-lint.yml` -- **Note:** We use the Default **GitHub** Rule set from [Rubocop-GitHub](https://github.com/github/rubocop-github) +- **Note:** We use the Default **GitHub** Rule set from [RuboCop-GitHub](https://github.com/github/rubocop-github) -### Rubocop disable single line +### RuboCop disable single line ```ruby method(argument) # rubocop:disable SomeRule, SomeOtherRule ``` -### Rubocop disable code block +### RuboCop disable code block ```ruby # rubocop:disable This is a long line @@ -48,7 +48,7 @@ var="this is some other stuff" # rubocop:enable ``` -### Rubocop disable entire file +### RuboCop disable entire file If you need to ignore an entire file, you can update the `.github/linters/.ruby-lint.yml` to ignore certain files and locations ```yml @@ -320,7 +320,7 @@ Here is more data -------------------------------------------------------------------------------- ## Coffeescript -- [coffeelint](http://www.coffeelint.org/) +- [coffeelint](https://coffeelint.github.io/) ### coffeelint Config file - `.github/linters/.coffee-lint.yml` diff --git a/docs/run-linter-locally.md b/docs/run-linter-locally.md index 06117349..c28418b4 100644 --- a/docs/run-linter-locally.md +++ b/docs/run-linter-locally.md @@ -12,14 +12,15 @@ You can follow the link below on how to install and configure **Docker** on your ## Download the latest Super-Linter Docker container - Pull the latest **Docker** container down from **DockerHub** - - `docker pull admiralawkbar/super-linter:latest` + - `docker pull github/super-linter:latest` Once the container has been downloaded to your local environment, you can then begin the process, or running the container against your codebase. ## Run the container Locally - You can run the container locally with the following **Base** flags to run your code: - - `docker run -e RUN_LOCAL=true -v /path/to/local/codebase:/tmp/lint admiralawkbar/super-linter` - - To run against a single file you can use: `docker run -e RUN_LOCAL=true -v /path/to/local/codebase/file:/tmp/lint/file admiralawkbar/super-linter` + - `docker run -e RUN_LOCAL=true -v /path/to/local/codebase:/tmp/lint github/super-linter` + - To run against a single file you can use: `docker run -e RUN_LOCAL=true -v /path/to/local/codebase/file:/tmp/lint/file github/super-linter` - **NOTE:** You need to pass the `RUN_LOCAL` flag to bypass some of the GitHub Actions checks, as well as the mapping of your local codebase to `/tmp/lint` so that the linter can pick up the code + - **NOTE:** If you want to override the `/tmp/lint` folder, you can set the `DEFAULT_WORKSPACE` environment variable to point to the folder you'd prefer to scan. - **NOTE:** The flag:`RUN_LOCAL` will set: `VALIDATE_ALL_CODEBASE` to true. This means it will scan **all** the files in the directory you have mapped. If you want to only validate a subset of your codebase, map a folder with only the files you wish to have linted ### Flags for running Locally @@ -29,7 +30,7 @@ You can add as many **Additional** flags as needed, documented in [README.md](.. ### Run container and gain access to the command line If you need to run the container locally and gain access to its command line, you can run the following command: -- `docker run -it --entrypoint /bin/bash admiralawkbar/super-linter` +- `docker run -it --entrypoint /bin/bash github/super-linter` - This will drop you in the command line of the docker container for any testing or troubleshooting that may be needed. ### Found issues diff --git a/lib/linter.sh b/lib/linter.sh index 84ec72b5..b96f44ec 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -74,6 +74,7 @@ LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'RUBY' 'PYTHON' GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # Github Event Path GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace +DEFAULT_BRANCH="${DEFAULT_BRANCH:-master}" # Default Git Branch to use (master by default) ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY}" # Ansible Directory VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files VALIDATE_YAML="${VALIDATE_YAML}" # Boolean to validate language @@ -106,7 +107,7 @@ ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG}" # Boolean to see even more info # Default Vars # ################ DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate all files -DEFAULT_WORKSPACE='/tmp/lint' # Default workspace if running locally +DEFAULT_WORKSPACE="${DEFAULT_WORKSPACE:-/tmp/lint}" # Default workspace if running locally DEFAULT_ANSIBLE_DIRECTORY="$GITHUB_WORKSPACE/ansible" # Default Ansible Directory DEFAULT_RUN_LOCAL='false' # Default value for debugging locally DEFAULT_TEST_CASE_RUN='false' # Flag to tell code to run only test cases @@ -175,7 +176,7 @@ Header() ########## echo "" echo "---------------------------------------------" - echo "--- Github Actions Multi Language Linter ----" + echo "--- GitHub Actions Multi Language Linter ----" echo "---------------------------------------------" echo "" echo "---------------------------------------------" @@ -1183,10 +1184,10 @@ BuildFileList() echo "Pulling in code history and branches..." fi - ##################################################################### - # Switch codebase back to master to get a list of all files changed # - ##################################################################### - SWITCH_CMD=$(cd "$GITHUB_WORKSPACE" || exit; git pull --quiet; git checkout master 2>&1) + ################################################################################# + # Switch codebase back to the default branch to get a list of all files changed # + ################################################################################# + SWITCH_CMD=$(cd "$GITHUB_WORKSPACE" || exit; git pull --quiet; git checkout "$DEFAULT_BRANCH" 2>&1) ####################### # Load the error code # @@ -1198,7 +1199,7 @@ BuildFileList() ############################## if [ $ERROR_CODE -ne 0 ]; then # Error - echo "Failed to switch to master branch to get files changed!" + echo "Failed to switch to $DEFAULT_BRANCH branch to get files changed!" echo "ERROR:[$SWITCH_CMD]" exit 1 fi @@ -1209,14 +1210,14 @@ BuildFileList() if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then echo "" echo "----------------------------------------------" - echo "Generating Diff with:[git diff --name-only 'master..$GITHUB_SHA' --diff-filter=d]" + echo "Generating Diff with:[git diff --name-only '$DEFAULT_BRANCH..$GITHUB_SHA' --diff-filter=d]" fi ################################################ # Get the Array of files changed in the comits # ################################################ # shellcheck disable=SC2207 - RAW_FILE_ARRAY=($(cd "$GITHUB_WORKSPACE" || exit; git diff --name-only "master..$GITHUB_SHA" --diff-filter=d 2>&1)) + RAW_FILE_ARRAY=($(cd "$GITHUB_WORKSPACE" || exit; git diff --name-only "$DEFAULT_BRANCH..$GITHUB_SHA" --diff-filter=d 2>&1)) ####################### # Load the error code # @@ -1949,7 +1950,7 @@ RunTestCases() { # This loop will run the test cases and exclude user code # This is called from the automation process to validate new code - # When a PR is opened, the new code is validated with the master branch + # When a PR is opened, the new code is validated with the default branch # version of linter.sh, and a new container is built with the latest codebase # for testing. That container is spun up, and ran, # with the flag: TEST_CASE_RUN=true @@ -2003,9 +2004,9 @@ RunTestCases() Header ####################### -# Get Github Env Vars # +# Get GitHub Env Vars # ####################### -# Need to pull in all the Github variables +# Need to pull in all the GitHub variables # needed to connect back and update checks GetGitHubVars