Skip to content

CI with Molecule

CI with Molecule #313

Workflow file for this run

---
name: CI with Molecule
"on":
push:
branches:
- 'main'
pull_request:
workflow_dispatch:
# Build master every Thursday at 7AM (schedule only applies to the master branch)
schedule:
- cron: "0 7 * * 4"
defaults:
run:
working-directory: ./traefik_auth_proxy
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
path: traefik_auth_proxy # Check out to where Ansible expects to find it
- name: Setup Python 3
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Append GitHub Actions system path
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install lint dependencies.
run: pip3 install ansible ansible-lint yamllint
- name: Lint code.
run: |
yamllint .
ansible-lint .
test:
name: Test
runs-on: ubuntu-latest
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DISTRO: ubuntu2404
RUN_TYPE: ci
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
path: traefik_auth_proxy # Check out to where Ansible expects to find it
- name: Setup Python 3
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install apt deps
run: sudo DEBIAN_FRONTEND=noninteractive apt-get install -y python3-venv
- name: Install Python deps
run: pip3 install ansible ansible-lint 'molecule>=5.0.1' molecule-plugins[docker] dnspython
- name: Create instances, prepare environment
run: molecule create
- name: Apply the role to the instance
run: molecule converge
- name: Check the role is idempotent
run: molecule idempotence
- name: Run tests
run: molecule verify
- name: Print containers and logs for debugging
if: failure()
run: |
docker ps;
docker logs traefik_auth_proxy_molecule_reverse-proxy_1;
docker logs traefik_auth_proxy_molecule_forward-auth_1;
date
- name: Clean up instance
if: always()
run: molecule cleanup && molecule destroy