Skip to content

Commit

Permalink
refactoring based on strict ansible-lint rules. added pre-commit hook…
Browse files Browse the repository at this point in the history
…s and gitlab pipeline, added CoC and Contributing, updated license #major
  • Loading branch information
ckaserer committed Sep 23, 2021
1 parent 83a512f commit 9c97ae6
Show file tree
Hide file tree
Showing 44 changed files with 1,364 additions and 1,726 deletions.
82 changes: 82 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
# .ansible-lint

exclude_paths:
- .cache/ # implicit unless exclude_paths is defined in config
- .env/
- .github/
- .pre-commit-config.yaml
- .pre-commit-hooks.yaml

# parseable: true
# verbosity: 1
quiet: true

# Mock modules or roles in order to pass ansible-playbook --syntax-check
# mock_modules:
# - zuul_return
# # note the foo.bar is invalid as being neither a module or a collection
# - fake_namespace.fake_collection.fake_module
# - fake_namespace.fake_collection.fake_module.fake_submodule
# mock_roles:
# - mocked_role
# - author.role_name # old standalone galaxy role
# - fake_namespace.fake_collection.fake_role # role within a collection

# Enable checking of loop variable prefixes in roles
loop_var_prefix: "microk8s_"

# Enforce variable names to follow pattern below, in addition to Ansible own
# requirements, like avoiding python identifiers. To disable add `var-naming`
# to skip_list.
var_naming_pattern: "^[_]*microk8s_[a-z][a-z0-9_]*$"

use_default_rules: true

# This makes linter to fully ignore rules/tags listed below
# skip_list:
# - skip_this_tag
# - git-latest

# Any rule that has the 'opt-in' tag will not be loaded unless its 'id' is
# mentioned in the enable_list:
enable_list:
- fqcn-builtins # opt-in
- no-log-password # opt-in
- no-same-owner # opt-in
# - yaml
# Report only a subset of tags and fully ignore any others
# tags:
# - var-spacing

# This makes the linter display but not fail for rules/tags listed below:
# warn_list:
# - skip_this_tag
# - git-latest
# - experimental # experimental is included in the implicit list
# # - role-name

# Offline mode disables installation of requirements.yml
# offline: false

# Define required Ansible's variables to satisfy syntax check
extra_vars:
# foo: bar
# multiline_string_variable: |
# line1
# line2
# complex_variable: ":{;\t$()"

# Uncomment to enforce action validation with tasks, usually is not
# needed as Ansible syntax check also covers it.
# skip_action_validation: false

# List of additional kind:pattern to be added at the top of the default
# match list, first match determines the file kind.
# kinds:
# - playbook: "**/examples/*.{yml,yaml}"
# - galaxy: "**/folder/galaxy.yml"
# - tasks: "**/tasks/*.yml"
# - vars: "**/vars/*.yml"
# - meta: "**/meta/main.yml"
...
27 changes: 0 additions & 27 deletions .editorconfig

This file was deleted.

49 changes: 2 additions & 47 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,47 +1,2 @@

# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
LICENSE text
.editorconfig text
.gitattributes text
.gitignore text
.yamllint text
*.cfg text
*.css text
*.htm text
*.html text
*.js text
*.json text
*.less text
*.md text
*.py text
*.scss text
*.ts text
*.txt text
*.xhtml text
*.xml text
*.yaml text
*.yml text

# Declare files that will always have CRLF line endings on checkout.
*.bat text eol=crlf
*.cmd text eol=crlf

# Declare files that will always have LF line endings on checkout.
*.conf eol=lf
*.desktop eol=lf
*.j2 eol=lf
*.service eol=lf
*.sh text eol=lf

# Denote all files that are truly binary and should not be modified.
*.eot binary
*.gif binary
*.jpeg binary
*.jpg binary
*.png binary
*.tff binary
*.woff binary
*.yml linguist-detectable
*.yaml linguist-detectable
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
github: ckaserer
...
109 changes: 109 additions & 0 deletions .github/workflows/1-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
name: Develop

'on':
push:
branches:
- develop
workflow_dispatch:

jobs:
ansible-linter:
name: Ansible Linter
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install ansible-lint Dependencies
run: pip3 install ansible ansible-base ansible-lint

- name: Lint Code Base with ansible-lint
run: ansible-lint

pre-commit:
name: pre-commit
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Run pre-commit
uses: pre-commit/[email protected]

super-linter:
name: Github Linter
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Lint Code Base with github super-linter
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: true
FILTER_REGEX_EXCLUDE: '.*.md'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

yaml-linter:
name: YAML Linter
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install yamllint Dependencies
run: pip3 install yamllint

- name: Lint Code Base with yamllint
run: yamllint .

pull-request:
name: Pull Request
runs-on: ubuntu-latest
needs:
- ansible-linter
- pre-commit
- super-linter
- yaml-linter
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
branch: main
token: ${{ secrets.PAT }}

notify:
name: Slack Notifications
runs-on: ubuntu-latest
if: ${{ failure() }}
needs:
- pull-request
steps:
- name: Notify Slack channel on failure
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_ICON: https://github.com/ckaserer/logos/raw/master/ansible.png
SLACK_USERNAME: ${{ github.repository }}
SLACK_COLOR: '#ff0033'
SLACK_FOOTER: ''
...
91 changes: 91 additions & 0 deletions .github/workflows/2-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
name: Pull Request

'on':
pull_request:

jobs:
ansible-linter:
name: Ansible Linter
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install ansible-lint Dependencies
run: pip3 install ansible ansible-base ansible-lint

- name: Lint Code Base with ansible-lint
run: ansible-lint

pre-commit:
name: pre-commit
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Run pre-commit
uses: pre-commit/[email protected]

super-linter:
name: Github Linter
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Lint Code Base with github super-linter
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: true
FILTER_REGEX_EXCLUDE: '.*.md'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

yaml-linter:
name: YAML Linter
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install yamllint Dependencies
run: pip3 install yamllint

- name: Lint Code Base with yamllint
run: yamllint .

notify:
name: Slack Notifications
runs-on: ubuntu-latest
if: ${{ failure() }}
needs:
- ansible-linter
- pre-commit
- super-linter
- yaml-linter
steps:
- name: Notify Slack channel on failure
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_ICON: https://github.com/ckaserer/logos/raw/master/ansible.png
SLACK_USERNAME: ${{ github.repository }}
SLACK_COLOR: '#ff0033'
SLACK_FOOTER: ''
...
Loading

0 comments on commit 9c97ae6

Please sign in to comment.