mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-24 23:21:12 -05:00
Merge branch 'master' into feature/tap-format
This commit is contained in:
commit
7cf73e5dc5
37 changed files with 712 additions and 102 deletions
|
@ -19,4 +19,5 @@ When the script is triggered in a branch, it will push with the tag:**NameOfBran
|
||||||
- **Note:** The branch name will be reduced to alphanumeric for consistency and uploading
|
- **Note:** The branch name will be reduced to alphanumeric for consistency and uploading
|
||||||
|
|
||||||
## test
|
## test
|
||||||
|
|
||||||
This folder holds all **Test Cases** to help run the *CI/CT/CD* process for the **Super-Linter**.
|
This folder holds all **Test Cases** to help run the *CI/CT/CD* process for the **Super-Linter**.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
############# Cleanup Image on DockerHub @admiralawkbar ########################
|
############# Cleanup Image on DockerHub @admiralawkbar ########################
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
# Its based on being built from a GitHub Action, but could be easily updated
|
# Its based on being built from a GitHub Action, but could be easily updated
|
||||||
# To be ran in a different medium.
|
# To be ran in a different medium.
|
||||||
#
|
#
|
||||||
# PRE-Reqs:
|
# PRE-Requirements:
|
||||||
# - Dockerfile
|
# - Dockerfile
|
||||||
# - System with Docker installed
|
# - System with Docker installed
|
||||||
# - Global variables met
|
# - Global variables met
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Script to run ghe-config-apply on the primary GHES instance
|
# Script to run ghe-config-apply on the primary GHES instance
|
||||||
|
@ -35,7 +35,7 @@ CheckGHEPid()
|
||||||
################################################
|
################################################
|
||||||
if [ ! -f "$GHE_CONFIG_PID" ]; then
|
if [ ! -f "$GHE_CONFIG_PID" ]; then
|
||||||
# File not found
|
# File not found
|
||||||
echo "Were good to move forward, no .pid file found at:[$GHE_CONFIG_PID]"
|
echo "We're good to move forward, no .pid file found at:[$GHE_CONFIG_PID]"
|
||||||
else
|
else
|
||||||
# Found the pid running, need to sleep
|
# Found the pid running, need to sleep
|
||||||
echo "Current PID found, sleeping $SLEEP_SECONDS seconds before next check..."
|
echo "Current PID found, sleeping $SLEEP_SECONDS seconds before next check..."
|
||||||
|
@ -189,10 +189,10 @@ CheckGHEProcess
|
||||||
####################
|
####################
|
||||||
RunConfigApply
|
RunConfigApply
|
||||||
|
|
||||||
##########################################
|
###########################################
|
||||||
# Were going to run it again after a nap #
|
# We're going to run it again after a nap #
|
||||||
# to make sure there is no crazy actions #
|
# to make sure there is no crazy actions #
|
||||||
##########################################
|
###########################################
|
||||||
sleep 300s
|
sleep 300s
|
||||||
|
|
||||||
######################
|
######################
|
||||||
|
|
13
.automation/test/clojure/README.md
Normal file
13
.automation/test/clojure/README.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# Clojure Test Cases
|
||||||
|
This folder holds the test cases for **Clojure**.
|
||||||
|
|
||||||
|
## Additional Docs
|
||||||
|
No Additional information is needed for this test case.
|
||||||
|
|
||||||
|
## Good Test Cases
|
||||||
|
The test cases denoted: `LANGUAGE_good_FILE.EXTENSION` are all valid, and should pass successfully when linted.
|
||||||
|
- **Note:** They are linted utilizing the default linter rules.
|
||||||
|
|
||||||
|
## Bad Test Cases
|
||||||
|
The test cases denoted: `LANGUAGE_bad_FILE.EXTENSION` are **NOT** valid, and should trigger errors when linted.
|
||||||
|
- **Note:** They are linted utilizing the default linter rules.
|
64
.automation/test/clojure/clojure_bad_1.clj
Normal file
64
.automation/test/clojure/clojure_bad_1.clj
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
(ns foo
|
||||||
|
(:require
|
||||||
|
[clojure.string :as str]
|
||||||
|
;; We're never using this namespace. Also, the namespaces aren't sorted.
|
||||||
|
[clojure.set :as set]))
|
||||||
|
|
||||||
|
;; Here we made a typo, so the symbol is unresolved:
|
||||||
|
(but-last [1 2 3])
|
||||||
|
|
||||||
|
;; Clj-kondo knows about arities of clojure namespaces, but you can also teach
|
||||||
|
;; it about your libraries or own namespaces
|
||||||
|
(str/join)
|
||||||
|
|
||||||
|
;; foo has an arity of 2, but we're not actually using y
|
||||||
|
(defn foo-fn [x y]
|
||||||
|
;; this do is redundant:
|
||||||
|
(do
|
||||||
|
;; this is handy for debugging, but please remove it before pushing your code:
|
||||||
|
(def tmp_x x)
|
||||||
|
(let [y (fn [] (inc x))]
|
||||||
|
;; the next let can be squashed together with the previous:
|
||||||
|
(let [z y]
|
||||||
|
;; whoopsy, calling a local function with an incorrect number of args:
|
||||||
|
(y x)
|
||||||
|
;; also wrong:
|
||||||
|
(recur)))))
|
||||||
|
|
||||||
|
(letfn
|
||||||
|
[(f [] (h 1))
|
||||||
|
(h [] (f 1))])
|
||||||
|
|
||||||
|
(defn- private-fn [])
|
||||||
|
;; redefining it...
|
||||||
|
(defn- private-fn [])
|
||||||
|
|
||||||
|
(defn foo [] :foo)
|
||||||
|
;; Type error, because foo doesn't return a number!
|
||||||
|
(inc (foo))
|
||||||
|
|
||||||
|
;; I'm tired now, let's sleep...
|
||||||
|
;; Oops, not happening because of wrong amount of args:
|
||||||
|
(Thread/sleep 1000 1 2)
|
||||||
|
|
||||||
|
;; Here we switch to another namespace and require the previous:
|
||||||
|
(ns bar (:require [foo :as f]))
|
||||||
|
|
||||||
|
;; Wrong arity when calling a function from the previous namespace:
|
||||||
|
(f/foo-fn)
|
||||||
|
|
||||||
|
;; private:
|
||||||
|
(f/private-fn)
|
||||||
|
|
||||||
|
;; this won't pass the reader:
|
||||||
|
{:a 1 :a 2}
|
||||||
|
;; and neither will this:
|
||||||
|
#{1 1}
|
||||||
|
;; nor this:
|
||||||
|
{:a 1 :b}
|
||||||
|
|
||||||
|
(ns bar-test (:require [clojure.test :as t]))
|
||||||
|
|
||||||
|
(t/deftest my-tests
|
||||||
|
;; you're not actually testing something here:
|
||||||
|
(odd? (inc 1)))
|
34
.automation/test/clojure/clojure_good_1.clj
Normal file
34
.automation/test/clojure/clojure_good_1.clj
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
(ns foo
|
||||||
|
(:require
|
||||||
|
[clojure.string :as str]))
|
||||||
|
|
||||||
|
(butlast [1 2 3])
|
||||||
|
|
||||||
|
(str/join "" "")
|
||||||
|
|
||||||
|
(defn foo-fn [x]
|
||||||
|
(let [y (fn [] (inc x))]
|
||||||
|
(y)))
|
||||||
|
|
||||||
|
(letfn
|
||||||
|
[(f [g] (h g))
|
||||||
|
(h [i] (f i))])
|
||||||
|
|
||||||
|
(defn foo [] 1)
|
||||||
|
(inc (foo))
|
||||||
|
|
||||||
|
(Thread/sleep 1000 1)
|
||||||
|
|
||||||
|
;; Here we switch to another namespace and require the previous:
|
||||||
|
(ns bar (:require [foo :as f]))
|
||||||
|
|
||||||
|
(f/foo-fn 1)
|
||||||
|
|
||||||
|
{:a 1 :b 2}
|
||||||
|
#{1 2}
|
||||||
|
{:a 1 :b 2}
|
||||||
|
|
||||||
|
(ns bar-test (:require [clojure.test :as t]))
|
||||||
|
|
||||||
|
(t/deftest my-tests
|
||||||
|
(t/is (odd? (inc 1))))
|
|
@ -6,7 +6,7 @@
|
||||||
# `mona echo *` - repeats what you say
|
# `mona echo *` - repeats what you say
|
||||||
#
|
#
|
||||||
# Author:
|
# Author:
|
||||||
# admiralAwkbar@github.com
|
# admiralawkbar@github.com
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
# Drop Hammer array of images #
|
# Drop Hammer array of images #
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
# `mona echo *` - repeats what you say
|
# `mona echo *` - repeats what you say
|
||||||
#
|
#
|
||||||
# Author:
|
# Author:
|
||||||
# admiralAwkbar@github.com
|
# admiralawkbar@github.com
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
# Drop Hammer array of images #
|
# Drop Hammer array of images #
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* Bad */
|
/* Bad */
|
||||||
/* Multiline */
|
/* Multi-line */
|
||||||
/* Comment */
|
/* Comment */
|
||||||
.selector-3[type="text"] {
|
.selector-3[type="text"] {
|
||||||
background: linear-gradient(#FFFFFF, rgba(0, 0, 0, 0.8));
|
background: linear-gradient(#FFFFFF, rgba(0, 0, 0, 0.8));
|
||||||
|
|
|
@ -16,5 +16,5 @@ ls -la
|
||||||
|
|
||||||
# Walk away
|
# Walk away
|
||||||
|
|
||||||
Were all done **here**.
|
We're all done **here**.
|
||||||
- [Link Action]https://github.com
|
- [Link Action]https://github.com
|
||||||
|
|
|
@ -16,5 +16,5 @@ ls -la
|
||||||
|
|
||||||
### Walk away
|
### Walk away
|
||||||
|
|
||||||
Were all done **here**.
|
We're all done **here**.
|
||||||
- [Link Action](https://github.com)
|
- [Link Action](https://github.com)
|
||||||
|
|
14
.automation/test/openapi/README.md
Normal file
14
.automation/test/openapi/README.md
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# OpenAPI Test Cases
|
||||||
|
This folder holds the test cases for **OpenAPI**.
|
||||||
|
|
||||||
|
## Additional Docs
|
||||||
|
The `_bad_` tests are valid `.yml`/`.json` but invalid OpenAPI specs.
|
||||||
|
The test extensions used are `.ymlopenapi`/`.jsonopenapi` instead of `.yml`/`.json`. This is to prevent the [YAML] and [JSON] tests from picking them up.
|
||||||
|
|
||||||
|
## Good Test Cases
|
||||||
|
The test cases denoted: `LANGUAGE_good_FILE.EXTENSION` are all valid, and should pass successfully when linted.
|
||||||
|
- **Note:** They are linted utilizing the default linter rules.
|
||||||
|
|
||||||
|
## Bad Test Cases
|
||||||
|
The test cases denoted: `LANGUAGE_bad_FILE.EXTENSION` are **NOT** valid, and should trigger errors when linted.
|
||||||
|
- **Note:** They are linted utilizing the default linter rules.
|
1
.automation/test/openapi/openapi_bad_1.ymlopenapi
Normal file
1
.automation/test/openapi/openapi_bad_1.ymlopenapi
Normal file
|
@ -0,0 +1 @@
|
||||||
|
openapi: '3.0.0'
|
3
.automation/test/openapi/openapi_bad_2.jsonopenapi
Normal file
3
.automation/test/openapi/openapi_bad_2.jsonopenapi
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"openapi": "3.0.0"
|
||||||
|
}
|
13
.automation/test/openapi/openapi_good_1.ymlopenapi
Normal file
13
.automation/test/openapi/openapi_good_1.ymlopenapi
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
openapi: 3.0.0
|
||||||
|
info:
|
||||||
|
title: Example
|
||||||
|
version: '1.0'
|
||||||
|
contact:
|
||||||
|
name: Justin Kalland
|
||||||
|
email: justin@kalland.com
|
||||||
|
description: Test for super-linter
|
||||||
|
servers:
|
||||||
|
- url: 'http://localhost:3000'
|
||||||
|
paths: {}
|
||||||
|
tags:
|
||||||
|
- name: example
|
23
.automation/test/openapi/openapi_good_2.jsonopenapi
Normal file
23
.automation/test/openapi/openapi_good_2.jsonopenapi
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"openapi": "3.0.0",
|
||||||
|
"info": {
|
||||||
|
"title": "Example",
|
||||||
|
"version": "1.0",
|
||||||
|
"contact": {
|
||||||
|
"name": "Justin Kalland",
|
||||||
|
"email": "justin@kalland.com"
|
||||||
|
},
|
||||||
|
"description": "Test for super-linter"
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "http://localhost:3000"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {},
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"name": "example"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
################################################################################
|
################################################################################
|
||||||
################################################################################
|
################################################################################
|
||||||
######### Script action @admiralAwkbar #########################################
|
######### Script action @admiralawkbar #########################################
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
#############
|
#############
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
################################################################################
|
################################################################################
|
||||||
################################################################################
|
################################################################################
|
||||||
######### Script action @admiralAwkbar #########################################
|
######### Script action @admiralawkbar #########################################
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
#############
|
#############
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# CMD
|
# CMD
|
||||||
HELLO_WORLD=($(echo "Hello World" | cut -f1 -d' ' 2>&1))
|
HELLO_WORLD=($(echo "Hello World" | cut -f1 -d' ' 2>&1))
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# CMD
|
# CMD
|
||||||
HELLO_WORLD=$(echo "Hello World" | cut -f1 -d' ' 2>&1)
|
HELLO_WORLD=$(echo "Hello World" | cut -f1 -d' ' 2>&1)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
############# Deploy Container to DockerHub @admiralawkbar #####################
|
############# Deploy Container to DockerHub @admiralawkbar #####################
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
# Its based on being built from a GitHub Action, but could be easily updated
|
# Its based on being built from a GitHub Action, but could be easily updated
|
||||||
# To be ran in a different medium.
|
# To be ran in a different medium.
|
||||||
#
|
#
|
||||||
# PRE-Reqs:
|
# PRE-Requirements:
|
||||||
# - Dockerfile
|
# - Dockerfile
|
||||||
# - System with Docker installed
|
# - System with Docker installed
|
||||||
# - Global variables met
|
# - Global variables met
|
||||||
|
@ -20,6 +20,9 @@
|
||||||
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # GitHub Workspace
|
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # GitHub Workspace
|
||||||
DOCKER_USERNAME="${DOCKER_USERNAME}" # Username to login to DockerHub
|
DOCKER_USERNAME="${DOCKER_USERNAME}" # Username to login to DockerHub
|
||||||
DOCKER_PASSWORD="${DOCKER_PASSWORD}" # Password to login to DockerHub
|
DOCKER_PASSWORD="${DOCKER_PASSWORD}" # Password to login to DockerHub
|
||||||
|
GPR_USERNAME="${GPR_USERNAME}" # Username to login to GitHub package registry
|
||||||
|
GPR_TOKEN="${GPR_TOKEN}" # Password to login to GitHub package registry
|
||||||
|
REGISTRY="${REGISTRY}" # What registry to upload | <GPR> or <Docker>
|
||||||
IMAGE_REPO="${IMAGE_REPO}" # Image repo to upload the image
|
IMAGE_REPO="${IMAGE_REPO}" # Image repo to upload the image
|
||||||
IMAGE_VERSION="${IMAGE_VERSION}" # Version to tag the image
|
IMAGE_VERSION="${IMAGE_VERSION}" # Version to tag the image
|
||||||
DOCKERFILE_PATH="${DOCKERFILE_PATH}" # Path to the Dockerfile to be uploaded
|
DOCKERFILE_PATH="${DOCKERFILE_PATH}" # Path to the Dockerfile to be uploaded
|
||||||
|
@ -33,7 +36,7 @@ Header()
|
||||||
{
|
{
|
||||||
echo ""
|
echo ""
|
||||||
echo "-------------------------------------------------------"
|
echo "-------------------------------------------------------"
|
||||||
echo "------ GitHub Actions Upload image to DockerHub -------"
|
echo "---- GitHub Actions Upload image to [$REGISTRY] ----"
|
||||||
echo "-------------------------------------------------------"
|
echo "-------------------------------------------------------"
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
@ -51,9 +54,9 @@ ValidateInput()
|
||||||
echo "----------------------------------------------"
|
echo "----------------------------------------------"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
############################
|
#############################
|
||||||
# Validate GITHUB_WORKSPACE #
|
# Validate GITHUB_WORKSPACE #
|
||||||
############################
|
#############################
|
||||||
if [ -z "$GITHUB_WORKSPACE" ]; then
|
if [ -z "$GITHUB_WORKSPACE" ]; then
|
||||||
echo "ERROR! Failed to get [GITHUB_WORKSPACE]!"
|
echo "ERROR! Failed to get [GITHUB_WORKSPACE]!"
|
||||||
echo "ERROR:[$GITHUB_WORKSPACE]"
|
echo "ERROR:[$GITHUB_WORKSPACE]"
|
||||||
|
@ -62,28 +65,77 @@ ValidateInput()
|
||||||
echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]"
|
echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
############################
|
#####################
|
||||||
# Validate DOCKER_USERNAME #
|
# Validate REGISTRY #
|
||||||
############################
|
#####################
|
||||||
if [ -z "$DOCKER_USERNAME" ]; then
|
if [ -z "$REGISTRY" ]; then
|
||||||
echo "ERROR! Failed to get [DOCKER_USERNAME]!"
|
echo "ERROR! Failed to get [REGISTRY]!"
|
||||||
echo "ERROR:[$DOCKER_USERNAME]"
|
echo "ERROR:[$REGISTRY]"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "Successfully found:[DOCKER_USERNAME], value:[$DOCKER_USERNAME]"
|
echo "Successfully found:[REGISTRY], value:[$REGISTRY]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
############################
|
#####################################################
|
||||||
# Validate DOCKER_PASSWORD #
|
# See if we need values for GitHub package Registry #
|
||||||
############################
|
#####################################################
|
||||||
if [ -z "$DOCKER_PASSWORD" ]; then
|
if [[ "$REGISTRY" == "GPR" ]]; then
|
||||||
echo "ERROR! Failed to get [DOCKER_PASSWORD]!"
|
#########################
|
||||||
echo "ERROR:[$DOCKER_PASSWORD]"
|
# Validate GPR_USERNAME #
|
||||||
exit 1
|
#########################
|
||||||
|
if [ -z "$GPR_USERNAME" ]; then
|
||||||
|
echo "ERROR! Failed to get [GPR_USERNAME]!"
|
||||||
|
echo "ERROR:[$GPR_USERNAME]"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Successfully found:[GPR_USERNAME], value:[$GPR_USERNAME]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
######################
|
||||||
|
# Validate GPR_TOKEN #
|
||||||
|
######################
|
||||||
|
if [ -z "$GPR_TOKEN" ]; then
|
||||||
|
echo "ERROR! Failed to get [GPR_TOKEN]!"
|
||||||
|
echo "ERROR:[$GPR_TOKEN]"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Successfully found:[GPR_TOKEN], value:[********]"
|
||||||
|
fi
|
||||||
|
########################################
|
||||||
|
# See if we need values for Ducker hub #
|
||||||
|
########################################
|
||||||
|
elif [[ "$REGISTRY" == "Docker" ]]; then
|
||||||
|
############################
|
||||||
|
# Validate DOCKER_USERNAME #
|
||||||
|
############################
|
||||||
|
if [ -z "$DOCKER_USERNAME" ]; then
|
||||||
|
echo "ERROR! Failed to get [DOCKER_USERNAME]!"
|
||||||
|
echo "ERROR:[$DOCKER_USERNAME]"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Successfully found:[DOCKER_USERNAME], value:[$DOCKER_USERNAME]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
############################
|
||||||
|
# Validate DOCKER_PASSWORD #
|
||||||
|
############################
|
||||||
|
if [ -z "$DOCKER_PASSWORD" ]; then
|
||||||
|
echo "ERROR! Failed to get [DOCKER_PASSWORD]!"
|
||||||
|
echo "ERROR:[$DOCKER_PASSWORD]"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Successfully found:[DOCKER_PASSWORD], value:[********]"
|
||||||
|
fi
|
||||||
|
###########################################
|
||||||
|
# We were not passed a registry to update #
|
||||||
|
###########################################
|
||||||
else
|
else
|
||||||
echo "Successfully found:[DOCKER_PASSWORD], value:[********]"
|
echo "ERROR! Failed to find a valid registry!"
|
||||||
|
echo "Registry:[$REGISTRY]"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Validate IMAGE_REPO #
|
# Validate IMAGE_REPO #
|
||||||
#######################
|
#######################
|
||||||
|
@ -93,6 +145,14 @@ ValidateInput()
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "Successfully found:[IMAGE_REPO], value:[$IMAGE_REPO]"
|
echo "Successfully found:[IMAGE_REPO], value:[$IMAGE_REPO]"
|
||||||
|
###############################################
|
||||||
|
# Need to see if GPR registry and update name #
|
||||||
|
###############################################
|
||||||
|
if [[ "$REGISTRY" == "GPR" ]]; then
|
||||||
|
NAME="docker.pkg.github/$IMAGE_REPO"
|
||||||
|
IMAGE_REPO="$NAME"
|
||||||
|
echo "Updated [IMAGE_REPO] to:[$IMAGE_REPO] for GPR"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
|
@ -146,22 +206,30 @@ ValidateInput()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
#### Function LoginToDocker ####################################################
|
#### Function Authenticate #####################################################
|
||||||
LoginToDocker()
|
Authenticate()
|
||||||
{
|
{
|
||||||
|
################
|
||||||
|
# Pull in Vars #
|
||||||
|
################
|
||||||
|
USERNAME="$1" # Name to auth with
|
||||||
|
PASSWORD="$2" # Password to auth with
|
||||||
|
URL="$3" # Url to auth towards
|
||||||
|
NAME="$4" # name of the service
|
||||||
|
|
||||||
################
|
################
|
||||||
# Print header #
|
# Print header #
|
||||||
################
|
################
|
||||||
echo ""
|
echo ""
|
||||||
echo "----------------------------------------------"
|
echo "----------------------------------------------"
|
||||||
echo "Login to DockerHub..."
|
echo "Login to $NAME..."
|
||||||
echo "----------------------------------------------"
|
echo "----------------------------------------------"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
######################
|
###################
|
||||||
# Login to DockerHub #
|
# Auth to service #
|
||||||
######################
|
###################
|
||||||
LOGIN_CMD=$(docker login --username "$DOCKER_USERNAME" --password "$DOCKER_PASSWORD" 2>&1)
|
LOGIN_CMD=$(docker login "$URL" --username "$USERNAME" --password "$PASSWORD" 2>&1)
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Load the error code #
|
# Load the error code #
|
||||||
|
@ -173,12 +241,12 @@ LoginToDocker()
|
||||||
##############################
|
##############################
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
if [ $ERROR_CODE -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo "ERROR! Failed to authenticate to DockerHub!"
|
echo "ERROR! Failed to authenticate to $NAME!"
|
||||||
echo "ERROR:[$LOGIN_CMD]"
|
echo "ERROR:[$LOGIN_CMD]"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo "Successfully authenticated to DockerHub!"
|
echo "Successfully authenticated to $NAME!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -194,7 +262,6 @@ BuildImage()
|
||||||
echo "----------------------------------------------"
|
echo "----------------------------------------------"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
################################
|
################################
|
||||||
# Validate the DOCKERFILE_PATH #
|
# Validate the DOCKERFILE_PATH #
|
||||||
################################
|
################################
|
||||||
|
@ -238,7 +305,7 @@ UploadImage()
|
||||||
################
|
################
|
||||||
echo ""
|
echo ""
|
||||||
echo "----------------------------------------------"
|
echo "----------------------------------------------"
|
||||||
echo "Uploading the DockerFile image..."
|
echo "Uploading the DockerFile image to $REGISTRY..."
|
||||||
echo "----------------------------------------------"
|
echo "----------------------------------------------"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
@ -261,7 +328,7 @@ UploadImage()
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo "Successfully Uploaded Docker image to DockerHub!"
|
echo "Successfully Uploaded Docker image to $REGISTRY!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
|
@ -329,16 +396,34 @@ Header
|
||||||
##################
|
##################
|
||||||
ValidateInput
|
ValidateInput
|
||||||
|
|
||||||
######################
|
|
||||||
# Login to DockerHub #
|
|
||||||
######################
|
|
||||||
LoginToDocker
|
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Build the image #
|
# Build the image #
|
||||||
###################
|
###################
|
||||||
BuildImage
|
BuildImage
|
||||||
|
|
||||||
|
######################
|
||||||
|
# Login to DockerHub #
|
||||||
|
######################
|
||||||
|
if [[ "$REGISTRY" == "Docker" ]]; then
|
||||||
|
# Authenticate "Username" "Password" "Url" "Name"
|
||||||
|
Authenticate "$DOCKER_USERNAME" "$DOCKER_PASSWORD" "" "Dockerhub"
|
||||||
|
|
||||||
|
####################################
|
||||||
|
# Login to GitHub Package Registry #
|
||||||
|
####################################
|
||||||
|
elif [[ "$REGISTRY" == "GPR" ]]; then
|
||||||
|
# Authenticate "Username" "Password" "Url" "Name"
|
||||||
|
Authenticate "$GPR_USERNAME" "$GPR_TOKEN" "https://docker.pkg.github.com" "GitHub Package Registry"
|
||||||
|
|
||||||
|
else
|
||||||
|
#########
|
||||||
|
# ERROR #
|
||||||
|
#########
|
||||||
|
echo "ERROR! Registry not set correctly!"
|
||||||
|
echo "Registry:[$REGISTRY]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Upload the image #
|
# Upload the image #
|
||||||
####################
|
####################
|
||||||
|
|
7
.github/CONTRIBUTING.md
vendored
7
.github/CONTRIBUTING.md
vendored
|
@ -33,9 +33,10 @@ Draft pull requests are also welcome to get feedback early on, or if there is so
|
||||||
If you are the current maintainer of this action:
|
If you are the current maintainer of this action:
|
||||||
1. Update `README.md` and the wiki to reflect new version number in the example workflow file sections
|
1. Update `README.md` and the wiki to reflect new version number in the example workflow file sections
|
||||||
2. Draft [Release](https://help.github.com/en/github/administering-a-repository/managing-releases-in-a-repository) with a summarized changelog
|
2. Draft [Release](https://help.github.com/en/github/administering-a-repository/managing-releases-in-a-repository) with a summarized changelog
|
||||||
3. Publish the docker image to GitHub package registry
|
3. Ensure you check the box for [publishing to the marketplace](https://help.github.com/en/actions/creating-actions/publishing-actions-in-github-marketplace#publishing-an-action)
|
||||||
4. Publish the docker image to Docker Hub
|
4. A GitHub Action will Publish the Docker image to GitHub Package Registry once a Release is created
|
||||||
5. Look for approval from [CODEOWNERS](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners)
|
5. A GitHub Action will Publish the Docker image to Docker Hub once a Release is created
|
||||||
|
6. Look for approval from [CODEOWNERS](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners)
|
||||||
|
|
||||||
## Resources
|
## Resources
|
||||||
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
|
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
|
||||||
|
|
2
.github/linters/.clj-kondo/config.edn
vendored
Normal file
2
.github/linters/.clj-kondo/config.edn
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
{:linters {:unresolved-symbol {:exclude [(compojure.api.sweet/defroutes)]}
|
||||||
|
:refer-all {:exclude [clj-time.jdbc]}}}
|
9
.github/linters/.openapirc.yml
vendored
Normal file
9
.github/linters/.openapirc.yml
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
##########################
|
||||||
|
##########################
|
||||||
|
## OpenAPI Linter rules ##
|
||||||
|
##########################
|
||||||
|
##########################
|
||||||
|
|
||||||
|
extends: spectral:oas
|
2
.github/workflows/cleanup-DEV.yml
vendored
2
.github/workflows/cleanup-DEV.yml
vendored
|
@ -47,7 +47,7 @@ jobs:
|
||||||
# Set the Env Vars
|
# Set the Env Vars
|
||||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
IMAGE_REPO: admiralawkbar/super-linter
|
IMAGE_REPO: github/super-linter
|
||||||
IMAGE_VERSION: ${{ github.event.pull_request.head.ref }}
|
IMAGE_VERSION: ${{ github.event.pull_request.head.ref }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: .automation/cleanup-docker.sh
|
run: .automation/cleanup-docker.sh
|
||||||
|
|
3
.github/workflows/deploy-DEV.yml
vendored
3
.github/workflows/deploy-DEV.yml
vendored
|
@ -43,13 +43,14 @@ jobs:
|
||||||
#####################
|
#####################
|
||||||
# Run Deploy script #
|
# Run Deploy script #
|
||||||
#####################
|
#####################
|
||||||
- name: Deploy image to DockerHub
|
- name: Deploy DEV image to DockerHub
|
||||||
env:
|
env:
|
||||||
# Set the Env Vars
|
# Set the Env Vars
|
||||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
IMAGE_REPO: github/super-linter
|
IMAGE_REPO: github/super-linter
|
||||||
DOCKERFILE_PATH: Dockerfile
|
DOCKERFILE_PATH: Dockerfile
|
||||||
|
REGISTRY: Docker
|
||||||
shell: bash
|
shell: bash
|
||||||
run: .automation/upload-docker.sh
|
run: .automation/upload-docker.sh
|
||||||
|
|
||||||
|
|
3
.github/workflows/deploy-PROD.yml
vendored
3
.github/workflows/deploy-PROD.yml
vendored
|
@ -40,7 +40,7 @@ jobs:
|
||||||
#####################
|
#####################
|
||||||
# Run Deploy script #
|
# Run Deploy script #
|
||||||
#####################
|
#####################
|
||||||
- name: Deploy image to DockerHub
|
- name: Deploy latest image to DockerHub
|
||||||
env:
|
env:
|
||||||
# Set the Env Vars
|
# Set the Env Vars
|
||||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
@ -48,5 +48,6 @@ jobs:
|
||||||
IMAGE_REPO: github/super-linter
|
IMAGE_REPO: github/super-linter
|
||||||
IMAGE_VERSION: latest
|
IMAGE_VERSION: latest
|
||||||
DOCKERFILE_PATH: Dockerfile
|
DOCKERFILE_PATH: Dockerfile
|
||||||
|
REGISTRY: Docker
|
||||||
shell: bash
|
shell: bash
|
||||||
run: .automation/upload-docker.sh
|
run: .automation/upload-docker.sh
|
||||||
|
|
68
.github/workflows/deploy-RELEASE.yml
vendored
Normal file
68
.github/workflows/deploy-RELEASE.yml
vendored
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
---
|
||||||
|
#########################
|
||||||
|
#########################
|
||||||
|
## Deploy Docker Image ##
|
||||||
|
#########################
|
||||||
|
#########################
|
||||||
|
|
||||||
|
#
|
||||||
|
# Documentation:
|
||||||
|
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
|
||||||
|
#
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# Start the job on all push to master #
|
||||||
|
#######################################
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
# Want to run the automation when a release is created
|
||||||
|
types: ['created']
|
||||||
|
|
||||||
|
###############
|
||||||
|
# Set the Job #
|
||||||
|
###############
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
# Name the Job
|
||||||
|
name: Deploy Docker Image - Release
|
||||||
|
# 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
|
||||||
|
|
||||||
|
###################################
|
||||||
|
# Run Deploy script for Dockerhub #
|
||||||
|
###################################
|
||||||
|
- name: Deploy Release image to 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.release.tag_name }}
|
||||||
|
DOCKERFILE_PATH: Dockerfile
|
||||||
|
REGISTRY: Docker
|
||||||
|
shell: bash
|
||||||
|
run: .automation/upload-docker.sh
|
||||||
|
|
||||||
|
#############################
|
||||||
|
# Run Deploy script for GPR #
|
||||||
|
#############################
|
||||||
|
- name: Deploy Release image to GitHub Package Registry
|
||||||
|
env:
|
||||||
|
# Set the Env Vars
|
||||||
|
GPR_USERNAME: ${{ secrets.GPR_USERNAME }}
|
||||||
|
GPR_TOKEN: ${{ secrets.GPR_TOKEN }}
|
||||||
|
IMAGE_REPO: github/super-linter
|
||||||
|
IMAGE_VERSION: ${{ github.event.release.tag_name }}
|
||||||
|
DOCKERFILE_PATH: Dockerfile
|
||||||
|
REGISTRY: GPR
|
||||||
|
shell: bash
|
||||||
|
run: .automation/upload-docker.sh
|
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -29,7 +29,7 @@ bower_components
|
||||||
# node-waf configuration
|
# node-waf configuration
|
||||||
.lock-wscript
|
.lock-wscript
|
||||||
|
|
||||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
# Compiled binary add-ons (https://nodejs.org/api/addons.html)
|
||||||
build/Release
|
build/Release
|
||||||
|
|
||||||
# Dependency directories
|
# Dependency directories
|
||||||
|
@ -60,5 +60,8 @@ typings/
|
||||||
# next.js build output
|
# next.js build output
|
||||||
.next
|
.next
|
||||||
|
|
||||||
|
# clj-kondo cache
|
||||||
|
.cache
|
||||||
|
|
||||||
# default output report
|
# default output report
|
||||||
super-linter.report
|
super-linter.report
|
||||||
|
|
15
Dockerfile
15
Dockerfile
|
@ -27,7 +27,7 @@ RUN apk add --no-cache \
|
||||||
libxml2-utils perl \
|
libxml2-utils perl \
|
||||||
ruby ruby-dev ruby-bundler ruby-rdoc make \
|
ruby ruby-dev ruby-bundler ruby-rdoc make \
|
||||||
py3-setuptools ansible-lint \
|
py3-setuptools ansible-lint \
|
||||||
go \
|
go \
|
||||||
openjdk8-jre \
|
openjdk8-jre \
|
||||||
php7 \
|
php7 \
|
||||||
ca-certificates less ncurses-terminfo-base \
|
ca-certificates less ncurses-terminfo-base \
|
||||||
|
@ -72,6 +72,7 @@ RUN npm config set package-lock false \
|
||||||
eslint-plugin-jest \
|
eslint-plugin-jest \
|
||||||
stylelint \
|
stylelint \
|
||||||
stylelint-config-standard \
|
stylelint-config-standard \
|
||||||
|
@stoplight/spectral \
|
||||||
&& npm --no-cache install \
|
&& npm --no-cache install \
|
||||||
markdownlint-cli \
|
markdownlint-cli \
|
||||||
jsonlint prettyjson \
|
jsonlint prettyjson \
|
||||||
|
@ -131,6 +132,15 @@ RUN curl -Ls "$(curl -Ls https://api.github.com/repos/terraform-linters/tflint/r
|
||||||
RUN wget "https://github.com/dotenv-linter/dotenv-linter/releases/latest/download/dotenv-linter-alpine-x86_64.tar.gz" -O - -q | tar -xzf - \
|
RUN wget "https://github.com/dotenv-linter/dotenv-linter/releases/latest/download/dotenv-linter-alpine-x86_64.tar.gz" -O - -q | tar -xzf - \
|
||||||
&& mv "dotenv-linter" /usr/bin
|
&& mv "dotenv-linter" /usr/bin
|
||||||
|
|
||||||
|
#####################
|
||||||
|
# Install clj-kondo #
|
||||||
|
#####################
|
||||||
|
ARG CLJ_KONDO_VERSION='2020.06.12'
|
||||||
|
RUN curl -sLO https://github.com/borkdude/clj-kondo/releases/download/v${CLJ_KONDO_VERSION}/clj-kondo-${CLJ_KONDO_VERSION}-linux-static-amd64.zip \
|
||||||
|
&& unzip clj-kondo-${CLJ_KONDO_VERSION}-linux-static-amd64.zip \
|
||||||
|
&& rm clj-kondo-${CLJ_KONDO_VERSION}-linux-static-amd64.zip \
|
||||||
|
&& mv clj-kondo /usr/bin/
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# Install ktlint #
|
# Install ktlint #
|
||||||
##################
|
##################
|
||||||
|
@ -145,6 +155,7 @@ ENV GITHUB_SHA=${GITHUB_SHA} \
|
||||||
GITHUB_WORKSPACE=${GITHUB_WORKSPACE} \
|
GITHUB_WORKSPACE=${GITHUB_WORKSPACE} \
|
||||||
DEFAULT_BRANCH=${DEFAULT_BRANCH} \
|
DEFAULT_BRANCH=${DEFAULT_BRANCH} \
|
||||||
VALIDATE_ALL_CODEBASE=${VALIDATE_ALL_CODEBASE} \
|
VALIDATE_ALL_CODEBASE=${VALIDATE_ALL_CODEBASE} \
|
||||||
|
LINTER_RULES_PATH=${LINTER_RULES_PATH} \
|
||||||
VALIDATE_YAML=${VALIDATE_YAML} \
|
VALIDATE_YAML=${VALIDATE_YAML} \
|
||||||
VALIDATE_JSON=${VALIDATE_JSON} \
|
VALIDATE_JSON=${VALIDATE_JSON} \
|
||||||
VALIDATE_XML=${VALIDATE_XML} \
|
VALIDATE_XML=${VALIDATE_XML} \
|
||||||
|
@ -165,8 +176,10 @@ ENV GITHUB_SHA=${GITHUB_SHA} \
|
||||||
VALIDATE_TERRAFORM=${VALIDATE_TERRAFORM} \
|
VALIDATE_TERRAFORM=${VALIDATE_TERRAFORM} \
|
||||||
VALIDATE_CSS=${VALIDATE_CSS} \
|
VALIDATE_CSS=${VALIDATE_CSS} \
|
||||||
VALIDATE_ENV=${VALIDATE_ENV} \
|
VALIDATE_ENV=${VALIDATE_ENV} \
|
||||||
|
VALIDATE_CLOJURE=${VALIDATE_CLOJURE} \
|
||||||
VALIDATE_KOTLIN=${VALIDATE_KOTLIN} \
|
VALIDATE_KOTLIN=${VALIDATE_KOTLIN} \
|
||||||
VALIDATE_POWERSHELL=${VALIDATE_POWERSHELL} \
|
VALIDATE_POWERSHELL=${VALIDATE_POWERSHELL} \
|
||||||
|
VALIDATE_OPENAPI=${VALIDATE_OPENAPI} \
|
||||||
ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \
|
ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \
|
||||||
RUN_LOCAL=${RUN_LOCAL} \
|
RUN_LOCAL=${RUN_LOCAL} \
|
||||||
TEST_CASE_RUN=${TEST_CASE_RUN} \
|
TEST_CASE_RUN=${TEST_CASE_RUN} \
|
||||||
|
|
30
README.md
30
README.md
|
@ -8,10 +8,26 @@ The end goal of this tool:
|
||||||
- Build guidelines for code layout and format
|
- Build guidelines for code layout and format
|
||||||
- Automate the process to help streamline code reviews
|
- Automate the process to help streamline code reviews
|
||||||
|
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
|
||||||
|
- [How it works](#how-it-works)
|
||||||
|
- [Supported linters](#supported-linters)
|
||||||
|
- [Usage](#how-to-use)
|
||||||
|
- [Environment variables](#environment-variables)
|
||||||
|
- [Disable rules](#disabling-rules)
|
||||||
|
- [Docker Hub](#docker-hub)
|
||||||
|
- [Run Super-Linter locally](#running-super-linter-locally-troubleshootingdebuggingenhancements)
|
||||||
|
- [CI / CT/ CD](#cictcd)
|
||||||
|
- [Limitations](#limitations)
|
||||||
|
- [Contributing](#how-to-contribute)
|
||||||
|
|
||||||
## How it Works
|
## How it Works
|
||||||
|
|
||||||
The super-linter finds issues and reports them to the console output. Fixes are suggested in the console output but not automatically fixed, and a status check will show up as failed on the pull request.
|
The super-linter finds issues and reports them to the console output. Fixes are suggested in the console output but not automatically fixed, and a status check will show up as failed on the pull request.
|
||||||
|
|
||||||
|
The design of the **Super-Linter** is currently to allow linting to occur in **GitHub Actions** as a part of continuous integration occurring on pull requests as the commits get pushed. It works best when commits are being pushed early and often to a branch with an open or draft pull request. There is some desire to move this closer to local development for faster feedback on linting errors but this is not yet supported.
|
||||||
|
|
||||||
## Supported Linters
|
## Supported Linters
|
||||||
|
|
||||||
Developers on **GitHub** can call the **GitHub Action** to lint their code base with the following list of linters:
|
Developers on **GitHub** can call the **GitHub Action** to lint their code base with the following list of linters:
|
||||||
|
@ -20,6 +36,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| **Ansible** | [ansible-lint](https://github.com/ansible/ansible-lint) |
|
| **Ansible** | [ansible-lint](https://github.com/ansible/ansible-lint) |
|
||||||
| **CSS** | [stylelint](https://stylelint.io/) |
|
| **CSS** | [stylelint](https://stylelint.io/) |
|
||||||
|
| **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) |
|
||||||
| **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) |
|
| **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) |
|
||||||
| **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) |
|
| **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) |
|
||||||
| **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) |
|
| **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) |
|
||||||
|
@ -38,6 +55,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base
|
||||||
| **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) |
|
| **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) |
|
||||||
| **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) |
|
| **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) |
|
||||||
| **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) |
|
| **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) |
|
||||||
|
| **OpenAPI** | [spectral](https://github.com/stoplightio/spectral) |
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
To use this **GitHub** Action you will need to complete the following:
|
To use this **GitHub** Action you will need to complete the following:
|
||||||
|
@ -98,14 +116,14 @@ jobs:
|
||||||
# Run Linter against code base #
|
# Run Linter against code base #
|
||||||
################################
|
################################
|
||||||
- name: Lint Code Base
|
- name: Lint Code Base
|
||||||
uses: docker://github/super-linter:v2.1.0
|
uses: docker://github/super-linter:v2.2.0
|
||||||
env:
|
env:
|
||||||
VALIDATE_ALL_CODEBASE: false
|
VALIDATE_ALL_CODEBASE: false
|
||||||
VALIDATE_ANSIBLE: false
|
VALIDATE_ANSIBLE: false
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
**NOTE:** Using the line:`uses: docker://github/super-linter:v2.1.0` will pull the image down from **DockerHub** and run the **GitHub Super-Linter**. Using the line: `uses: github/super-linter@v2.1.0` will build and compile the **GitHub Super-Linter** at build time. This can be far more costly in time...
|
**NOTE:** Using the line:`uses: docker://github/super-linter:v2.2.0` will pull the image down from **DockerHub** and run the **GitHub Super-Linter**. Using the line: `uses: github/super-linter@v2.2.0` will build and compile the **GitHub Super-Linter** at build time. This can be far more costly in time...
|
||||||
|
|
||||||
## Environment variables
|
## Environment variables
|
||||||
The super-linter allows you to pass the following `ENV` variables to be able to trigger different functionality.
|
The super-linter allows you to pass the following `ENV` variables to be able to trigger different functionality.
|
||||||
|
@ -121,6 +139,7 @@ and won't run anything unexpected.
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| **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. |
|
| **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. |
|
| **DEFAULT_BRANCH** | `master` | The name of the repository default branch. |
|
||||||
|
| **LINTER_RULES_PATH** | `.github/linters` | Directory for all linter configuration rules. |
|
||||||
| **VALIDATE_YAML** | `true` |Flag to enable or disable the linting process of the language. |
|
| **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_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. |
|
| **VALIDATE_XML** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
|
@ -130,11 +149,14 @@ and won't run anything unexpected.
|
||||||
| **VALIDATE_PHP** | `true` | Flag to enable or disable the linting process of the language. |
|
| **VALIDATE_PHP** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
| **VALIDATE_PYTHON** | `true` | Flag to enable or disable the linting process of the language. |
|
| **VALIDATE_PYTHON** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
| **VALIDATE_RUBY** | `true` | Flag to enable or disable the linting process of the language. |
|
| **VALIDATE_RUBY** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
|
| **RUBY_CONFIG_FILE** | `.ruby-lint.yml` | Filename for [rubocop configuration](https://docs.rubocop.org/rubocop/configuration.html) (ex: `.ruby-lint.yml`, `.rubocop.yml`)|
|
||||||
| **VALIDATE_COFFEE** | `true` | Flag to enable or disable the linting process of the language . |
|
| **VALIDATE_COFFEE** | `true` | Flag to enable or disable the linting process of the language . |
|
||||||
| **VALIDATE_ANSIBLE** | `true` | Flag to enable or disable the linting process of the language. |
|
| **VALIDATE_ANSIBLE** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
| **VALIDATE_JAVASCRIPT_ES** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: eslint) |
|
| **VALIDATE_JAVASCRIPT_ES** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: eslint) |
|
||||||
|
| **JAVASCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`)|
|
||||||
| **VALIDATE_JAVASCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: standard) |
|
| **VALIDATE_JAVASCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: standard) |
|
||||||
| **VALIDATE_TYPESCRIPT_ES** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: eslint) |
|
| **VALIDATE_TYPESCRIPT_ES** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: eslint) |
|
||||||
|
| **TYPESCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`)|
|
||||||
| **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: standard) |
|
| **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: standard) |
|
||||||
| **VALIDATE_DOCKER** | `true` | Flag to enable or disable the linting process of the language. |
|
| **VALIDATE_DOCKER** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
| **VALIDATE_GO** | `true` | Flag to enable or disable the linting process of the language. |
|
| **VALIDATE_GO** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
|
@ -142,7 +164,9 @@ and won't run anything unexpected.
|
||||||
| **VALIDATE_TERRAFORM** | `true` | Flag to enable or disable the linting process of the language. |
|
| **VALIDATE_TERRAFORM** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
| **VALIDATE_CSS** | `true` | Flag to enable or disable the linting process of the language. |
|
| **VALIDATE_CSS** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
| **VALIDATE_ENV** | `true` | Flag to enable or disable the linting process of the language. |
|
| **VALIDATE_ENV** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
|
| **VALIDATE_CLOJURE** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
| **VALIDATE_KOTLIN** | `true` | Flag to enable or disable the linting process of the language. |
|
| **VALIDATE_KOTLIN** | `true` | Flag to enable or disable the linting process of the language. |
|
||||||
|
| **VALIDATE_OPENAPI** | `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). |
|
| **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. |
|
| **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. |
|
||||||
| **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. |
|
| **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. |
|
||||||
|
@ -164,6 +188,8 @@ The **Docker** container that is built from this repository is located at `https
|
||||||
## Running Super-Linter locally (troubleshooting/debugging/enhancements)
|
## 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)
|
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)
|
||||||
|
|
||||||
|
Check out the [note](#how-it-works) in **How it Works** to understand more about the **Super-Linter** linting locally versus via continuous integration.
|
||||||
|
|
||||||
### CI/CT/CD
|
### CI/CT/CD
|
||||||
The **Super-Linter** has *CI/CT/CD* configured utilizing **GitHub** Actions.
|
The **Super-Linter** has *CI/CT/CD* configured utilizing **GitHub** Actions.
|
||||||
- When a branch is created and code is pushed, a **GitHub** Action is triggered for building the new **Docker** container with the new codebase
|
- When a branch is created and code is pushed, a **GitHub** Action is triggered for building the new **Docker** container with the new codebase
|
||||||
|
|
|
@ -29,9 +29,9 @@ quiet: true
|
||||||
################
|
################
|
||||||
skip_list:
|
skip_list:
|
||||||
- '602' # Allow compare to empty string
|
- '602' # Allow compare to empty string
|
||||||
- '204' # Allow string length greater that 160 chars
|
- '204' # Allow string length greater than 160 chars
|
||||||
- '301' # False positives for running command shells
|
- '301' # False positives for running command shells
|
||||||
- '303' # Allow git commands for push add, etc...
|
- '303' # Allow git commands for push, add, etc...
|
||||||
- '305' # Allow use of shell when you want
|
- '305' # Allow use of shell when you want
|
||||||
- '503' # Allow step to run like handler
|
- '503' # Allow step to run like handler
|
||||||
|
|
||||||
|
|
2
TEMPLATES/.clj-kondo/config.edn
Normal file
2
TEMPLATES/.clj-kondo/config.edn
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
{:linters {:unresolved-symbol {:exclude [(compojure.api.sweet/defroutes)]}
|
||||||
|
:refer-all {:exclude [clj-time.jdbc]}}}
|
9
TEMPLATES/.openapirc.yml
Normal file
9
TEMPLATES/.openapirc.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
##########################
|
||||||
|
##########################
|
||||||
|
## OpenAPI Linter rules ##
|
||||||
|
##########################
|
||||||
|
##########################
|
||||||
|
|
||||||
|
extends: spectral:oas
|
|
@ -1,6 +1,6 @@
|
||||||
# Disabling linters and Rules
|
# Disabling linters and Rules
|
||||||
If you find you need to ignore certain **errors** and **warnings**, you will need to know the *format* to disable the **Super-Linter** rules.
|
If you find you need to ignore certain **errors** and **warnings**, you will need to know the *format* to disable the **Super-Linter** rules.
|
||||||
Below is examples and documentation for each language and the various methods to disable.
|
Below are examples and documentation for each language and the various methods to disable.
|
||||||
|
|
||||||
## Table of Linters
|
## Table of Linters
|
||||||
- [Ruby](#ruby)
|
- [Ruby](#ruby)
|
||||||
|
@ -24,6 +24,7 @@ Below is examples and documentation for each language and the various methods to
|
||||||
- [CSS](#stylelint)
|
- [CSS](#stylelint)
|
||||||
- [ENV](#dotenv-linter)
|
- [ENV](#dotenv-linter)
|
||||||
- [Kotlin](#kotlin)
|
- [Kotlin](#kotlin)
|
||||||
|
- [OpenAPI](#openapi)
|
||||||
|
|
||||||
<!-- toc -->
|
<!-- toc -->
|
||||||
|
|
||||||
|
@ -156,9 +157,9 @@ This line is waaaaaaaaaay too long # yamllint disable-line
|
||||||
### Yamllint disable code block
|
### Yamllint disable code block
|
||||||
```yml
|
```yml
|
||||||
# yamllint disable rule:colons
|
# yamllint disable rule:colons
|
||||||
- Lorem : ipsum
|
- Key : value
|
||||||
dolor : sit amet,
|
dolor : sit,
|
||||||
consectetur : adipiscing elit
|
foo : bar
|
||||||
# yamllint enable
|
# yamllint enable
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -222,9 +223,9 @@ class Foo(object):
|
||||||
def meth3(self):
|
def meth3(self):
|
||||||
"""test one line disabling"""
|
"""test one line disabling"""
|
||||||
# no error
|
# no error
|
||||||
print(self.bla) # pylint: disable=no-member
|
print(self.baz) # pylint: disable=no-member
|
||||||
# error
|
# error
|
||||||
print(self.blop)
|
print(self.baz)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Pylint disable entire file
|
### Pylint disable entire file
|
||||||
|
@ -607,3 +608,44 @@ import package.b.*
|
||||||
|
|
||||||
### ktlint disable entire file
|
### ktlint disable entire file
|
||||||
- There is currently **No** way to disable rules inline of the file(s)
|
- There is currently **No** way to disable rules inline of the file(s)
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## OpenAPI
|
||||||
|
- [spectral](https://github.com/stoplightio/spectral)
|
||||||
|
|
||||||
|
### OpenAPI Config file
|
||||||
|
- `.github/linters/.openapirc.yml`
|
||||||
|
- You can add, extend, and disable rules
|
||||||
|
- Documentation at [Spectral Custom Rulesets](https://stoplight.io/p/docs/gh/stoplightio/spectral/docs/guides/4-custom-rulesets.md)
|
||||||
|
- File should be located at: `.github/linters/.openapirc.yml`
|
||||||
|
|
||||||
|
### OpenAPI disable single line
|
||||||
|
- There is currently **No** way to disable rules inline of the file(s)
|
||||||
|
|
||||||
|
### OpenAPI disable code block
|
||||||
|
- There is currently **No** way to disable rules inline of the file(s)
|
||||||
|
|
||||||
|
### OpenAPI disable entire file
|
||||||
|
- There is currently **No** way to disable rules inline of the file(s)
|
||||||
|
- However, you can make [rule exceptions](https://stoplight.io/p/docs/gh/stoplightio/spectral/docs/guides/6-exceptions.md?srn=gh/stoplightio/spectral/docs/guides/6-exceptions.md) in the config for individual file(s).
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Clojure
|
||||||
|
- [clj-kondo](https://github.com/borkdude/clj-kondo)
|
||||||
|
- Since clj-kondo approaches static analysis in a very Clojure way, it is advised to read the [configuration docs](https://github.com/borkdude/clj-kondo/blob/master/doc/config.md)
|
||||||
|
|
||||||
|
### clj-kondo standard Config file
|
||||||
|
- `.github/linters/.clj-kondo/config.edn`
|
||||||
|
|
||||||
|
### clj-kondo disable single line
|
||||||
|
- There is currently **No** way to disable rules in a single line
|
||||||
|
|
||||||
|
### clj-kondo disable code block
|
||||||
|
- There is currently **No** way to disable rules in a code block
|
||||||
|
|
||||||
|
### clj-kondo disable entire file
|
||||||
|
```clojure
|
||||||
|
{:output {:exclude-files ["path/to/file"]}}
|
||||||
|
```
|
||||||
|
|
238
lib/linter.sh
238
lib/linter.sh
|
@ -1,9 +1,9 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck disable=SC1003,SC2016
|
# shellcheck disable=SC1003,SC2016
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
################################################################################
|
################################################################################
|
||||||
########### Super-Linter (Lint all the code) @AdmiralAwkbar ####################
|
########### Super-Linter (Lint all the code) @admiralawkbar ####################
|
||||||
################################################################################
|
################################################################################
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
###########
|
###########
|
||||||
# Default Vars
|
# Default Vars
|
||||||
DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location
|
DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location
|
||||||
LINTER_PATH='.github/linters' # Default linter path
|
LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory
|
||||||
# YAML Vars
|
# YAML Vars
|
||||||
YAML_FILE_NAME='.yaml-lint.yml' # Name of the file
|
YAML_FILE_NAME='.yaml-lint.yml' # Name of the file
|
||||||
YAML_LINTER_RULES="$DEFAULT_RULES_LOCATION/$YAML_FILE_NAME" # Path to the yaml lint rules
|
YAML_LINTER_RULES="$DEFAULT_RULES_LOCATION/$YAML_FILE_NAME" # Path to the yaml lint rules
|
||||||
|
@ -23,17 +23,17 @@ MD_LINTER_RULES="$DEFAULT_RULES_LOCATION/$MD_FILE_NAME" # Path to th
|
||||||
PYTHON_FILE_NAME='.python-lint' # Name of the file
|
PYTHON_FILE_NAME='.python-lint' # Name of the file
|
||||||
PYTHON_LINTER_RULES="$DEFAULT_RULES_LOCATION/$PYTHON_FILE_NAME" # Path to the python lint rules
|
PYTHON_LINTER_RULES="$DEFAULT_RULES_LOCATION/$PYTHON_FILE_NAME" # Path to the python lint rules
|
||||||
# Ruby Vars
|
# Ruby Vars
|
||||||
RUBY_FILE_NAME='.ruby-lint.yml' # Name of the file
|
RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file
|
||||||
RUBY_LINTER_RULES="$DEFAULT_RULES_LOCATION/$RUBY_FILE_NAME" # Path to the ruby lint rules
|
RUBY_LINTER_RULES="$DEFAULT_RULES_LOCATION/$RUBY_FILE_NAME" # Path to the ruby lint rules
|
||||||
# Coffee Vars
|
# Coffee Vars
|
||||||
COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file
|
COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file
|
||||||
COFFEESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$COFFEE_FILE_NAME" # Path to the coffescript lint rules
|
COFFEESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$COFFEE_FILE_NAME" # Path to the coffeescript lint rules
|
||||||
# Javascript Vars
|
# Javascript Vars
|
||||||
JAVASCRIPT_FILE_NAME='.eslintrc.yml' # Name of the file
|
JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file
|
||||||
JAVASCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$JAVASCRIPT_FILE_NAME" # Path to the Javascript lint rules
|
JAVASCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$JAVASCRIPT_FILE_NAME" # Path to the Javascript lint rules
|
||||||
JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard
|
JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard
|
||||||
# Typescript Vars
|
# Typescript Vars
|
||||||
TYPESCRIPT_FILE_NAME='.eslintrc.yml' # Name of the file
|
TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file
|
||||||
TYPESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TYPESCRIPT_FILE_NAME" # Path to the Typescript lint rules
|
TYPESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TYPESCRIPT_FILE_NAME" # Path to the Typescript lint rules
|
||||||
TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard
|
TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard
|
||||||
# Ansible Vars
|
# Ansible Vars
|
||||||
|
@ -54,6 +54,12 @@ POWERSHELL_LINTER_RULES="$DEFAULT_RULES_LOCATION/$POWERSHELL_FILE_NAME" # Pat
|
||||||
# CSS Vars
|
# CSS Vars
|
||||||
CSS_FILE_NAME='.stylelintrc.json' # Name of the file
|
CSS_FILE_NAME='.stylelintrc.json' # Name of the file
|
||||||
CSS_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CSS_FILE_NAME" # Path to the CSS lint rules
|
CSS_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CSS_FILE_NAME" # Path to the CSS lint rules
|
||||||
|
# OpenAPI Vars
|
||||||
|
OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file
|
||||||
|
OPENAPI_LINTER_RULES="$DEFAULT_RULES_LOCATION/$OPENAPI_FILE_NAME" # Path to the OpenAPI lint rules
|
||||||
|
# Clojure Vars
|
||||||
|
CLOJURE_FILE_NAME='.clj-kondo/config.edn'
|
||||||
|
CLOJURE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CLOJURE_FILE_NAME"
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Linter array for information prints #
|
# Linter array for information prints #
|
||||||
|
@ -61,7 +67,7 @@ CSS_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CSS_FILE_NAME" # Path to th
|
||||||
LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck"
|
LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck"
|
||||||
"pylint" "perl" "rubocop" "coffeelint" "eslint" "standard"
|
"pylint" "perl" "rubocop" "coffeelint" "eslint" "standard"
|
||||||
"ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint"
|
"ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint"
|
||||||
"stylelint" "dotenv-linter" "powershell" "ktlint")
|
"stylelint" "dotenv-linter" "powershell" "ktlint" "clj-kondo" "spectral")
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
# Language array for prints #
|
# Language array for prints #
|
||||||
|
@ -69,7 +75,7 @@ LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck"
|
||||||
LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'PHP' 'RUBY' 'PYTHON'
|
LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'PHP' 'RUBY' 'PYTHON'
|
||||||
'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES'
|
'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES'
|
||||||
'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM'
|
'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM'
|
||||||
'ENV' 'POWERSHELL' 'KOTLIN')
|
'CSS' 'ENV' 'POWERSHELL' 'KOTLIN' 'CLOJURE' 'OPENAPI')
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# GitHub ENV Vars #
|
# GitHub ENV Vars #
|
||||||
|
@ -97,11 +103,13 @@ VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to val
|
||||||
VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language
|
VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language
|
||||||
VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language
|
VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language
|
||||||
VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language
|
VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language
|
||||||
VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language
|
|
||||||
VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language
|
|
||||||
VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language
|
VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language
|
||||||
VALIDATE_ENV="${VALIDATE_ENV}" # Boolean to validate language
|
VALIDATE_ENV="${VALIDATE_ENV}" # Boolean to validate language
|
||||||
|
VALIDATE_CLOJURE="${VALIDATE_CLOJURE}" # Boolean to validate language
|
||||||
|
VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language
|
||||||
|
VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language
|
||||||
VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to validate language
|
VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to validate language
|
||||||
|
VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language
|
||||||
TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases
|
TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases
|
||||||
DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors
|
DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors
|
||||||
|
|
||||||
|
@ -114,16 +122,17 @@ ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG}" # Boolean to see even more info
|
||||||
################
|
################
|
||||||
# Default Vars #
|
# Default Vars #
|
||||||
################
|
################
|
||||||
DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate all files
|
DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate all files
|
||||||
DEFAULT_WORKSPACE="${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_ANSIBLE_DIRECTORY="$GITHUB_WORKSPACE/ansible" # Default Ansible Directory
|
||||||
DEFAULT_RUN_LOCAL='false' # Default value for debugging locally
|
DEFAULT_RUN_LOCAL='false' # Default value for debugging locally
|
||||||
DEFAULT_TEST_CASE_RUN='false' # Flag to tell code to run only test cases
|
DEFAULT_TEST_CASE_RUN='false' # Flag to tell code to run only test cases
|
||||||
DEFAULT_ACTIONS_RUNNER_DEBUG='false' # Default value for debugging output
|
DEFAULT_ACTIONS_RUNNER_DEBUG='false' # Default value for debugging output
|
||||||
RAW_FILE_ARRAY=() # Array of all files that were changed
|
RAW_FILE_ARRAY=() # Array of all files that were changed
|
||||||
READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md
|
READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md
|
||||||
TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore
|
TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore
|
||||||
DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors
|
DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors
|
||||||
|
DEFAULT_IFS="$IFS" # Get the Default IFS for updating
|
||||||
|
|
||||||
##############
|
##############
|
||||||
# Format #
|
# Format #
|
||||||
|
@ -152,10 +161,12 @@ FILE_ARRAY_TYPESCRIPT_STANDARD=() # Array of files to check
|
||||||
FILE_ARRAY_DOCKER=() # Array of files to check
|
FILE_ARRAY_DOCKER=() # Array of files to check
|
||||||
FILE_ARRAY_GO=() # Array of files to check
|
FILE_ARRAY_GO=() # Array of files to check
|
||||||
FILE_ARRAY_TERRAFORM=() # Array of files to check
|
FILE_ARRAY_TERRAFORM=() # Array of files to check
|
||||||
FILE_ARRAY_POWERSHELL=() # Array of files to check
|
FILE_ARRAY_POWERSHELL=() # Array of files to check
|
||||||
FILE_ARRAY_CSS=() # Array of files to check
|
FILE_ARRAY_CSS=() # Array of files to check
|
||||||
FILE_ARRAY_ENV=() # Array of files to check
|
FILE_ARRAY_ENV=() # Array of files to check
|
||||||
|
FILE_ARRAY_CLOJURE=() # Array of files to check
|
||||||
FILE_ARRAY_KOTLIN=() # Array of files to check
|
FILE_ARRAY_KOTLIN=() # Array of files to check
|
||||||
|
FILE_ARRAY_OPENAPI=() # Array of files to check
|
||||||
|
|
||||||
############
|
############
|
||||||
# Counters #
|
# Counters #
|
||||||
|
@ -181,7 +192,9 @@ ERRORS_FOUND_TERRAFORM=0 # Count of errors found
|
||||||
ERRORS_FOUND_POWERSHELL=0 # Count of errors found
|
ERRORS_FOUND_POWERSHELL=0 # Count of errors found
|
||||||
ERRORS_FOUND_CSS=0 # Count of errors found
|
ERRORS_FOUND_CSS=0 # Count of errors found
|
||||||
ERRORS_FOUND_ENV=0 # Count of errors found
|
ERRORS_FOUND_ENV=0 # Count of errors found
|
||||||
|
ERRORS_FOUND_CLOJURE=0 # Count of errors found
|
||||||
ERRORS_FOUND_KOTLIN=0 # Count of errors found
|
ERRORS_FOUND_KOTLIN=0 # Count of errors found
|
||||||
|
ERRORS_FOUND_OPENAPI=0 # Count of errors found
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
########################## FUNCTIONS BELOW #####################################
|
########################## FUNCTIONS BELOW #####################################
|
||||||
|
@ -269,14 +282,14 @@ GetLinterRules()
|
||||||
#####################################
|
#####################################
|
||||||
# Validate we have the linter rules #
|
# Validate we have the linter rules #
|
||||||
#####################################
|
#####################################
|
||||||
if [ -f "$GITHUB_WORKSPACE/$LINTER_PATH/$FILE_NAME" ]; then
|
if [ -f "$GITHUB_WORKSPACE/$LINTER_RULES_PATH/$FILE_NAME" ]; then
|
||||||
echo "----------------------------------------------"
|
echo "----------------------------------------------"
|
||||||
echo "User provided file:[$FILE_NAME], setting rules file..."
|
echo "User provided file:[$FILE_NAME], setting rules file..."
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# Copy users into default location #
|
# Copy users into default location #
|
||||||
####################################
|
####################################
|
||||||
CP_CMD=$(cp "$GITHUB_WORKSPACE/$LINTER_PATH/$FILE_NAME" "$FILE_LOCATION" 2>&1)
|
CP_CMD=$(cp "$GITHUB_WORKSPACE/$LINTER_RULES_PATH/$FILE_NAME" "$FILE_LOCATION" 2>&1)
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Load Error code #
|
# Load Error code #
|
||||||
|
@ -296,7 +309,7 @@ GetLinterRules()
|
||||||
# No user default provided, using the template default #
|
# No user default provided, using the template default #
|
||||||
########################################################
|
########################################################
|
||||||
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then
|
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then
|
||||||
echo " -> Codebase does NOT have file:[$LINTER_PATH/$FILE_NAME], using Default rules at:[$FILE_LOCATION]"
|
echo " -> Codebase does NOT have file:[$LINTER_RULES_PATH/$FILE_NAME], using Default rules at:[$FILE_LOCATION]"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -602,6 +615,42 @@ LintAnsibleFiles()
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#### Function DetectOpenAPIFile ################################################
|
||||||
|
DetectOpenAPIFile()
|
||||||
|
{
|
||||||
|
################
|
||||||
|
# Pull in vars #
|
||||||
|
################
|
||||||
|
FILE="$1"
|
||||||
|
|
||||||
|
###############################
|
||||||
|
# Check the file for keywords #
|
||||||
|
###############################
|
||||||
|
grep -E '"openapi":|"swagger":|^openapi:|^swagger:' "$GITHUB_WORKSPACE/$FILE" > /dev/null
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# Load the error code #
|
||||||
|
#######################
|
||||||
|
ERROR_CODE=$?
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# Check the shell for errors #
|
||||||
|
##############################
|
||||||
|
if [ $ERROR_CODE -eq 0 ]; then
|
||||||
|
########################
|
||||||
|
# Found string in file #
|
||||||
|
########################
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
###################
|
||||||
|
# No string match #
|
||||||
|
###################
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#### Function GetGitHubVars ####################################################
|
#### Function GetGitHubVars ####################################################
|
||||||
GetGitHubVars()
|
GetGitHubVars()
|
||||||
|
@ -801,7 +850,9 @@ GetValidationInfo()
|
||||||
VALIDATE_POWERSHELL=$(echo "$VALIDATE_POWERSHELL" | awk '{print tolower($0)}')
|
VALIDATE_POWERSHELL=$(echo "$VALIDATE_POWERSHELL" | awk '{print tolower($0)}')
|
||||||
VALIDATE_CSS=$(echo "$VALIDATE_CSS" | awk '{print tolower($0)}')
|
VALIDATE_CSS=$(echo "$VALIDATE_CSS" | awk '{print tolower($0)}')
|
||||||
VALIDATE_ENV=$(echo "$VALIDATE_ENV" | awk '{print tolower($0)}')
|
VALIDATE_ENV=$(echo "$VALIDATE_ENV" | awk '{print tolower($0)}')
|
||||||
|
VALIDATE_CLOJURE=$(echo "$VALIDATE_CLOJURE" | awk '{print tolower($0)')
|
||||||
VALIDATE_KOTLIN=$(echo "$VALIDATE_KOTLIN" | awk '{print tolower($0)}')
|
VALIDATE_KOTLIN=$(echo "$VALIDATE_KOTLIN" | awk '{print tolower($0)}')
|
||||||
|
VALIDATE_OPENAPI=$(echo "$VALIDATE_OPENAPI" | awk '{print tolower($0)}')
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
# Determine if any linters were explicitly set #
|
# Determine if any linters were explicitly set #
|
||||||
|
@ -828,6 +879,8 @@ GetValidationInfo()
|
||||||
-n "$VALIDATE_POWERSHELL" || \
|
-n "$VALIDATE_POWERSHELL" || \
|
||||||
-n "$VALIDATE_CSS" || \
|
-n "$VALIDATE_CSS" || \
|
||||||
-n "$VALIDATE_ENV" || \
|
-n "$VALIDATE_ENV" || \
|
||||||
|
-n "$VALIDATE_CLOJURE" || \
|
||||||
|
-n "$VALIDATE_OPENAPI" || \
|
||||||
-n "$VALIDATE_KOTLIN" ]]; then
|
-n "$VALIDATE_KOTLIN" ]]; then
|
||||||
ANY_SET="true"
|
ANY_SET="true"
|
||||||
fi
|
fi
|
||||||
|
@ -1140,6 +1193,33 @@ GetValidationInfo()
|
||||||
VALIDATE_KOTLIN="true"
|
VALIDATE_KOTLIN="true"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# Validate if we should check OPENAPI #
|
||||||
|
#######################################
|
||||||
|
if [[ "$ANY_SET" == "true" ]]; then
|
||||||
|
# Some linter flags were set - only run those set to true
|
||||||
|
if [[ -z "$VALIDATE_OPENAPI" ]]; then
|
||||||
|
# OPENAPI flag was not set - default to false
|
||||||
|
VALIDATE_OPENAPI="false"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# No linter flags were set - default all to true
|
||||||
|
VALIDATE_OPENAPI="true"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# Validate if we should check Clojure #
|
||||||
|
#######################################
|
||||||
|
if [[ "$ANY_SET" == "true" ]]; then
|
||||||
|
# Some linter flags were set - only run those set to true
|
||||||
|
if [[ -z "$VALIDATE_CLOJURE" ]]; then
|
||||||
|
# Clojure flag was not set - default to false
|
||||||
|
VALIDATE_CLOJURE="false"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# No linter flags were set - default all to true
|
||||||
|
VALIDATE_CLOJURE="true"
|
||||||
|
fi
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Print which linters we are enabling #
|
# Print which linters we are enabling #
|
||||||
|
@ -1244,6 +1324,11 @@ GetValidationInfo()
|
||||||
else
|
else
|
||||||
PRINT_ARRAY+=("- Excluding [CSS] files in code base...")
|
PRINT_ARRAY+=("- Excluding [CSS] files in code base...")
|
||||||
fi
|
fi
|
||||||
|
if [[ "$VALIDATE_CLOJURE" == "true" ]]; then
|
||||||
|
PRINT_ARRAY+=("- Validating [CLOJURE] files in code base...")
|
||||||
|
else
|
||||||
|
PRINT_ARRAY+=("- Excluding [CLOJURE] files in code base...")
|
||||||
|
fi
|
||||||
if [[ "$VALIDATE_ENV" == "true" ]]; then
|
if [[ "$VALIDATE_ENV" == "true" ]]; then
|
||||||
PRINT_ARRAY+=("- Validating [ENV] files in code base...")
|
PRINT_ARRAY+=("- Validating [ENV] files in code base...")
|
||||||
else
|
else
|
||||||
|
@ -1254,6 +1339,11 @@ GetValidationInfo()
|
||||||
else
|
else
|
||||||
PRINT_ARRAY+=("- Excluding [KOTLIN] files in code base...")
|
PRINT_ARRAY+=("- Excluding [KOTLIN] files in code base...")
|
||||||
fi
|
fi
|
||||||
|
if [[ "$VALIDATE_OPENAPI" == "true" ]]; then
|
||||||
|
PRINT_ARRAY+=("- Validating [OPENAPI] files in code base...")
|
||||||
|
else
|
||||||
|
PRINT_ARRAY+=("- Excluding [OPENAPI] files in code base...")
|
||||||
|
fi
|
||||||
|
|
||||||
##############################
|
##############################
|
||||||
# Validate Ansible Directory #
|
# Validate Ansible Directory #
|
||||||
|
@ -1437,6 +1527,12 @@ BuildFileList()
|
||||||
# Append the file to the array #
|
# Append the file to the array #
|
||||||
################################
|
################################
|
||||||
FILE_ARRAY_YML+=("$FILE")
|
FILE_ARRAY_YML+=("$FILE")
|
||||||
|
############################
|
||||||
|
# Check if file is OpenAPI #
|
||||||
|
############################
|
||||||
|
if DetectOpenAPIFile "$FILE"; then
|
||||||
|
FILE_ARRAY_OPENAPI+=("$FILE")
|
||||||
|
fi
|
||||||
##########################################################
|
##########################################################
|
||||||
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||||
##########################################################
|
##########################################################
|
||||||
|
@ -1449,6 +1545,12 @@ BuildFileList()
|
||||||
# Append the file to the array #
|
# Append the file to the array #
|
||||||
################################
|
################################
|
||||||
FILE_ARRAY_JSON+=("$FILE")
|
FILE_ARRAY_JSON+=("$FILE")
|
||||||
|
############################
|
||||||
|
# Check if file is OpenAPI #
|
||||||
|
############################
|
||||||
|
if DetectOpenAPIFile "$FILE"; then
|
||||||
|
FILE_ARRAY_OPENAPI+=("$FILE")
|
||||||
|
fi
|
||||||
##########################################################
|
##########################################################
|
||||||
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||||
##########################################################
|
##########################################################
|
||||||
|
@ -1639,6 +1741,15 @@ BuildFileList()
|
||||||
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||||
##########################################################
|
##########################################################
|
||||||
READ_ONLY_CHANGE_FLAG=1
|
READ_ONLY_CHANGE_FLAG=1
|
||||||
|
elif [ "$FILE" == "clj" ] || [ "$FILE" == "cljs" ] || [ "$FILE" == "cljc" ] || [ "$FILE" == "edn" ]; then
|
||||||
|
################################
|
||||||
|
# Append the file to the array #
|
||||||
|
################################
|
||||||
|
FILE_ARRAY_CLOJURE+=("$FILE")
|
||||||
|
##########################################################
|
||||||
|
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||||
|
##########################################################
|
||||||
|
READ_ONLY_CHANGE_FLAG=1
|
||||||
else
|
else
|
||||||
##############################################
|
##############################################
|
||||||
# Use file to see if we can parse what it is #
|
# Use file to see if we can parse what it is #
|
||||||
|
@ -1792,12 +1903,22 @@ LintCodebase()
|
||||||
# We have files added to array of files to check
|
# We have files added to array of files to check
|
||||||
LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list
|
LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list
|
||||||
else
|
else
|
||||||
|
###############################################################################
|
||||||
|
# Set the file seperator to newline to allow for grabbing objects with spaces #
|
||||||
|
###############################################################################
|
||||||
|
IFS=$'\n'
|
||||||
|
|
||||||
#################################
|
#################################
|
||||||
# Get list of all files to lint #
|
# Get list of all files to lint #
|
||||||
#################################
|
#################################
|
||||||
# shellcheck disable=SC2207,SC2086
|
# shellcheck disable=SC2207,SC2086
|
||||||
LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -regex "$FILE_EXTENSIONS" 2>&1))
|
LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -regex "$FILE_EXTENSIONS" 2>&1))
|
||||||
|
|
||||||
|
###########################
|
||||||
|
# Set IFS back to default #
|
||||||
|
###########################
|
||||||
|
IFS="$DEFAULT_IFS"
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Set it back to empty if loaded with blanks from scanning #
|
# Set it back to empty if loaded with blanks from scanning #
|
||||||
############################################################
|
############################################################
|
||||||
|
@ -1883,7 +2004,7 @@ LintCodebase()
|
||||||
# Lint the file with the rules #
|
# Lint the file with the rules #
|
||||||
################################
|
################################
|
||||||
# Need to append "'" to make the pwsh call syntax correct, also exit with exit code from inner subshell
|
# 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)
|
LINT_CMD=$(cd "$GITHUB_WORKSPACE" || exit; $LINTER_COMMAND "$FILE"; exit $? 2>&1)
|
||||||
else
|
else
|
||||||
################################
|
################################
|
||||||
# Lint the file with the rules #
|
# Lint the file with the rules #
|
||||||
|
@ -2003,11 +2124,21 @@ TestCodebase()
|
||||||
# shellcheck disable=SC2207,SC2086,SC2010
|
# shellcheck disable=SC2207,SC2086,SC2010
|
||||||
LIST_FILES=($(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; ls ansible/ | grep ".yml" 2>&1))
|
LIST_FILES=($(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; ls ansible/ | grep ".yml" 2>&1))
|
||||||
else
|
else
|
||||||
|
###############################################################################
|
||||||
|
# Set the file seperator to newline to allow for grabbing objects with spaces #
|
||||||
|
###############################################################################
|
||||||
|
IFS=$'\n'
|
||||||
|
|
||||||
#################################
|
#################################
|
||||||
# Get list of all files to lint #
|
# Get list of all files to lint #
|
||||||
#################################
|
#################################
|
||||||
# shellcheck disable=SC2207,SC2086
|
# shellcheck disable=SC2207,SC2086
|
||||||
LIST_FILES=($(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; find . -type f -regex "$FILE_EXTENSIONS" ! -path "*./ansible*" 2>&1))
|
LIST_FILES=($(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; find . -type f -regex "$FILE_EXTENSIONS" ! -path "*./ansible*" 2>&1))
|
||||||
|
|
||||||
|
###########################
|
||||||
|
# Set IFS back to default #
|
||||||
|
###########################
|
||||||
|
IFS="$DEFAULT_IFS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##################
|
##################
|
||||||
|
@ -2215,6 +2346,8 @@ Footer()
|
||||||
[ "$ERRORS_FOUND_RUBY" -ne 0 ] || \
|
[ "$ERRORS_FOUND_RUBY" -ne 0 ] || \
|
||||||
[ "$ERRORS_FOUND_CSS" -ne 0 ] || \
|
[ "$ERRORS_FOUND_CSS" -ne 0 ] || \
|
||||||
[ "$ERRORS_FOUND_ENV" -ne 0 ] || \
|
[ "$ERRORS_FOUND_ENV" -ne 0 ] || \
|
||||||
|
[ "$ERRORS_FOUND_OPENAPI" -ne 0 ] || \
|
||||||
|
[ "$ERRORS_FOUND_CLOJURE" -ne 0 ] || \
|
||||||
[ "$ERRORS_FOUND_KOTLIN" -ne 0 ]; then
|
[ "$ERRORS_FOUND_KOTLIN" -ne 0 ]; then
|
||||||
# Failed exit
|
# Failed exit
|
||||||
echo "Exiting with errors found!"
|
echo "Exiting with errors found!"
|
||||||
|
@ -2270,13 +2403,15 @@ RunTestCases()
|
||||||
TestCodebase "JAVASCRIPT_STANDARD" "standard" "standard $JAVASCRIPT_STANDARD_LINTER_RULES" ".*\.\(js\)\$"
|
TestCodebase "JAVASCRIPT_STANDARD" "standard" "standard $JAVASCRIPT_STANDARD_LINTER_RULES" ".*\.\(js\)\$"
|
||||||
TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(ts\)\$"
|
TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(ts\)\$"
|
||||||
TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin $TYPESCRIPT_STANDARD_LINTER_RULES" ".*\.\(ts\)\$"
|
TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin $TYPESCRIPT_STANDARD_LINTER_RULES" ".*\.\(ts\)\$"
|
||||||
TestCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(Dockerfile\)\$"
|
TestCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint -c $DOCKER_LINTER_RULES" ".*\(Dockerfile\)\$"
|
||||||
TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c $ANSIBLE_LINTER_RULES" "ansible-lint"
|
TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c $ANSIBLE_LINTER_RULES" "ansible-lint"
|
||||||
TestCodebase "TERRAFORM" "tflint" "tflint -c $TERRAFORM_LINTER_RULES" ".*\.\(tf\)\$"
|
TestCodebase "TERRAFORM" "tflint" "tflint -c $TERRAFORM_LINTER_RULES" ".*\.\(tf\)\$"
|
||||||
TestCodebase "POWERSHELL" "pwsh" "pwsh -c Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$"
|
TestCodebase "POWERSHELL" "pwsh" "pwsh -c Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$"
|
||||||
TestCodebase "CSS" "stylelint" "stylelint --config $CSS_LINTER_RULES" ".*\.\(css\)\$"
|
TestCodebase "CSS" "stylelint" "stylelint --config $CSS_LINTER_RULES" ".*\.\(css\)\$"
|
||||||
TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$"
|
TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$"
|
||||||
|
TestCodebase "CLOJURE" "clj-kondo" "clj-kondo --config $CLOJURE_LINTER_RULES --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$"
|
||||||
TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$"
|
TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$"
|
||||||
|
TestCodebase "OPENAPI" "spectral" "spectral lint -r $OPENAPI_LINTER_RULES" ".*\.\(ymlopenapi\|jsonopenapi\)\$"
|
||||||
|
|
||||||
#################
|
#################
|
||||||
# Footer prints #
|
# Footer prints #
|
||||||
|
@ -2626,7 +2761,21 @@ if [ "$VALIDATE_DOCKER" == "true" ]; then
|
||||||
# Lint the docker files #
|
# Lint the docker files #
|
||||||
#########################
|
#########################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
LintCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}"
|
LintCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint -c $DOCKER_LINTER_RULES" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
###################
|
||||||
|
# CLOJURE LINTING #
|
||||||
|
###################
|
||||||
|
if [ "$VALIDATE_CLOJURE" == "true" ]; then
|
||||||
|
#################################
|
||||||
|
# Get Clojure standard rules #
|
||||||
|
#################################
|
||||||
|
GetStandardRules "clj-kondo"
|
||||||
|
#########################
|
||||||
|
# Lint the Clojure files #
|
||||||
|
#########################
|
||||||
|
LintCodebase "CLOJURE" "clj-kondo" "clj-kondo --config $CLOJURE_LINTER_RULES --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "${FILE_ARRAY_CLOJURE[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
######################
|
######################
|
||||||
|
@ -2640,6 +2789,39 @@ if [ "$VALIDATE_POWERSHELL" == "true" ]; then
|
||||||
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" "pwsh -c Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILE_ARRAY_POWERSHELL[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
###################
|
||||||
|
# OPENAPI LINTING #
|
||||||
|
###################
|
||||||
|
if [ "$VALIDATE_OPENAPI" == "true" ]; then
|
||||||
|
# If we are validating all codebase we need to build file list because not every yml/json file is an OpenAPI file
|
||||||
|
if [ "$VALIDATE_ALL_CODEBASE" == "true" ]; then
|
||||||
|
###############################################################################
|
||||||
|
# Set the file seperator to newline to allow for grabbing objects with spaces #
|
||||||
|
###############################################################################
|
||||||
|
IFS=$'\n'
|
||||||
|
|
||||||
|
# shellcheck disable=SC2207
|
||||||
|
LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1))
|
||||||
|
for FILE in "${LIST_FILES[@]}"
|
||||||
|
do
|
||||||
|
if DetectOpenAPIFile "$FILE"; then
|
||||||
|
FILE_ARRAY_OPENAPI+=("$FILE")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
###########################
|
||||||
|
# Set IFS back to default #
|
||||||
|
###########################
|
||||||
|
IFS="$DEFAULT_IFS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
##########################
|
||||||
|
# Lint the OpenAPI files #
|
||||||
|
##########################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "OPENAPI" "spectral" "spectral lint -r $OPENAPI_LINTER_RULES" "disabledfileext" "${FILE_ARRAY_OPENAPI[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
##########
|
##########
|
||||||
# Footer #
|
# Footer #
|
||||||
##########
|
##########
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue