You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
4 years ago | |
---|---|---|
conf | 4 years ago | |
scripts | 4 years ago | |
.dockerignore | 4 years ago | |
.hadolint.yaml | 4 years ago | |
.woodpecker.yml | 4 years ago | |
Dockerfile | 4 years ago | |
LICENSE | 4 years ago | |
README.md | 4 years ago | |
linter.template | 4 years ago | |
php.ini | 4 years ago | |
sudoers | 5 years ago |
README.md
Linter
Drone/Woodpecker CI "plugin"
pipeline:
lint:
image: sevoid/linter:plugin
lint: shell
before_script: |
touch /tmp/foo
if [[ -f /tmp/foo ]]; then
echo "foo"
fi
ignore:
- SC1234
- SC5678
path:
- ./build/scripts
files:
- ./foo/script1.sh
- ./foo/script2.sh
- ./bar/run-*
- check.sh
Table of contents
Linters & basic usage
Name | Plug-in | Description | Link |
---|---|---|---|
shellcheck | shell |
A shell script static analysis tool | GitHub |
yamllint | yaml |
A linter for YAML files | GitHub |
hadolint | docker |
A smarter Dockerfile linter that helps you build best practice Docker images | GitHub |
phpcs | php |
PHP_CodeSniffer: phpcs script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard |
GitHub |
php-cs-fixer | php |
The PHP Coding Standards Fixer (PHP CS Fixer) tool fixes your code to follow standards; whether you want to follow PHP coding standards as defined in the PSR-1, PSR-2, etc., or other community driven ones like the Symfony one. You can also define your (team's) style through configuration. | GitHub |
Enabling linter
Shell (click to expand)
pipeline:
lint:
image: sevoid/linter:plugin
+ lint: shell
YAML (click to expand)
pipeline:
lint:
image: sevoid/linter:plugin
+ lint: yaml
Docker (click to expand)
pipeline:
lint:
image: sevoid/linter:plugin
+ lint: docker
PHP (click to expand)
pipeline:
lint:
image: sevoid/linter:plugin
+ lint: php
Examples
Common pipeline options
Option | Accepted values | Mandatory | Description |
---|---|---|---|
debug | Any kind of value | NO | If set, enables debug mode (set -o xtrace ) for wrapper and subscripts |
errexit | Any kind of value | NO | If set, enables exit-on-error mode (set -o errexit ) for wrapper and subcripts |
path | YAML list of strings | NO | Specifies custom search path. If not set linter will attempt to search for *.sh scripts starting from current directory** |
files | YAML list of strings | NO | Specifies custom scripts to be checked |
before_script | YAML-formatted inline strings or lists | NO | If you need to run something before step execution, this is a right place to add those things |
ignore | YAML list of strings | NO | List of linter codes to ignore |
Files (click to expand)
pipeline:
lint:
image: sevoid/linter:plugin
lint: shell
+ files:
+ - ./foo/script1.sh
+ - ./foo/script2.sh
+ - ./bar/run-*
+ - check.sh
Path (click to expand)
pipeline:
lint:
image: sevoid/linter:plugin
lint: shell
+ path:
+ - ./foo
+ - ./build/scripts
Path & files (click to expand)
pipeline:
lint:
image: sevoid/linter:plugin
lint: shell
+ path:
+ - ./build/scripts
+ files:
+ - ./foo/script1.sh
+ - ./foo/script2.sh
+ - ./bar/run-*
+ - check.sh
Pre-run inline script (click to expand)
pipeline:
lint:
image: sevoid/linter:plugin
lint: shell
+ before_script: |
+ touch /tmp/foo
+ if [[ -f /tmp/foo ]]; then
+ echo "foo"
+ fi
Pre-run line-by-line script (click to expand)
pipeline:
lint:
image: sevoid/linter:plugin
lint: shell
+ before_script:
+ - touch /tmp/bar
+ - "[[ -f /tmp/bar ]] && echo bar"
Ignore (click to expand)
pipeline:
lint:
image: sevoid/linter:plugin
lint: shell
+ ignore:
+ - SC1234
+ - SC5678
Enable debug and/or errexit (click to expand)
debug
pipeline:
lint-shell:
image: sevoid/linter:plugin
lint: shell
+ debug: true
errexit
pipeline:
lint-shell:
image: sevoid/linter:plugin
lint: shell
+ errexit: true
Enable debug and errexit
pipeline:
lint-shell:
image: sevoid/linter:plugin
lint: shell
+ debug: true
+ errexit: true
Shell linter
Configuration file
Default behaviour of shellcheck
can be overriden by placing .shellcheckrc
into root directory of your git repo.
Example of .shellcheckrc (click to expand)
color=always
severity=error
disable=SC1234
disable=SC5678
Pipeline options
Option | Accepted values | Default value | Mandatory | Description |
---|---|---|---|---|
lint |
|
YES | Specifies linter to be used | |
color |
|
always |
NO | Linter option Enables/disables colourful output |
severity |
|
style |
NO | Linter option Specifies minimum severity of errors to consider |
YAML linter
Configuration file
Default behaviour of yamllint
can be overriden by placing config file into root directory of your git repo.
Configuration file names:
.yamllint
.yamllint.yml
.yamllint.yaml
Example of .yamllint (click to expand)
yaml-files:
- '*.yaml'
- '*.yml'
- '.yamllint'
locale: en_US.UTF-8
extends: default
rules:
# 80 chars should be enough, but don't fail if a line is longer
line-length:
max: 80
level: warning
Pipeline options
Option | Accepted values | Default value | Mandatory | Description |
---|---|---|---|---|
lint |
|
YES | Specifies linter to be used |
Dockerfile linter
Configuration file
Default behaviour of hadolint
can be overriden by placing .hadolint.yaml
file into root directory of your git repo.
Example of .hadolint.yaml (click to expand)
override:
error:
- DL3001
- DL3002
warning:
- DL3042
- DL3033
info:
- DL3032
style:
- DL3015
Pipeline options
Option | Accepted values | Default value | Mandatory | Description |
---|---|---|---|---|
lint |
|
YES | Specifies linter to be used |
PHP linter
Configuration file
Default behaviour of php-cs-fixer
can be overriden by placing .php-cs-fixer.php
file into root directory of your git repo.
Example of .php-cs-fixer.php (click to expand)
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
;
$config = new PhpCsFixer\Config();
return $config->setRules([
'@Symfony' => true,
'full_opening_tag' => false,
])
->setFinder($finder)
;
Pipeline options
Option | Accepted values | Default value | Mandatory | Description |
---|---|---|---|---|
lint | php |
YES | Specifies linter to be used | |
type |
|
phpcs |
NO |
Example of phpcs (click to expand)
Plugin will use phpcs by default if type
isn't specified.
pipeline:
lint-php:
image: sevoid/linter:plugin
lint: php
pipeline:
lint-php:
image: sevoid/linter:plugin
lint: php
+ type: phpcs
Example of php-cs-fixer (click to expand)
pipeline:
lint-php:
image: sevoid/linter:plugin
lint: php
+ type: cs-fix
pipeline:
lint-php:
image: sevoid/linter:plugin
lint: php
+ type: cs-fixer
pipeline:
lint-php:
image: sevoid/linter:plugin
lint: php
+ type: php-cs-fixer