Skip to content

Commit

Permalink
Different way of testing, simpler.
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-de-bock committed Mar 6, 2025
1 parent e3ea720 commit a43e33b
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 124 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
types: [created, edited, published, released]
jobs:
release:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: galaxy
uses: robertdebock/[email protected]
Expand Down
142 changes: 40 additions & 102 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,21 @@ on:

jobs:
lint:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: ansible-lint
uses: ansible-community/ansible-lint-action@main

python-3-9:
molecule:
needs:
- lint
runs-on: ubuntu-20.04
container:
image: python:3.9
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
config:
distro:
- image: "alpine"
tag: "latest"
- image: "amazonlinux"
Expand All @@ -46,8 +44,6 @@ jobs:
tag: "40"
- image: "fedora"
tag: "latest"
- image: "fedora"
tag: "rawhide"
- image: "ubuntu"
tag: "latest"
- image: "ubuntu"
Expand All @@ -57,104 +53,46 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
with:
path: ansible-role-java

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

- name: molecule
- name: Configure Docker for systemd
run: |
apt-get update -qq
apt-get -y -qq install yamllint docker.io
pip install --no-cache-dir tox
if [ -f tox.ini ] ; then tox ; fi
if [ ! -f tox.ini ] ; then pip install -r requirements.yml ; pip install ansible-lint ansible-core ; molecule test ; fi
env:
image: ${{ matrix.config.image }}
tag: ${{ matrix.config.tag }}
python-3-10:
needs:
- lint
runs-on: ubuntu-20.04
container:
image: python:3.10
strategy:
fail-fast: false
matrix:
config:
- image: "alpine"
tag: "latest"
- image: "amazonlinux"
tag: "latest"
- image: "enterpriselinux"
tag: "latest"
- image: "debian"
tag: "latest"
- image: "debian"
tag: "bullseye"
- image: "fedora"
tag: "40"
- image: "fedora"
tag: "latest"
- image: "fedora"
tag: "rawhide"
- image: "ubuntu"
tag: "latest"
- image: "ubuntu"
tag: "jammy"
- image: "ubuntu"
tag: "focal"
steps:
- name: checkout
uses: actions/checkout@v4
sudo mkdir -p /etc/docker
echo '{
"features": {
"buildkit": true
},
"exec-opts": ["native.cgroupdriver=systemd"]
}' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker || true
- name: Install Docker
uses: docker/setup-buildx-action@v3

- name: molecule
- name: Install dependencies
run: |
apt-get update -qq
apt-get -y -qq install yamllint docker.io
pip install --no-cache-dir tox
if [ -f tox.ini ] ; then tox ; fi
if [ ! -f tox.ini ] ; then pip install -r requirements.yml ; pip install ansible-lint ansible-core ; molecule test ; fi
env:
image: ${{ matrix.config.image }}
tag: ${{ matrix.config.tag }}
python-3-13:
needs:
- lint
runs-on: ubuntu-20.04
container:
image: python:3.13
strategy:
fail-fast: false
matrix:
config:
- image: "alpine"
tag: "latest"
- image: "enterpriselinux"
tag: "latest"
- image: "debian"
tag: "latest"
- image: "debian"
tag: "bullseye"
- image: "fedora"
tag: "40"
- image: "fedora"
tag: "latest"
- image: "fedora"
tag: "rawhide"
- image: "ubuntu"
tag: "latest"
- image: "ubuntu"
tag: "jammy"
- image: "ubuntu"
tag: "focal"
steps:
- name: checkout
uses: actions/checkout@v4
python -m pip install --upgrade pip
pip install ansible-lint molecule molecule-plugins[docker] ansible-core
if [ -f ansible-role-java/requirements.txt ]; then pip install -r ansible-role-java/requirements.txt; fi
if [ -f ansible-role-java/requirements.yml ]; then ansible-galaxy install -r ansible-role-java/requirements.yml; fi
# Create proper role directory structure for molecule
mkdir -p ~/.ansible/roles
ln -s ${GITHUB_WORKSPACE}/ansible-role-java ~/.ansible/roles/robertdebock.java
- name: molecule
- name: Test with molecule
run: |
apt-get update -qq
apt-get -y -qq install yamllint docker.io
pip install --no-cache-dir tox
if [ -f tox.ini ] ; then tox ; fi
if [ ! -f tox.ini ] ; then pip install -r requirements.yml ; pip install ansible-lint ansible-core ; molecule test ; fi
cd ansible-role-java
molecule test
env:
image: ${{ matrix.config.image }}
tag: ${{ matrix.config.tag }}
PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1
ANSIBLE_ROLES_PATH: ~/.ansible/roles:${GITHUB_WORKSPACE}/ansible-role-java
image: ${{ matrix.distro.image }}
tag: ${{ matrix.distro.tag }}
2 changes: 1 addition & 1 deletion .github/workflows/requirements2png.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name: Ansible Graphviz

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
permissions:
contents: write
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
build:
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- name: "TODO to Issue"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.tox
.cache
.DS_Store
.ansible
36 changes: 18 additions & 18 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,54 @@ variables:
DEBIAN_FRONTEND: noninteractive

molecule:
image: $python
image: python:3.13
script:
- apt-get update -qq
- apt-get -y -qq install yamllint docker.io
- pip install --no-cache-dir tox
- if [ -f tox.ini ] ; then tox ; fi
- if [ ! -f tox.ini ] ; then pip install -r requirements.yml ; pip install ansible-lint ansible-core ; molecule test ; fi
# Configure Docker for systemd
- mkdir -p /etc/docker
- echo '{"features":{"buildkit":true},"exec-opts":["native.cgroupdriver=systemd"]}' > /etc/docker/daemon.json
- service docker restart || true
# Install dependencies and run tests
- pip install --no-cache-dir ansible-lint molecule molecule-plugins[docker] ansible-core
- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- if [ -f requirements.yml ]; then ansible-galaxy install -r requirements.yml; fi
# Create proper role directory structure for molecule
- mkdir -p ~/.ansible/roles
- ln -s $CI_PROJECT_DIR ~/.ansible/roles/robertdebock.java
# Run molecule tests
- cd $CI_PROJECT_DIR
- ANSIBLE_ROLES_PATH=~/.ansible/roles:$CI_PROJECT_DIR molecule test
rules:
- if: $CI_COMMIT_REF_NAME == "master"
parallel:
matrix:
- image: "alpine"
tag: "latest"
python: ['python:3.9', 'python:3.10', 'python:3.13']
- image: "amazonlinux"
tag: "latest"
python: ['python:3.9', 'python:3.10']
- image: "enterpriselinux"
tag: "latest"
python: ['python:3.9', 'python:3.10', 'python:3.13']
- image: "debian"
tag: "latest"
python: ['python:3.9', 'python:3.10', 'python:3.13']
- image: "debian"
tag: "bullseye"
python: ['python:3.9', 'python:3.10', 'python:3.13']
- image: "fedora"
tag: "40"
python: ['python:3.9', 'python:3.10', 'python:3.13']
- image: "fedora"
tag: "latest"
python: ['python:3.9', 'python:3.10', 'python:3.13']
- image: "fedora"
tag: "rawhide"
python: ['python:3.9', 'python:3.10', 'python:3.13']
- image: "ubuntu"
tag: "latest"
python: ['python:3.9', 'python:3.10', 'python:3.13']
- image: "ubuntu"
tag: "jammy"
python: ['python:3.9', 'python:3.10', 'python:3.13']
- image: "ubuntu"
tag: "focal"
python: ['python:3.9', 'python:3.10', 'python:3.13']

galaxy:
image: python:3.13
script:
- apk add ansible-core
- apt-get update -qq
- apt-get -y -qq install ansible-core
- ansible-galaxy role import --api-key ${GALAXY_API_KEY} robertdebock ${CI_PROJECT_NAME}
rules:
- if: $CI_COMMIT_TAG != null
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This example is taken from [`molecule/default/converge.yml`](https://github.com/
gather_facts: true

roles:
- role: robertdebock.java
- role: ansible-role-java
# To install Oracle java 21 package:
# NOTE: Please download Java yourself, place it in `files/`.
# This is to avoid licensing issues.
Expand Down
1 change: 1 addition & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ platforms:
- name: "java-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}"
image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}"
command: /sbin/init
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
privileged: true
Expand Down

0 comments on commit a43e33b

Please sign in to comment.