Skip to content

Commit b8a502f

Browse files
committed
Add Github Actions for running code linters
1 parent 87bfefc commit b8a502f

File tree

8 files changed

+121
-0
lines changed

8 files changed

+121
-0
lines changed

.ansible-lint.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
skip_list:
3+
- var-naming[no-role-prefix]
4+
- galaxy[no-changelog]
5+
- galaxy[version-incorrect]
6+
- meta-runtime[unsupported-version]
7+
exclude_paths:
8+
- actionlint.yml
9+
- .github/

.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# The is primarily used to alter the behaviour of linters executed by super-linter.
2+
# See https://editorconfig.org/
3+
4+
# shfmt will default to indenting shell scripts with tabs,
5+
# define the indent as 2 spaces
6+
[bin/*]
7+
indent_style = space
8+
indent_size = 2

.github/linters/actionlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../actionlint.yml

.github/workflows/lint.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: Lint
3+
4+
on: # yamllint disable-line rule:truthy
5+
workflow_call:
6+
7+
permissions:
8+
contents: read
9+
packages: read
10+
# To report GitHub Actions status checks
11+
statuses: write
12+
13+
jobs:
14+
lint:
15+
name: Lint
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: read
20+
# To report GitHub Actions status checks
21+
statuses: write
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
# super-linter needs the full git history to get the
27+
# list of files that changed across commits
28+
fetch-depth: 0
29+
submodules: true
30+
31+
- name: Run ansible-lint
32+
uses: ansible/[email protected]
33+
34+
- name: Load super-linter configuration
35+
# Use grep inverse matching to exclude eventual comments in the .env file
36+
# because the GitHub Actions command to set environment variables doesn't
37+
# support comments.
38+
# yamllint disable-line rule:line-length
39+
# Ref: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable
40+
run: grep -v '^#' super-linter.env >> "$GITHUB_ENV"
41+
if: always()
42+
43+
- name: Run super-linter
44+
uses: super-linter/[email protected]
45+
if: always()
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.yamllint.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
brackets:
6+
forbid: non-empty
7+
comments:
8+
# https://github.com/prettier/prettier/issues/6780
9+
min-spaces-from-content: 1
10+
# https://github.com/adrienverge/yamllint/issues/384
11+
comments-indentation: false
12+
document-start: disable
13+
# 160 chars was the default used by old E204 rule, but
14+
# you can easily change it or disable in your .yamllint file.
15+
line-length:
16+
max: 160
17+
# We are adding an extra space inside braces as that's how prettier does it
18+
# and we are trying not to fight other linters.
19+
braces:
20+
min-spaces-inside: 0 # yamllint defaults to 0
21+
max-spaces-inside: 1 # yamllint defaults to 0
22+
octal-values:
23+
forbid-implicit-octal: true # yamllint defaults to false
24+
forbid-explicit-octal: true # yamllint defaults to false

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,20 @@ where the IP of the login node is given in `environments/$ENV/inventory/hosts.ym
138138
- `dev/`: Contains development tools.
139139

140140
For further information see the [docs](docs/) directory.
141+
142+
## Developing locally
143+
144+
To run the GitHub Actions linters locally, use:
145+
146+
```sh
147+
docker run --rm \
148+
-e RUN_LOCAL=true \
149+
--env-file "super-linter.env" \
150+
-v "$(pwd)":/tmp/lint \
151+
ghcr.io/super-linter/super-linter:v7.3.0
152+
```
153+
154+
```sh
155+
ansible-lint -c .ansible-lint.yml ansible/
156+
```
157+

actionlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
---

super-linter.env

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Detect that default branch is devel when running locally
2+
DEFAULT_BRANCH=main
3+
4+
# Don't validate JSCPD
5+
VALIDATE_JSCPD=false
6+
7+
# Don't validate JS standard because it conflicts with JS prettier
8+
VALIDATE_JAVASCRIPT_STANDARD=false
9+
10+
# Don't validate Ansible because ansible-lint is more flexible
11+
VALIDATE_ANSIBLE=false
12+
13+
# Don't validate YAML prettier because yamllint is sufficient
14+
VALIDATE_YAML_PRETTIER=false

0 commit comments

Comments
 (0)