Skip to content

Commit

Permalink
rework ci
Browse files Browse the repository at this point in the history
  • Loading branch information
maxhoesel committed Jun 7, 2024
1 parent 9e0f39a commit c37046d
Show file tree
Hide file tree
Showing 10 changed files with 280 additions and 42 deletions.
12 changes: 10 additions & 2 deletions .config/molecule/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
dependency:
name: galaxy
options:
requirements-file: requirements.molecule.yml

driver:
name: docker
Expand All @@ -9,12 +11,18 @@ provisioner:
name: ansible
env:
ANSIBLE_PIPELINING: true
inventory:
group_vars:
all:
# Versions to use, can be passed in from pytest
step_cli_version: ${STEP_CLI_VERSION:-latest}
step_ca_version: ${STEP_CA_VERSION:-latest}

scenario:
test_sequence:
- destroy
- dependency
- syntax
- dependency
- destroy
- create
- prepare
- converge
Expand Down
11 changes: 10 additions & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"extends": [
"github>maxhoesel-ansible/.github:renovate-config"
]
],
"pip-compile": {
"fileMatch": ["^requirements\\.txt$"]
},
"pip_requirements": {
"enabled": false
},
"pip_setup": {
"enabled": false
}
}
53 changes: 41 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,41 @@ on:

jobs:
lint:
name: "CI"
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out codebase
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
pip3 install --upgrade pip
pip3 install -r requirements.txt
- name: Run ansible-lint
run: ansible-lint

- name: Run pre-commit
run: pre-commit run --all-files

molecule:
name: "Molecule ${{ matrix.scenario }},${{ matrix.ansible_version }}"
runs-on: ubuntu-latest
strategy:
matrix:
job:
- molecule-ansible8
- molecule-ansible9
- lint
matrix:
scenario:
- default
ansible_version:
- "2.16"
- "2.17"

steps:
- name: Check out codebase
uses: actions/checkout@v4
Expand All @@ -24,11 +51,13 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Set up pip
run: pip3 install --upgrade pip

- name: Install tox
run: sudo apt update && sudo apt -y install tox
- name: Install dependencies
run: |
pip3 install --upgrade pip
pip3 install -r requirements.txt
pip3 install "ansible-core~=${{ matrix.ansible_version }}"
- name: Run Tox
run: tox -e ${{ matrix.job }}
- name: Run scenario
run: |
molecule test -s ${{ matrix.scenario }}
13 changes: 12 additions & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
---
platforms:
- name: postfix-nullclient-ubuntu-222
- name: postfix-nullclient-ubuntu-24
image: "geerlingguy/docker-ubuntu2404-ansible"
groups:
- ubuntu
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
override_command: false
pre_build_image: true

- name: postfix-nullclient-ubuntu-22
image: "geerlingguy/docker-ubuntu2204-ansible"
groups:
- ubuntu
Expand Down
15 changes: 15 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Include a version of ansible-core for IDE hints and the default pytest version
# It is also needed for docs generation.
#
# This installed version can be overriden by running pytest with the --ansible-version command.
# Ideally pytest would install another venv just for the test, but the pytest-virtualenv package
# is ancient and incompatible with python 3.12.
ansible-core==2.17.0

# Linting & Formatting
ansible-lint==24.6.0
pre-commit==3.7.1

# Requirements for running the tests for this role
molecule==24.2.1
molecule-plugins[docker]==23.5.3
5 changes: 5 additions & 0 deletions requirements.molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Requirements for running molecule testing scenarios
# These are not the collection runtime requirements
collections:
- name: community.docker
version: "==3.4.8"
164 changes: 161 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,163 @@
# Requirements for running the tests for this role
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile requirements.in
#
ansible-compat==24.6.1
# via
# ansible-lint
# molecule
ansible-core==2.17.0
# via
# -r requirements.in
# ansible-compat
# ansible-lint
# molecule
ansible-lint==24.6.0
# via -r requirements.in
attrs==23.2.0
# via
# jsonschema
# referencing
black==24.4.2
# via ansible-lint
bracex==2.4
# via wcmatch
certifi==2024.6.2
# via requests
cffi==1.16.0
# via cryptography
cfgv==3.4.0
# via pre-commit
charset-normalizer==3.3.2
# via requests
click==8.1.7
# via
# black
# click-help-colors
# molecule
click-help-colors==0.9.4
# via molecule
cryptography==42.0.8
# via ansible-core
distlib==0.3.8
# via virtualenv
distro==1.9.0
# via selinux
docker==7.1.0
# via molecule-plugins
enrich==1.2.7
# via molecule
filelock==3.14.0
# via
# ansible-lint
# virtualenv
identify==2.5.36
# via pre-commit
idna==3.7
# via requests
importlib-metadata==7.1.0
# via ansible-lint
jinja2==3.1.4
# via
# ansible-core
# molecule
jsonschema==4.22.0
# via
# ansible-compat
# ansible-lint
# molecule
jsonschema-specifications==2023.12.1
# via jsonschema
markdown-it-py==3.0.0
# via rich
markupsafe==2.1.5
# via jinja2
mdurl==0.1.2
# via markdown-it-py
molecule==24.2.1
# via
# -r requirements.in
# molecule-plugins
molecule-plugins[docker]==23.5.3
ansible-lint==24.5.0
tox==4.12.1
# via -r requirements.in
mypy-extensions==1.0.0
# via black
nodeenv==1.9.1
# via pre-commit
packaging==24.0
# via
# ansible-compat
# ansible-core
# ansible-lint
# black
# molecule
pathspec==0.12.1
# via
# ansible-lint
# black
# yamllint
platformdirs==4.2.2
# via
# black
# virtualenv
pluggy==1.5.0
# via molecule
pre-commit==3.7.1
# via -r requirements.in
pycparser==2.22
# via cffi
pygments==2.18.0
# via rich
pyyaml==6.0.1
# via
# ansible-compat
# ansible-core
# ansible-lint
# molecule
# pre-commit
# yamllint
referencing==0.35.1
# via
# jsonschema
# jsonschema-specifications
requests==2.31.0
# via
# docker
# molecule-plugins
resolvelib==1.0.1
# via ansible-core
rich==13.7.1
# via
# ansible-lint
# enrich
# molecule
rpds-py==0.18.1
# via
# jsonschema
# referencing
ruamel-yaml==0.18.6
# via ansible-lint
ruamel-yaml-clib==0.2.8
# via ruamel-yaml
selinux==0.3.0
# via molecule-plugins
subprocess-tee==0.4.1
# via
# ansible-compat
# ansible-lint
urllib3==2.2.1
# via
# docker
# requests
virtualenv==20.26.2
# via pre-commit
wcmatch==8.5.2
# via
# ansible-lint
# molecule
yamllint==1.35.1
# via ansible-lint
zipp==3.19.2
# via importlib-metadata
24 changes: 24 additions & 0 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -eu
set -e pipefail

printf "Creating project-specific virtualenv in .venv..."
python3 -m venv .venv
printf "OK\n"

source .venv/bin/activate

printf "Installing development requirements..."
python3 -m pip install --upgrade pip --quiet
python3 -m pip install --quiet -r requirements.txt --upgrade
python3 -m piptools sync --pip-args "--quiet" # ensure contents stay synced with lockfile

printf "OK\n"

printf "Installing pre-commit hook..."
pre-commit install > /dev/null
printf "OK\n"

printf "Development venv initialized!\n"
printf "To activate it, run:\n\n"
printf "source .venv/bin/activate\n"
2 changes: 2 additions & 0 deletions scripts/update_requirements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
pip-compile -U requirements.in
23 changes: 0 additions & 23 deletions tox.ini

This file was deleted.

0 comments on commit c37046d

Please sign in to comment.