when:
  branch: master

steps:
  ansible-lint:
    image: alpine/git
    commands:
      - apk add ansible ansible-lint
      - export ANSIBLE_COLLECTION=slococo/playground
      - ansible-galaxy collection install -r "$ANSIBLE_COLLECTION"/requirements.yml
      - ansible-lint
      - ansible-galaxy collection install "$ANSIBLE_COLLECTION"
      - ansible-playbook "$ANSIBLE_COLLECTION"/playbooks/main.yml --syntax-check
  molecule:
    image: docker:dind
    commands:
      - apk add --no-cache python3 python3-dev py3-pip gcc git curl build-base autoconf automake
      - apk add --no-cache py3-cryptography linux-headers musl-dev libffi-dev openssl-dev openssh
      - python3 -m pip config set global.break-system-packages true
      - python3 -m pip install ansible molecule molecule-plugins[docker] docker
      - export ANSIBLE_COLLECTION=slococo/playground
      - cd "$ANSIBLE_COLLECTION"
      - molecule test

services:
  dind:
    image: docker:dind
    privileged: true