mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-26 02:31:00 -05:00
Merge remote-tracking branch 'upstream/master' into color
This commit is contained in:
commit
f2db69df82
8 changed files with 103 additions and 93 deletions
53
.github/workflows/cleanup-DEV.yml
vendored
53
.github/workflows/cleanup-DEV.yml
vendored
|
@ -1,53 +0,0 @@
|
|||
---
|
||||
##########################
|
||||
##########################
|
||||
## Cleanup Docker Image ##
|
||||
##########################
|
||||
##########################
|
||||
|
||||
#
|
||||
# Documentation:
|
||||
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
|
||||
#
|
||||
|
||||
########################################
|
||||
# Run job when PR is merged and closed #
|
||||
########################################
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [closed]
|
||||
|
||||
###############
|
||||
# Set the Job #
|
||||
###############
|
||||
jobs:
|
||||
build:
|
||||
# Name the Job
|
||||
name: Cleanup Docker Image - DEV
|
||||
# Set the agent to run on
|
||||
runs-on: ubuntu-latest
|
||||
##################
|
||||
# Load all steps #
|
||||
##################
|
||||
steps:
|
||||
##########################
|
||||
# Checkout the code base #
|
||||
##########################
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
######################
|
||||
# Run Removal script #
|
||||
######################
|
||||
- name: Remove old image from DockerHub
|
||||
env:
|
||||
# Set the Env Vars
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
IMAGE_REPO: github/super-linter
|
||||
IMAGE_VERSION: ${{ github.event.pull_request.head.ref }}
|
||||
shell: bash
|
||||
run: .automation/cleanup-docker.sh
|
29
.github/workflows/deploy-DEV.yml
vendored
29
.github/workflows/deploy-DEV.yml
vendored
|
@ -20,6 +20,7 @@ on:
|
|||
push:
|
||||
branches-ignore:
|
||||
- 'master'
|
||||
pull_request: []
|
||||
|
||||
###############
|
||||
# Set the Job #
|
||||
|
@ -40,32 +41,16 @@ jobs:
|
|||
- name: Checkout Code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
#####################
|
||||
# Run Deploy script #
|
||||
#####################
|
||||
- name: Deploy DEV image to DockerHub
|
||||
env:
|
||||
# Set the Env Vars
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
IMAGE_REPO: github/super-linter
|
||||
DOCKERFILE_PATH: Dockerfile
|
||||
REGISTRY: Docker
|
||||
###################################
|
||||
# Build image locally for testing #
|
||||
###################################
|
||||
- name: Build image
|
||||
shell: bash
|
||||
run: .automation/upload-docker.sh
|
||||
|
||||
#######################
|
||||
# Get the branch name #
|
||||
#######################
|
||||
- name: Extract branch name
|
||||
shell: bash
|
||||
run: echo "::set-env name=BRANCH_NAME::$(echo ${GITHUB_REF#refs/heads/} | sed 's/[^[:alnum:]]//g')"
|
||||
run: docker build --no-cache -t github/super-linter:${GITHUB_SHA} .
|
||||
|
||||
################################
|
||||
# Run Linter against code base #
|
||||
################################
|
||||
- name: Run Test Cases
|
||||
shell: bash
|
||||
run: |
|
||||
docker pull github/super-linter:${BRANCH_NAME}
|
||||
docker run -e RUN_LOCAL=true -e TEST_CASE_RUN=true -v ${GITHUB_WORKSPACE}:/tmp/lint github/super-linter:${BRANCH_NAME}
|
||||
run: docker run -e RUN_LOCAL=true -e TEST_CASE_RUN=true -v ${GITHUB_WORKSPACE}:/tmp/lint github/super-linter:${GITHUB_SHA}
|
||||
|
|
30
.github/workflows/versioning.yml
vendored
30
.github/workflows/versioning.yml
vendored
|
@ -1,14 +1,42 @@
|
|||
name: Keep the versions up-to-date
|
||||
---
|
||||
#########################
|
||||
#########################
|
||||
## Version GitHub Tags ##
|
||||
#########################
|
||||
#########################
|
||||
|
||||
#
|
||||
# Documentation:
|
||||
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
|
||||
#
|
||||
|
||||
##########################
|
||||
# Name of the action job #
|
||||
##########################
|
||||
name: Keep GitHub tag versions up-to-date
|
||||
|
||||
#####################################################
|
||||
# Run the job when a release is published or edited #
|
||||
#####################################################
|
||||
on:
|
||||
release:
|
||||
types: [published, edited]
|
||||
|
||||
#################
|
||||
# Start the job #
|
||||
#################
|
||||
jobs:
|
||||
actions-tagger:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
#############################
|
||||
# Check out the latest code #
|
||||
#############################
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
######################
|
||||
# Run the tag action #
|
||||
######################
|
||||
- uses: Actions-R-Us/actions-tagger@latest
|
||||
with:
|
||||
publish_latest_tag: true
|
||||
|
|
14
Dockerfile
14
Dockerfile
|
@ -39,15 +39,19 @@ RUN apk add --no-cache \
|
|||
#########################################
|
||||
# Reference: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7
|
||||
# Slightly modified to always retrieve latest stable Powershell version
|
||||
RUN mkdir -p /opt/microsoft/powershell/7 \
|
||||
&& curl -s https://api.github.com/repos/powershell/powershell/releases/latest \
|
||||
# If changing PWSH_VERSION='latest' to a specific version, use format PWSH_VERSION='tags/v7.0.2'
|
||||
ARG PWSH_VERSION='latest'
|
||||
ARG PWSH_DIRECTORY='/opt/microsoft/powershell'
|
||||
ARG PSSA_VERSION='latest'
|
||||
RUN mkdir -p ${PWSH_DIRECTORY} \
|
||||
&& curl -s https://api.github.com/repos/powershell/powershell/releases/${PWSH_VERSION} \
|
||||
| grep browser_download_url \
|
||||
| grep linux-alpine-x64 \
|
||||
| cut -d '"' -f 4 \
|
||||
| xargs -n 1 wget -O - \
|
||||
| tar -xzC /opt/microsoft/powershell/7 \
|
||||
&& ln -s /opt/microsoft/powershell/7/pwsh /usr/bin/pwsh \
|
||||
&& pwsh -c 'install-module psscriptanalyzer -Scope AllUsers -force'
|
||||
| tar -xzC ${PWSH_DIRECTORY} \
|
||||
&& ln -s ${PWSH_DIRECTORY}/pwsh /usr/bin/pwsh -f \
|
||||
&& pwsh -c 'Install-Module -Name PSScriptAnalyzer -RequiredVersion ${PSSA_VERSION} -Scope AllUsers -Force'
|
||||
|
||||
#####################
|
||||
# Run Pip3 Installs #
|
||||
|
|
|
@ -59,7 +59,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base
|
|||
| **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) |
|
||||
|
||||
## How to use
|
||||
<img height="512" src="https://github.com/github/super-linter/blob/quickstart/docs/how-to.gif?raw=true" alt="How to gif">
|
||||
More in-depth [tutorial](https://www.youtube.com/watch?v=EDAmFKO4Zt0&t=118s) available
|
||||
|
||||
To use this **GitHub** Action you will need to complete the following:
|
||||
1. Create a new file in your repository called `.github/workflows/linter.yml`
|
||||
|
|
BIN
docs/how-to.gif
BIN
docs/how-to.gif
Binary file not shown.
Before Width: | Height: | Size: 17 MiB |
|
@ -84,10 +84,9 @@ CLOJURE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CLOJURE_FILE_NAME"
|
|||
LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck"
|
||||
"pylint" "perl" "rubocop" "coffeelint" "eslint" "standard"
|
||||
"ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint"
|
||||
"stylelint" "dotenv-linter" "powershell" "ktlint" "protolint" "clj-kondo"
|
||||
"stylelint" "dotenv-linter" "pwsh" "ktlint" "protolint" "clj-kondo"
|
||||
"spectral" "cfn-lint")
|
||||
|
||||
|
||||
#############################
|
||||
# Language array for prints #
|
||||
#############################
|
||||
|
@ -644,6 +643,48 @@ GetGitHubVars()
|
|||
fi
|
||||
}
|
||||
################################################################################
|
||||
#### Function ValidatePowershellModules ########################################
|
||||
function ValidatePowershellModules()
|
||||
{
|
||||
VALIDATE_PSSA_MODULE=$(pwsh -c "(Get-Module -Name PSScriptAnalyzer -ListAvailable | Select-Object -First 1).Name" 2>&1)
|
||||
# If module found, ensure Invoke-ScriptAnalyzer command is available
|
||||
if [[ "$VALIDATE_PSSA_MODULE" == "PSScriptAnalyzer" ]]; then
|
||||
VALIDATE_PSSA_CMD=$(pwsh -c "(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name" 2>&1)
|
||||
else
|
||||
# Failed to find module
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#########################################
|
||||
# validate we found the script analyzer #
|
||||
#########################################
|
||||
if [[ "$VALIDATE_PSSA_CMD" != "Invoke-ScriptAnalyzer" ]]; then
|
||||
# Failed to find module
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#######################
|
||||
# Load the error code #
|
||||
#######################
|
||||
ERROR_CODE=$?
|
||||
|
||||
##############################
|
||||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# Failed
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed find module [PSScriptAnalyzer] for [$LINTER_NAME] in system!"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[PSSA_MODULE $VALIDATE_PSSA_MODULE] [PSSA_CMD $VALIDATE_PSSA_CMD]"
|
||||
exit 1
|
||||
else
|
||||
# Success
|
||||
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then
|
||||
echo "Successfully found module [$VALIDATE_PSSA_MODULE] in system"
|
||||
echo "Successfully found command [$VALIDATE_PSSA_CMD] in system"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
################################################################################
|
||||
#### Function Footer ###########################################################
|
||||
Footer()
|
||||
{
|
||||
|
@ -1090,11 +1131,16 @@ fi
|
|||
# POWERSHELL LINTING #
|
||||
######################
|
||||
if [ "$VALIDATE_POWERSHELL" == "true" ]; then
|
||||
###############################################################
|
||||
# For POWERSHELL, ensure PSScriptAnalyzer module is available #
|
||||
###############################################################
|
||||
ValidatePowershellModules
|
||||
|
||||
#############################
|
||||
# Lint the powershell files #
|
||||
#############################
|
||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||
LintCodebase "POWERSHELL" "pwsh" "pwsh -c Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILE_ARRAY_POWERSHELL[@]}"
|
||||
LintCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILE_ARRAY_POWERSHELL[@]}"
|
||||
fi
|
||||
|
||||
###################
|
||||
|
|
|
@ -35,9 +35,9 @@ function LintCodebase()
|
|||
PRINT_ARRAY+=("----------------------------------------------")
|
||||
PRINT_ARRAY+=("----------------------------------------------")
|
||||
|
||||
#######################################
|
||||
# Validate we have jsonlint installed #
|
||||
#######################################
|
||||
#####################################
|
||||
# Validate we have linter installed #
|
||||
#####################################
|
||||
VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1)
|
||||
|
||||
#######################
|
||||
|
@ -56,7 +56,7 @@ function LintCodebase()
|
|||
else
|
||||
# Success
|
||||
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then
|
||||
echo -e "${NC}${F[B]}Successfully found binary in system${NC}"
|
||||
echo -e "${NC}${F[B]}Successfully found binary for ${F[W]}[$LINTER_NAME]${F[B]} in system${NC}"
|
||||
echo "Location:[$VALIDATE_INSTALL_CMD]"
|
||||
fi
|
||||
fi
|
||||
|
@ -166,8 +166,8 @@ function LintCodebase()
|
|||
################################
|
||||
# Lint the file with the rules #
|
||||
################################
|
||||
# Need to append "'" to make the pwsh call syntax correct, also exit with exit code from inner subshell
|
||||
LINT_CMD=$(cd "$GITHUB_WORKSPACE" || exit; $LINTER_COMMAND "$FILE"; exit $? 2>&1)
|
||||
# Need to run PowerShell commands using pwsh -c, also exit with exit code from inner subshell
|
||||
LINT_CMD=$(cd "$GITHUB_WORKSPACE" || exit; pwsh -c "($LINTER_COMMAND $FILE)"; exit $? 2>&1)
|
||||
else
|
||||
################################
|
||||
# Lint the file with the rules #
|
||||
|
@ -333,8 +333,8 @@ function TestCodebase()
|
|||
################################
|
||||
# Lint the file with the rules #
|
||||
################################
|
||||
# Need to append "'" to make the pwsh call syntax correct, also exit with exit code from inner subshell
|
||||
LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; $LINTER_COMMAND "$FILE"; exit $? 2>&1)
|
||||
# Need to run PowerShell commands using pwsh -c, also exit with exit code from inner subshell
|
||||
LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; pwsh -c "($LINTER_COMMAND $FILE)"; exit $? 2>&1)
|
||||
else
|
||||
################################
|
||||
# Lint the file with the rules #
|
||||
|
|
Loading…
Reference in a new issue