Skip to content

Commit

Permalink
Merge branch 'yaml' into 'main'
Browse files Browse the repository at this point in the history
Add yamllint

See merge request xebis/repository-template!7
  • Loading branch information
bruzina committed Apr 24, 2021
2 parents 1f0fd77 + c0daf9b commit a75f85d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ stages:
lint:
stage: verify
script:
- pip3 install pre-commit gitlint
- pip3 install gitlint pre-commit yamllint
- gitlint
- npm install -g markdownlint-cli
- pre-commit run --all-files
Expand Down
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ repos:
- id: check-merge-conflict
- id: check-symlinks
- id: check-vcs-permalinks
- id: check-yaml
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
Expand All @@ -30,3 +29,8 @@ repos:
rev: v0.27.1
hooks:
- id: markdownlint
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.26.1
hooks:
- id: yamllint
args: [--strict]
18 changes: 18 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
extends: default

rules:
braces:
min-spaces-inside: 1
max-spaces-inside: 1
comments:
min-spaces-from-content: 1
empty-lines:
max: 1
empty-values: enable
indentation:
spaces: 2
line-length: disable
octal-values: enable
quoted-strings:
required: only-when-needed
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Strategies and tactics to achieve objectives:
- Prevents merge conflict strings using [pre-commit/pre-commit-hooks: check-merge-conflict](https://github.com/pre-commit/pre-commit-hooks#check-merge-conflict)
- Prevents stale symlinks using [pre-commit/pre-commit-hooks: check-symlinks](https://github.com/pre-commit/pre-commit-hooks#check-symlinks)
- Prevents non-permanent GitHub links using [pre-commit/pre-commit-hooks: check-vcs-permalinks](https://github.com/pre-commit/pre-commit-hooks#check-vcs-permalinks)
- Checks YAML using [pre-commit/pre-commit-hooks: check-yaml](https://github.com/pre-commit/pre-commit-hooks#check-yaml)
- Prevents destroyed symlinks using [pre-commit/pre-commit-hooks: destroyed-symlinks](https://github.com/pre-commit/pre-commit-hooks#destroyed-symlinks)
- Prevents the existence of private keys using [pre-commit/pre-commit-hooks: detect-private-key](https://github.com/pre-commit/pre-commit-hooks#detect-private-key)
- Enforces files end with empty newline using [pre-commit/pre-commit-hooks: end-of-file-fixer](https://github.com/pre-commit/pre-commit-hooks#end-of-file-fixer)
Expand All @@ -48,6 +47,7 @@ Strategies and tactics to achieve objectives:
- Enforces non-executable script libraries have extension using [jumanjihouse/pre-commit-hooks: script-must-have-extension](https://github.com/jumanjihouse/pre-commit-hooks#script-must-have-extension)
- Lints Markdown using [igorshubovych/markdownlint-cli: MarkdownLint Command Line Interface](https://github.com/igorshubovych/markdownlint-cli)
- Except [CHANGELOG.md](CHANGELOG.md)
- Lints YAML using [adrienverge/yamllint](https://github.com/adrienverge/yamllint)
- When merged to `main` branch releases using [semantic-release/semantic-release](https://github.com/semantic-release/semantic-release)
- Determines major, minor, or patch version bump using [semantic-release/commit-analyzer](https://github.com/semantic-release/commit-analyzer)
- Generates release notes using [semantic-release/release-notes-generator](https://github.com/semantic-release/release-notes-generator)
Expand Down Expand Up @@ -101,6 +101,7 @@ Set up **GH_TOKEN**: [GitHub Personal Access Token](https://docs.github.com/en/g
- [GitHub - jumanjihouse/pre-commit-hooks: git pre-commit hooks that work with http://pre-commit.com/](https://github.com/jumanjihouse/pre-commit-hooks)
- [GitHub - jorisroovers/gitlint: Linting for your git commit messages](https://github.com/jorisroovers/gitlint)
- [GitHub - igorshubovych/markdownlint-cli: MarkdownLint Command Line Interface](https://github.com/igorshubovych/markdownlint-cli)
- [GitHub - adrienverge/yamllint: A linter for YAML files.](https://github.com/adrienverge/yamllint)

### Recommended

Expand Down
18 changes: 15 additions & 3 deletions tools/setup-repo
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,29 @@ else
# Install markdownlint-cli if it's not present
set +o pipefail
if npm list -g 2>/dev/null | grep "markdownlint-cli" >/dev/null; then
echo "$ECHO_PRE_OK MarkdownLint CLI is installed"
echo "$ECHO_PRE_OK markdownlint-cli is installed"
else
if $SUDO npm install -g markdownlint-cli; then
echo "$ECHO_PRE_INST MarkdownLint CLI has been installed"
echo "$ECHO_PRE_INST markdownlint-cli has been installed"
else
echo "$ECHO_PRE_ERR MarkdownLint CLI installation failed."
echo "$ECHO_PRE_ERR markdownlint-cli installation failed."
exit 1
fi
fi
set -o pipefail

# Install yamllint if it's not present
if pip3 list | grep "^yamllint\\s.*$" >/dev/null; then
echo "$ECHO_PRE_OK yamllint is installed"
else
if pip3 install yamllint; then
echo "$ECHO_PRE_INST yamllint has been installed"
else
echo "$ECHO_PRE_ERR yamllint installation failed."
exit 1
fi
fi

# Install pre-commit and gitlint into git hooks
pre-commit install
gitlint install-hook
Expand Down

0 comments on commit a75f85d

Please sign in to comment.