Skip to content

Commit

Permalink
ci: Initial pass at linting YAML files (#979)
Browse files Browse the repository at this point in the history
Co-authored-by: Cody J. Hanson <[email protected]>
  • Loading branch information
edgarrmondragon and cjohnhanson authored Nov 17, 2022
1 parent 72ec44e commit 32a2850
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .github/workflows/check-yaml-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint:
name: Lint YAML files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Get changed files in the docs folder
id: changed-files
uses: tj-actions/changed-files@v34
with:
files: |
_data/**/*.yml
- name: Install yamllint
if: steps.changed-files.outputs.any_changed == 'true'
run: pipx install yamllint

- name: Lint YAML files
if: steps.changed-files.outputs.any_changed == 'true'
run: yamllint ${{ steps.changed-files.outputs.all_changed_files }}
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Update the rev variable with the release version that you want, from the yamllint repo
# You can pass your custom .yamllint with args attribute.
repos:
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.28.0
hooks:
- id: yamllint
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ src/.temp
_data
assets
schemas
singer
singer
.pre-commit-config.yaml
.yamllint.yaml
16 changes: 16 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
extends: default

ignore: |
.pre-commit-config.yaml
rules:
braces:
forbid: non-empty
document-start:
present: false # Don't require `---` at the start of the file
indentation:
indent-sequences: false
spaces: 2
key-ordering: enable
line-length:
max: 160
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ yarn
yarn add --global @gridsome/cli
```

### Linters

You can use `pre-commit` to run the linters before committing.

```console
pipx install pre-commit
pre-commit install
```

This will run the linters on all files that are staged for commit. Included linters:

- [yamlllint](https://yamllint.readthedocs.io/en/stable/)

## Build and serve the project

Build for development and get live updates as files are changed:
Expand Down

0 comments on commit 32a2850

Please sign in to comment.