Commit f7c3ed3d authored by Fabrice Gangler's avatar Fabrice Gangler 🎨
Browse files

CI: init gitlab CI

parent d1ca1dd1
---
stages:
- linter
- documentation
include:
- local: /.gitlab/ci/job.documentation.gitlab-ci.yml
- local: /.gitlab/ci/job.linters.gitlab-ci.yml
---
default: true
# MD007 - Unordered list indentation
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md007---unordered-list-indentation
MD007:
indent: 2
# MD012 - Multiple consecutive blank lines (expected: 1)
# see: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md012---multiple-consecutive-blank-lines
MD012:
maximum: 3
# MD013 - Line length (expected: 80)
# see: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md013---line-length
MD013:
stern: false
strict: false
tables: false
code_blocks: false
line_length: 120
# heading_line_length: 120
# code_block_line_length: 120
# MD024 - Multiple headings with the same content
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md024---multiple-headings-with-the-same-content
MD024:
siblings_only: true
---
###################################################
# Config for yamllint
# https://yamllint.readthedocs.io
# https://github.com/adrienverge/yamllint
###################################################
extends: default
rules:
comments-indentation: disable
line-length:
max: 120
level: warning
empty-lines:
max: 2
level: warning
---
#### DOCUMENTATION ###############################################################################################
# markdownlint ---> Markdown files linter
# remark-validate-links ---> check that Markdown links and images reference existing local files and headings.
# remark-lint-no-dead-urls ---> check that external URLs in Markdown files are alive.
##################################################################################################################
###############################################################
# markdownlint https://github.com/DavidAnson/markdownlint
# https://github.com/igorshubovych/markdownlint-cli
# https://gitlab.com/06kellyjac/docker_markdownlint-cli
# --> a CI job that will lint all markdown files
###############################################################
markdown_linter:
stage: documentation
# when: manual
needs: []
image:
name: registry.gitlab.com/06kellyjac/docker_markdownlint-cli:0.27.1
entrypoint:
- "/usr/bin/env"
- "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
before_script:
- markdownlint --version
- cat .gitlab/ci/config/markdownlint.yml
- cat .gitlab/ci/config/markdownlintignore.txt
script:
- markdownlint '**/*.md' --config .gitlab/ci/config/markdownlint.yml -p .gitlab/ci/config/markdownlintignore.txt
- markdownlint --version
###############################################################
# remark-validate-links https://github.com/remarkjs/remark-validate-links
# remark-lint-no-dead-urls https://github.com/davidtheclark/remark-lint-no-dead-urls
# --> a CI job that will:
# - check that Markdown links and images reference existing local files and headings.
# - check that external URLs in Markdown files are alive.
###############################################################
doc_check-links:
stage: documentation
when: manual
needs: []
image: node:14.15.0
# @TODO find a dedicated image or build it
cache:
paths:
- node_modules/
script:
- npm -v
- node -v
- npm install remark-cli remark-validate-links remark-lint-no-dead-urls remark-preset-lint-recommended
- node node_modules/remark-cli/cli.js -u lint-no-dead-urls . 2> links-external.txt
- cat links-external.txt
- node node_modules/remark-cli/cli.js -u validate-links . 2> links-relative.txt
- cat links-relative.txt
- cat links-relative.txt | grep warning && exit 404 || echo "no error"
- cat links-external.txt | grep warning && exit 404 || echo "no error"
---
#### LINTER ######################################################################################################
# Vagrant ---> Validate Vagrantfile
# SShellCheck ---> shell scripts linter
# Yamllint ---> Yaml files linter
# JsonLint ---> JSON files linter
##################################################################################################################
###############################################################
# Vagrant https://www.vagrantup.com/docs/cli/validate
# --> a CI job that will validate Vagrantfile
###############################################################
Vagrantfile_linter:
stage: linter
# when: manual
needs: []
image: debian:buster-slim
variables:
vagrant_version: "2.2.19"
before_script:
- apt-get update
- apt-get -y --no-install-recommends install wget ca-certificates
- wget --quiet "https://releases.hashicorp.com/vagrant/${vagrant_version}/vagrant_${vagrant_version}_x86_64.deb"
- dpkg -i "vagrant_${vagrant_version}_x86_64.deb"
- vagrant --version
script:
- mkdir -p ../demarches-simplifiees.fr
- mkdir -p ./modules/
- vagrant validate --ignore-provider
# - VAGRANT_LOG=info vagrant validate --ignore-provider
###############################################################
# Yamllint https://yamllint.readthedocs.io
# https://github.com/adrienverge/yamllint
# https://github.com/sdesbure/docker_yamllint
# https://manpages.debian.org/buster/yamllint/yamllint.1.en.html
# --> a CI job that will lint all YAML files (docker-compose.yml, .gitlab/ci/*.yml)
###############################################################
yaml_linter:
stage: linter
# when: manual
needs: []
image: sdesbure/yamllint:latest
script:
- find . -name '*.yaml' -type f
- find . -name '*.yml' -type f
- find . -name '*.yaml' -type f | xargs -I % yamllint -c .gitlab/ci/config/yamllint.yaml %
- find . -name '*.yml' -type f | xargs -I % yamllint -c .gitlab/ci/config/yamllint.yaml %
# - yamllint -d relaxed .
###############################################################
# ShellCheck https://github.com/koalaman/shellcheck/wiki/GitLab-CI
# https://git-scm.com/docs/git-ls-files
# --> a CI job that will lint all shell scripts (fail when no .sh files)
###############################################################
shellcheck_linter:
stage: linter
# when: manual
needs: []
image: koalaman/shellcheck-alpine:latest
before_script:
- apk update
- apk add git
script:
- find . -name '*.sh' -type f
- find . -name '*.sh' -type f | xargs -I % shellcheck %
###############################################################
# JsonLint hhttps://github.com/zaach/jsonlint
# https://github.com/PeterDaveHello/docker-jsonlint
# https://hub.docker.com/r/peterdavehello/jsonlint/
# --> a CI job that will lint all JSON files
###############################################################
json_linter:
stage: linter
when: manual
needs: []
variables:
jsonlint_version: "1.6.3"
image: peterdavehello/jsonlint:$jsonlint_version
script:
- find . -name '*.json' -type f
- find . -name '*.json' -type f | xargs -n 1 jsonlint -q
###############################################################
# Alternative: https://gitlab.com/pipeline-components/jsonlint
###############################################################
#json_linter:
# stage: linter
# when: manual
# image: registry.gitlab.com/pipeline-components/jsonlint:latest
# script:
# - |
# find . -not -path './.git/*' -name '*.json' -type f -print0 |
# parallel --will-cite -k -0 -n1 jsonlint -q
###############################################################
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment