Skip to content

Commit

Permalink
update build hooks
Browse files Browse the repository at this point in the history
- update github workflows
- update molecule config
  • Loading branch information
bodsch committed Apr 25, 2023
1 parent 73e65f8 commit a935b25
Show file tree
Hide file tree
Showing 15 changed files with 131 additions and 52 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/configured.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
name: libvirt with configuration

on:
schedule:
- cron: "0 2 * * 0"
workflow_dispatch:
workflow_run:
workflows:
- "CI"
branches:
- main
- feature/**
types:
- completed

Expand All @@ -30,7 +25,8 @@ jobs:
- debian:11
ansible-version:
- '6.1'

scenario:
- configured
steps:
- name: check out the codebase.
uses: actions/checkout@v3
Expand All @@ -49,8 +45,11 @@ jobs:
- name: test with tox
run: |
tox -e ansible_$(printf "${{ matrix.ansible-version }}") \
-- molecule test --scenario-name configured
make \
test \
-e TOX_SCENARIO="${{ matrix.scenario }}" \
-e TOX_ANSIBLE="ansible_${{ matrix.ansible-version }}" \
-e DISTRIBUTION="${{ matrix.image }}"
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
Expand Down
33 changes: 28 additions & 5 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,37 @@
name: code linter

on:
schedule:
- cron: "45 1 * * 0"
workflow_dispatch:
pull_request:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
push:
branches:
- main
- testing
- 'main'
- 'feature/**'
- '!doc/**'
paths:
- "!Makefile"
- "!README.md"
- "tasks/**"
pull_request:
branches:
- 'main'
- 'feature/**'
- '!doc/**'
paths:
- "!Makefile"
- "!README.md"
- "tasks/**"

jobs:
lint:
Expand All @@ -17,8 +42,6 @@ jobs:
steps:
- name: 🛎 Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: lint
uses: docker://ghcr.io/github/super-linter:slim-v4
Expand Down
26 changes: 14 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
name: CI

on:
schedule:
- cron: "0 2 * * 0"
workflow_dispatch:
workflow_run:
workflows:
- "code linter"
branches:
- main
- feature/**
types:
- completed

Expand All @@ -31,7 +25,8 @@ jobs:
ansible-version:
- '5.1'
- '6.1'

scenario:
- default
steps:
- name: check out the codebase.
uses: actions/checkout@v3
Expand All @@ -50,8 +45,11 @@ jobs:
- name: test with tox
run: |
tox -e ansible_$(printf "${{ matrix.ansible-version }}") \
-- molecule test --scenario-name default
make \
test \
-e TOX_SCENARIO="${{ matrix.scenario }}" \
-e TOX_ANSIBLE="ansible_${{ matrix.ansible-version }}" \
-e DISTRIBUTION="${{ matrix.image }}"
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
Expand All @@ -71,7 +69,8 @@ jobs:
ansible-version:
- '5.1'
- '6.1'

scenario:
- default
steps:
- name: check out the codebase.
uses: actions/checkout@v3
Expand All @@ -90,8 +89,11 @@ jobs:
- name: test with tox
run: |
tox -e ansible_$(printf "${{ matrix.ansible-version }}") \
-- molecule test --scenario-name default
make \
test \
-e TOX_SCENARIO="${{ matrix.scenario }}" \
-e TOX_ANSIBLE="ansible_${{ matrix.ansible-version }}" \
-e DISTRIBUTION="${{ matrix.image }}"
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#
export TOX_SCENARIO ?= default
# export TOX_PYTHON ?= py310
export TOX_ANSIBLE ?= ansible_6.1

.PHONY: converge destroy verify lint
.PHONY: converge destroy verify test lint

default: converge

Expand All @@ -16,5 +15,8 @@ destroy:
verify:
@hooks/verify

test:
@hooks/test

lint:
@hooks/lint
4 changes: 1 addition & 3 deletions hooks/converge
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env bash

. hooks/_tox_base

tox ${TOX_OPTS} -- molecule converge ${TOX_ARGS}
hooks/tox.sh "converge"
4 changes: 1 addition & 3 deletions hooks/destroy
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env bash

. hooks/_tox_base

tox ${TOX_OPTS} -- molecule destroy ${TOX_ARGS}
hooks/tox.sh "destroy"
4 changes: 1 addition & 3 deletions hooks/lint
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env bash

. hooks/_tox_base

tox ${TOX_OPTS} -- molecule lint ${TOX_ARGS}
hooks/tox.sh "lint"
File renamed without changes.
3 changes: 3 additions & 0 deletions hooks/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

hooks/tox.sh "test"
26 changes: 26 additions & 0 deletions hooks/tox.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

. hooks/molecule.rc

TOX_TEST="${1}"

if [ -f "./collections.yml" ]
then
for collection in $(grep -v "#" collections.yml | grep "^ - name: " | awk -F ': ' '{print $2}')
do
collections_installed="$(ansible-galaxy collection list | grep ${collection} 2> /dev/null)"

if [ -z "${collections_installed}" ]
then
echo "Install the required collection '${collection}'"
ansible-galaxy collection install ${collection}
else
collection_version=$(echo "${collections_installed}" | awk -F ' ' '{print $2}')

echo "The required collection '${collection}' is installed in version ${collection_version}."
fi
done
echo ""
fi

tox ${TOX_OPTS} -- molecule ${TOX_TEST} ${TOX_ARGS}
4 changes: 1 addition & 3 deletions hooks/verify
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env bash

. hooks/_tox_base

tox ${TOX_OPTS} -- molecule verify ${TOX_ARGS}
hooks/tox.sh "verify"
8 changes: 6 additions & 2 deletions molecule/configured/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ provisioner:
name: ansible
ansible_args:
- --diff
# - -v
- -v
config_options:
defaults:
deprecation_warnings: True
deprecation_warnings: true
stdout_callback: yaml
callbacks_enabled: profile_tasks
gathering: smart
fact_caching: jsonfile
fact_caching_timeout: 8640
fact_caching_connection: ansible_facts

scenario:
test_sequence:
Expand Down
24 changes: 19 additions & 5 deletions molecule/configured/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,27 @@
gather_facts: true

pre_tasks:
- name: update pacman system
command: |
pacman --refresh --sync --sysupgrade --noconfirm
- name: arch- / artixlinux
when:
- ansible_distribution | lower == 'archlinux'
- ansible_distribution | lower == 'archlinux' or
ansible_os_family | lower == 'artix linux'
block:
- name: update pacman system
ansible.builtin.command: |
pacman --refresh --sync --sysupgrade --noconfirm
- debug:
- name: create depends service
ansible.builtin.copy:
mode: 0755
dest: /etc/init.d/net
content: |
#!/usr/bin/openrc-run
true
when:
- ansible_os_family | lower == 'artix linux'

- name: environment
ansible.builtin.debug:
msg:
- "os family : {{ ansible_distribution }} ({{ ansible_os_family }})"
- "distribution version : {{ ansible_distribution_major_version }}"
Expand Down
24 changes: 19 additions & 5 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,27 @@
gather_facts: true

pre_tasks:
- name: update pacman system
command: |
pacman --refresh --sync --sysupgrade --noconfirm
- name: arch- / artixlinux
when:
- ansible_distribution | lower == 'archlinux'
- ansible_distribution | lower == 'archlinux' or
ansible_os_family | lower == 'artix linux'
block:
- name: update pacman system
ansible.builtin.command: |
pacman --refresh --sync --sysupgrade --noconfirm
- debug:
- name: create depends service
ansible.builtin.copy:
mode: 0755
dest: /etc/init.d/net
content: |
#!/usr/bin/openrc-run
true
when:
- ansible_os_family | lower == 'artix linux'

- name: environment
ansible.builtin.debug:
msg:
- "os family : {{ ansible_distribution }} ({{ ansible_os_family }})"
- "distribution version : {{ ansible_distribution_major_version }}"
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ansible-lint
docker
flake8
molecule
molecule-docker
molecule-plugins[docker]
netaddr
pytest
pytest-testinfra
Expand Down

0 comments on commit a935b25

Please sign in to comment.