diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 00000000..75057d9f --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,10 @@ +# Devcontainer +This file specifies to vscode how to run the container + +For format details, see [documentation](https://aka.ms/vscode-remote/devcontainer.json) or this file's [README](https://github.com/microsoft/vscode-dev-containers/tree/v0.123.0/containers/docker-existing-dockerfile) + + +context: Sets the run context to one level up instead of the .devcontainer folder. +dockerFile: Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. +settings: Set *default* container specific settings.json values on container create. +extensions: Add the IDs of extensions you want installed when the container is created. \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..ac0ac8e1 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,12 @@ +{ + "name": "SUPER-LINTER", + "context": "..", + "dockerFile": "..//Dockerfile", + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + "extensions": [ + "github.vscode-pull-request-github", + "rogalmic.bash-debug" + ] +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..5dc46e6b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +* text=auto eol=lf +*.{cmd,[cC][mM][dD]} text eol=crlf +*.{bat,[bB][aA][tT]} text eol=crlf \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..77e1ced2 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "bashdb", + "request": "launch", + "name": "Test Linter", + "program": ".vscode/testlinter.sh", + "cwd": "${workspaceFolder}", + "internalConsoleOptions": "openOnSessionStart", + "presentation": { + "group": "aLinter" + } + } + ] +} \ No newline at end of file diff --git a/.vscode/testlinter.sh b/.vscode/testlinter.sh new file mode 100644 index 00000000..8d778d16 --- /dev/null +++ b/.vscode/testlinter.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# At this point you can use the debug console to add export GITHUB_WORKSPACE=/path to test only a specific folder +# You can also use ln -s /path /tmp/lint as an alternative +# If you do neither, this will default to running against the test automation files + +########### +# GLOBALS # +########### +CODE_PATH='/tmp/lint' # Path to code base + +################## +# Check the path # +################## +if [ ! -L $CODE_PATH ]; then + # Create symbolic link + ln -s "$PWD"/.automation/test $CODE_PATH +fi + +######################### +# Export to run locally # +######################### +export RUN_LOCAL=true + +# shellcheck disable=SC1091,SC1090 +source "$PWD"/lib/linter.sh diff --git a/README.md b/README.md index ab9efb85..aaaf494f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Super-Linter -This repository is for the **GitHub Action** to run a **Super-Linter**. +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: @@ -129,9 +129,9 @@ jobs: ## Environment variables The super-linter allows you to pass the following `ENV` variables to be able to trigger different functionality. -*Note:* All the `VALIDATE_[LANGUAGE]` variables behave in a specific way. -If none of them are passed, then they all default to true. -However if any one of the variables are set, we default to leaving any unset variable to false. +*Note:* All the `VALIDATE_[LANGUAGE]` variables behave in a specific way. +If none of them are passed, then they all default to true. +However if any one of the variables are set, we default to leaving any unset variable to false. This means that if you run the linter "out of the box", all languages will be checked. But if you wish to select specific linters, we give you full control to choose which linters are run, and won't run anything unexpected. @@ -208,6 +208,12 @@ Below are a list of the known limitations for the **GitHub Super-Linter**: ## How to contribute If you would like to help contribute to this **GitHub** Action, please see [CONTRIBUTING](https://github.com/github/super-linter/blob/master/.github/CONTRIBUTING.md) +### Visual Studio Code +You can checkout this repository using [Container Remote Development](https://code.visualstudio.com/docs/remote/containers), and debug the linter using the `Test Linter` task. +![Example](https://user-images.githubusercontent.com/15258962/85165778-2d2ce700-b21b-11ea-803e-3f6709d8e609.gif) + +We will also support [Github Codespaces](https://github.com/features/codespaces/) once it becomes available + -------------------------------------------------------------------------------- ### License diff --git a/lib/linter.sh b/lib/linter.sh index e90dde75..8b3bc141 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -659,6 +659,14 @@ GetGitHubVars() ########################################## echo "NOTE: ENV VAR [RUN_LOCAL] has been set to:[true]" echo "bypassing GitHub Actions variables..." + + ############################ + # Set the GITHUB_WORKSPACE # + ############################ + if [ -z "$GITHUB_WORKSPACE" ]; then + GITHUB_WORKSPACE="$DEFAULT_WORKSPACE" + fi + echo "Linting all files in mapped directory:[$DEFAULT_WORKSPACE]" # No need to touch or set the GITHUB_SHA @@ -666,10 +674,6 @@ GetGitHubVars() # No need to touch or set the GITHUB_ORG # No need to touch or set the GITHUB_REPO - ############################ - # Set the GITHUB_WORKSPACE # - ############################ - GITHUB_WORKSPACE="$DEFAULT_WORKSPACE" ################################# # Set the VALIDATE_ALL_CODEBASE #