Skip to content

Commit

Permalink
Merge pull request #17 from jobtome-labs/feature/review-dog
Browse files Browse the repository at this point in the history
Feature/review dog
  • Loading branch information
gadiener authored Apr 13, 2020
2 parents 1072124 + 3a98515 commit e9faa10
Show file tree
Hide file tree
Showing 21 changed files with 101 additions and 54 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,17 @@ stages:
- lint
variables:
#optional, used by docker-lint
# optional, used by docker-lint
IGNORE_DOCKER_LINT: "DL3012"
# optional, used to enable reviewdog
ENABLE_REVIEWDOG: 1
REVIEWDOG_GITLAB_API_TOKEN: <personal gitlab token used to call v4 api endpoints>
REVIEWDOG_LEVEL: warning # optional, values: info, warning, error
```

The [Review Dog](https://github.com/reviewdog/reviewdog) feature provides a way to post review comments automatically by integrating with any linter tools with ease. It uses an output of lint tools and posts them as a comment if findings are in diff of patches to review.

The default skipped test for `lint-docker` is `Provide an email address or URL as maintainer`. See skippable tests [here](https://hub.docker.com/r/hadolint/hadolint).

If one wants to check the kube manifests (through lint and security practices), then the import becomes `test-kubernetes-score.yaml`, and it will perform the following:
Expand Down Expand Up @@ -758,7 +765,7 @@ stages:

```yaml
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/<REF>/terraform-security.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/<REF>/test-terraform-security.yml'
stages:
- test
Expand Down
2 changes: 1 addition & 1 deletion bucket-production.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/bucket-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/bucket-quality.yml'

deploy:production:
extends: .deploy
Expand Down
2 changes: 1 addition & 1 deletion bucket-quality.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/templates/bucket.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/templates/bucket.yml'

deploy:quality:
extends: .deploy
Expand Down
2 changes: 1 addition & 1 deletion cloudrun-production.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/cloudrun-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/cloudrun-quality.yml'

deploy:production:
extends: deploy:quality
Expand Down
4 changes: 2 additions & 2 deletions cloudrun-quality.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/templates/cloudrun.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/templates/cloudrun.yml'

deploy:quality:
extends: .cloudrun:deploy
Expand Down
2 changes: 1 addition & 1 deletion docker.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/templates/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/templates/docker.yml'

build:
stage: build
Expand Down
2 changes: 1 addition & 1 deletion helm-multiregion.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/helm-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/helm-quality.yml'

# EUROPE
deploy:production:europe:helm:
Expand Down
4 changes: 2 additions & 2 deletions helm-quality.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/templates/helm.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/templates/helm.yml'

deploy:quality:helm:
variables:
Expand Down
2 changes: 1 addition & 1 deletion helm-regional.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/helm-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/helm-quality.yml'

deploy:production:helm:
extends: .deploy:production:helm
Expand Down
3 changes: 1 addition & 2 deletions kubernetes-multiregion.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/kubernetes-quality.yml'

- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/kubernetes-quality.yml'

# EUROPE
deploy:production:europe:image:
Expand Down
4 changes: 2 additions & 2 deletions kubernetes-quality.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/templates/kubernetes.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/templates/kubernetes.yml'

deploy:quality:image:
variables:
Expand Down
2 changes: 1 addition & 1 deletion kubernetes-regional.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/kubernetes-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/kubernetes-quality.yml'

deploy:production:image:
extends: .deploy:production:image
Expand Down
35 changes: 30 additions & 5 deletions lint-go.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
lint:go:
stage: lint
image: cytopia/golint:latest-release-0.1
image: gadiener/golint-reviewdog:v1.0.0
variables:
GITLAB_API: ${CI_API_V4_URL}
script:
- |
echo
echo "-> Linting code:"
echo "-> Linting Go files:"
echo
golint .
if [ -z "${LINT_PATH}" ]; then
LINT_PATH="./..."
fi
if [ "${ENABLE_REVIEWDOG}" = "1" ]; then
echo
echo "-> Enabled Review Dog!"
echo
if [ -z "${REVIEWDOG_GITLAB_API_TOKEN}" ]; then
echo
echo "-> [WARNING] Missing 'REVIEWDOG_GITLAB_API_TOKEN' variable!"
echo
exit 1
fi
if [ -z "${REVIEWDOG_LEVEL}" ]; then
REVIEWDOG_LEVEL="warning"
fi
golint "${LINT_PATH}" | reviewdog -name="Go Linter" \
-f=golint -diff="git diff master" -reporter=gitlab-mr-discussion -level="${REVIEWDOG_LEVEL}"
else
golint "${LINT_PATH}"
fi
echo
echo "-> Code checked!"
echo "-> Go files checked!"
echo
35 changes: 28 additions & 7 deletions lint-yaml.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
lint:yaml:
stage: lint
image: cytopia/yamllint:1.18
image: gdiener/yamllint-reviewdog:v1.0.0
variables:
GITLAB_API: ${CI_API_V4_URL}
script:
- |
if [[ -z "${YAML_DIR}" ]]; then
YAML_DIR="kube/"
if [[ -z "${LINT_PATH}" ]]; then
LINT_PATH="."
fi
echo
echo "-> Linting manifests:"
echo "-> Linting YAML files:"
echo
yamllint ${YAML_DIR}
if [ "${ENABLE_REVIEWDOG}" = "1" ]; then
echo
echo "-> Enabled Review Dog!"
echo
if [ -z "${REVIEWDOG_GITLAB_API_TOKEN}" ]; then
echo
echo "-> [WARNING] Missing 'REVIEWDOG_GITLAB_API_TOKEN' variable!"
echo
exit 1
fi
if [ -z "${REVIEWDOG_LEVEL}" ]; then
REVIEWDOG_LEVEL="warning"
fi
yamllint --format "parsable" "${LINT_PATH}" | reviewdog -name="YAML Linter" \
-efm="%f:%l:%c: %m" -diff="git diff master" -reporter=gitlab-mr-discussion -level="${INPUT_LEVEL}"
else
yamllint "${LINT_PATH}"
fi
echo
echo "-> Manifests checked!"
echo "-> YAML files checked!"
echo
2 changes: 1 addition & 1 deletion serverless-multiregion.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/serverless-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/templates/serverless.yml'

# EUROPE
deploy:production:europe:
Expand Down
4 changes: 2 additions & 2 deletions serverless-regional.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/serverless-quality.yml'

- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/templates/serverless.yml'
deploy:production:
extends: .serverless:deploy
variables:
Expand Down
2 changes: 1 addition & 1 deletion ssh-production.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/ssh-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/ssh-quality.yml'

ssh:production:
extends: .ssh:exec
Expand Down
2 changes: 1 addition & 1 deletion ssh-quality.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/templates/ssh.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/templates/ssh.yml'

ssh:quality:
extends: .ssh:exec
Expand Down
19 changes: 0 additions & 19 deletions terraform-security.yml

This file was deleted.

14 changes: 14 additions & 0 deletions test-terraform-security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

test:terraform-security:
stage: test
image: linuxbandit/terraform-with-tfsec:v0.12.9
script:
- |
if [ -n "${TF_FOLDER_PATH}" ]; then
cd "${TF_FOLDER_PATH}"
fi
terraform --version
terraform init -backend=false
tfsec .
variables:
GIT_DEPTH: 1
2 changes: 1 addition & 1 deletion test-unit.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.4.0/templates/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.5.0/templates/docker.yml'

test:unit:
extends: .docker
Expand Down

0 comments on commit e9faa10

Please sign in to comment.