Skip to content

Commit

Permalink
optimize workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
bodsch committed Jul 14, 2024
1 parent 8cded7c commit e72dcae
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 123 deletions.
108 changes: 104 additions & 4 deletions .github/workflows/configured.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,28 @@ defaults:
run:
working-directory: 'ansible-telegraf'

env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'

jobs:

deb:
debian:
name: "${{ matrix.image }} / ansible: ${{ matrix.ansible-version }}"
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'schedule' || github.event.workflow_run.conclusion == 'success' }}
strategy:
fail-fast: false
matrix:
image:
- debian:12
python_version:
- "3.10"
- "3.11"
ansible-version:
- '6.7'
- '8.5'
scenario:
- configured
- default

steps:
- name: check out the codebase.
Expand Down Expand Up @@ -64,3 +69,98 @@ jobs:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
DISTRIBUTION: ${{ matrix.image }}

ubuntu:
name: "${{ matrix.image }} / ansible: ${{ matrix.ansible-version }}"
runs-on: ubuntu-22.04
needs:
- debian
strategy:
fail-fast: false
matrix:
image:
- ubuntu:22.04
python_version:
- "3.10"
- "3.11"
ansible-version:
- '8.5'
scenario:
- default

steps:
- name: check out the codebase.
uses: actions/checkout@v4
with:
path: 'ansible-telegraf'
ref: ${{ github.event.workflow_run.head_branch }}

- name: 🐍 set up python
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python_version }}"

- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install -r test-requirements.txt
- name: force reinstall of community.docker
run: |
mkdir -p /home/runner/.ansible/collections
ansible-galaxy collection install community.docker --force
- name: test with tox
run: |
make \
test \
-e TOX_SCENARIO="${{ matrix.scenario }}" \
-e TOX_ANSIBLE="ansible_${{ matrix.ansible-version }}" \
-e DISTRIBUTION="${{ matrix.image }}"
scenarios:
name: "${{ matrix.image }} / ${{ matrix.scenario }} / ${{ matrix.ansible-version }} / ${{ matrix.python_version }}"
runs-on: ubuntu-22.04
needs:
- debian
strategy:
fail-fast: false
matrix:
image:
- debian:12
python_version:
- "3.11"
ansible-version:
- '8.5'
scenario:
- configured

steps:
- name: check out the codebase.
uses: actions/checkout@v4
with:
path: 'ansible-telegraf'
ref: ${{ github.event.workflow_run.head_branch }}

- name: 🐍 set up python
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python_version }}"

- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install -r test-requirements.txt
- name: force reinstall of community.docker
run: |
mkdir -p /home/runner/.ansible/collections
ansible-galaxy collection install community.docker --force
- name: test with tox
run: |
make \
test \
-e TOX_SCENARIO="${{ matrix.scenario }}" \
-e TOX_ANSIBLE="ansible_${{ matrix.ansible-version }}" \
-e DISTRIBUTION="${{ matrix.image }}"
116 changes: 6 additions & 110 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ defaults:
run:
working-directory: 'ansible-telegraf'

env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'

jobs:
arch:
name: "${{ matrix.image }} / ansible: ${{ matrix.ansible-version }}"
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'schedule' || github.event.workflow_run.conclusion == 'success' }}
strategy:
fail-fast: false
Expand All @@ -26,111 +30,7 @@ jobs:
- "3.10"
- "3.11"
ansible-version:
- '6.7'
scenario:
- default

steps:
- name: check out the codebase.
uses: actions/checkout@v4
with:
path: 'ansible-telegraf'
ref: ${{ github.event.workflow_run.head_branch }}

- name: 🐍 set up python
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python_version }}"

- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install -r test-requirements.txt
- name: force reinstall of community.docker
run: |
mkdir -p /home/runner/.ansible/collections
ansible-galaxy collection install community.docker --force
- name: test with tox
run: |
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'
DISTRIBUTION: ${{ matrix.image }}

debian:
name: "${{ matrix.image }} / ansible: ${{ matrix.ansible-version }}"
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'schedule' || github.event.workflow_run.conclusion == 'success' }}
strategy:
fail-fast: false
matrix:
image:
- debian:11
- debian:12
python_version:
- "3.10"
- "3.11"
ansible-version:
- '6.7'
scenario:
- default

steps:
- name: check out the codebase.
uses: actions/checkout@v4
with:
path: 'ansible-telegraf'
ref: ${{ github.event.workflow_run.head_branch }}

- name: 🐍 set up python
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python_version }}"

- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install -r test-requirements.txt
- name: force reinstall of community.docker
run: |
mkdir -p /home/runner/.ansible/collections
ansible-galaxy collection install community.docker --force
- name: test with tox
run: |
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'
DISTRIBUTION: ${{ matrix.image }}

ubuntu:
name: "${{ matrix.image }} / ansible: ${{ matrix.ansible-version }}"
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'schedule' || github.event.workflow_run.conclusion == 'success' }}
strategy:
fail-fast: false
matrix:
image:
- ubuntu:20.04
- ubuntu:22.04
python_version:
- "3.10"
- "3.11"
ansible-version:
- '6.7'
- '8.5'
scenario:
- default

Expand Down Expand Up @@ -163,7 +63,3 @@ jobs:
-e TOX_SCENARIO="${{ matrix.scenario }}" \
-e TOX_ANSIBLE="ansible_${{ matrix.ansible-version }}" \
-e DISTRIBUTION="${{ matrix.image }}"
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
DISTRIBUTION: ${{ matrix.image }}
1 change: 1 addition & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

galaxy_info:
role_name: telegraf
namespace: bodsch

author: Bodo Schulz
description: ansible role to setup telegraf
Expand Down
10 changes: 5 additions & 5 deletions molecule/configured/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ platforms:
privileged: true
pre_build_image: true
cgroupns_mode: host
published_ports:
- 9090:9090
- 9093:9093
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
- /var/lib/containerd
tmpfs:
- /run
- /tmp
published_ports:
- 9090:9090
- 9093:9093
docker_networks:
- name: telegraf
ipam_config:
Expand All @@ -35,7 +35,7 @@ platforms:
ipv4_address: "10.11.0.10"

- name: influx1
image: "bodsch/ansible-${DISTRIBUTION:-debian:12}"
image: "bodsch/ansible-debian:11"
command: ${MOLECULE_DOCKER_COMMAND:-""}
docker_host: "${DOCKER_HOST:-unix://run/docker.sock}"
privileged: true
Expand All @@ -52,7 +52,7 @@ platforms:
ipv4_address: "10.11.0.11"

- name: influx2
image: "bodsch/ansible-${DISTRIBUTION:-debian:12}"
image: "bodsch/ansible-debian:12"
command: ${MOLECULE_DOCKER_COMMAND:-""}
docker_host: "${DOCKER_HOST:-unix://run/docker.sock}"
privileged: true
Expand Down
14 changes: 14 additions & 0 deletions molecule/configured/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,25 @@
when:
- ansible_os_family | lower == 'artix linux'

- name: make sure python3-apt is installed (only debian based)
ansible.builtin.package:
name:
- python3-apt
state: present
when:
- ansible_os_family | lower == 'debian'

- name: update package cache
become: true
ansible.builtin.package:
update_cache: true

- name: install dependencies
ansible.builtin.package:
name:
- iproute2
state: present

- name: environment
ansible.builtin.debug:
msg:
Expand Down
4 changes: 2 additions & 2 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ platforms:
privileged: true
pre_build_image: true
cgroupns_mode: host
published_ports:
- 9090:9090
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
- /var/lib/containerd
Expand All @@ -26,6 +24,8 @@ platforms:
tmpfs:
- /run
- /tmp
published_ports:
- 9090:9090

provisioner:
name: ansible
Expand Down
14 changes: 14 additions & 0 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,25 @@
when:
- ansible_os_family | lower == 'artix linux'

- name: make sure python3-apt is installed (only debian based)
ansible.builtin.package:
name:
- python3-apt
state: present
when:
- ansible_os_family | lower == 'debian'

- name: update package cache
become: true
ansible.builtin.package:
update_cache: true

- name: install dependencies
ansible.builtin.package:
name:
- iproute2
state: present

- name: environment
ansible.builtin.debug:
msg:
Expand Down
Loading

0 comments on commit e72dcae

Please sign in to comment.