Skip to content

Commit

Permalink
feat: updates to template (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp authored Jun 27, 2022
1 parent 4ff2e03 commit eb13b6f
Show file tree
Hide file tree
Showing 35 changed files with 2,694 additions and 241 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.{yml,yaml}]
[*.{yml,yaml,toml}]
indent_size = 2
5 changes: 5 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

github: wayofdev

...
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ updates:
directory: "/"
schedule:
interval: "daily"

...
178 changes: 147 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ on: # yamllint disable-line rule:truthy
- master
workflow_dispatch:
inputs:
shouldPublishImage:
description: 'Should publish image to Ansible Galaxy? (yes/no)'
shouldPublish:
description: 'Should publish role to Ansible Galaxy? (yes/no)'
required: false
default: 'no'

Expand All @@ -24,67 +24,183 @@ jobs:
- name: Check out the codebase
uses: actions/checkout@v3

- name: Set up Python 3
uses: actions/setup-python@v3
- name: Setup python3
uses: actions/setup-python@v4
with:
python-version: '3.x'
python-version: '3.9'

- name: Install poetry
uses: gi0baro/setup-poetry-bin@v1

- name: Install dependencies
run: |
set -eux
make install-all-deps
run: make install-deps

- name: Run linting tasks
run: make lint
run: |
set -eux
poetry run yamllint .
poetry run ansible-later **/*.yml
cd ./tests && poetry run ansible-lint test.yml -c ../.ansible-lint
integration:
name: Integration.
integration-macos-native:
name: Integration on macOS (native)
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-12

os: ["macos-12"]
steps:
- name: Check out the codebase
uses: actions/checkout@v3
- uses: actions/setup-python@v3

# Uncomment for debugging over SSH
# - name: Setup upterm.dev session for SSH debugging
# uses: lhotari/action-upterm@v1

- name: Update built-in macOS pip
run: make update-pip

- name: Install poetry into system
uses: gi0baro/setup-poetry-bin@v1
with:
python-version: 3.9
virtualenvs-in-project: true

- name: Install test dependencies
run: |
set -eux
make install-all-deps
- name: Load cached .venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies (cached)
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
env:
PY_COLORS: '1'

- name: Install dependencies
run: make install-deps

- name: Test the playbook
run: make test
env:
ANSIBLE_FORCE_COLOR: '1'
ANSIBLE_STDOUT_CALLBACK: 'unixy'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Idempotence check
run: |
idempotence=$(mktemp)
cd tests && poetry run ansible-playbook test.yml | tee -a ${idempotence}
tail ${idempotence} \
IDEMPOTENCE=$(mktemp)
cd tests && poetry run ansible-playbook test.yml | tee -a ${IDEMPOTENCE}
tail ${IDEMPOTENCE} \
| grep -q 'changed=0.*failed=0' \
&& (echo 'Idempotence test: pass' && exit 0) \
|| (echo 'Idempotence test: fail' && exit 1)
env:
PY_COLORS: '1'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

integration-macos-molecule:
name: Integration check on macOS (molecule)
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 4
matrix:
os: ["macos-12"]
python-version: ["3.9"]
scenario: ["default-macos-on-localhost"]
steps:
- name: Check out the codebase
uses: actions/checkout@v3

- name: Update built-in macOS pip
run: make update-pip

- name: Install poetry into system
uses: gi0baro/setup-poetry-bin@v1
with:
virtualenvs-in-project: true

- name: Load cached .venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies (cached)
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
env:
PY_COLORS: '1'

- name: Install dependencies
run: make install-deps

- name: Run molecule tests
run: poetry run molecule test --scenario-name "${SCENARIO}" -- -v
env:
SCENARIO: ${{ matrix.scenario }}
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

integration-linux-molecule:
name: Integration on Linux
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 4
matrix:
os: ["ubuntu-latest"]
python-version: ["3.9"]
scenario: ["default"]
steps:
- name: Check out the codebase
uses: actions/checkout@v3

- name: Setup python3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry into system
uses: gi0baro/setup-poetry-bin@v1
with:
virtualenvs-in-project: true

- name: Load cached .venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies (cached)
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
env:
PY_COLORS: '1'

- name: Install dependencies
run: make install-deps

- name: Run molecule tests
run: poetry run molecule test --scenario-name "${SCENARIO}" -- -v
env:
SCENARIO: ${{ matrix.scenario }}
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
ANSIBLE_STDOUT_CALLBACK: 'unixy'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish:
if: github.event.inputs.shouldPublishImage == 'yes' || github.ref == 'refs/heads/master'
if: github.event.inputs.shouldPublish == 'yes' || github.ref == 'refs/heads/master'
needs:
- lint
- integration
- integration-macos-native
- integration-macos-molecule
- integration-linux-molecule
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Publish to Ansible Galaxy
uses: lotyp/galaxy-action@1.2.1
uses: robertdebock/galaxy-action@1.2.1
with:
galaxy_api_key: ${{ secrets.GALAXY_API_KEY }}

...
2 changes: 2 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ jobs:
release-type: node
package-name: ansible-role-tpl
default-branch: master

...
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
*/__pycache__
*.pyc
.cache
poetry.lock
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "contrib/poetry-bin"]
path = contrib/poetry-bin
url = https://github.com/gi0baro/poetry-bin
17 changes: 17 additions & 0 deletions .later.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---

ansible:

# List of allowed literal bools (ANSIBLE0014)
literal-bools:
- "true"
- "false"
- "yes"
- "no"

# Global settings for all defined rules
rules:
# List of files to exclude
exclude_files: []

...
18 changes: 11 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -18,24 +18,28 @@ repos:
entry: yamllint --strict

- repo: https://github.com/commitizen-tools/commitizen
rev: v2.24.0
rev: v2.27.1
hooks:
- id: commitizen
stages:
- commit-msg

- repo: https://github.com/ansible/ansible-lint
rev: v6.2.1
rev: v6.3.0
hooks:
- id: ansible-lint
files: \.(yaml|yml)$
entry: ansible-lint . --force-color
pass_filenames: false
always_run: true
additional_dependencies:
- .[community]

- repo: https://github.com/robertdebock/pre-commit
rev: v1.4.5
rev: 1.5.1
hooks:
- id: ansible_role_find_unused_variable
- id: ansible_role_find_empty_files
# - id: ansible_role_find_empty_files
- id: ansible_role_find_empty_directories
- id: ansible_role_fix_readability
- id: ansible_role_find_undefined_handlers
- id: ansible_role_find_unquoted_values
# - id: ansible_role_find_unquoted_values
7 changes: 4 additions & 3 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

extends: default

ignore: |
contrib

# Overwrite above default rules
rules:
braces:
Expand Down Expand Up @@ -47,6 +50,4 @@ rules:
require-starting-space: true
min-spaces-from-content: 1

line-length:
max: 180
level: warning
line-length: disable
Loading

0 comments on commit eb13b6f

Please sign in to comment.