Skip to content

Make sure roles are runnable in clean environment #80

Make sure roles are runnable in clean environment

Make sure roles are runnable in clean environment #80

name: "Test Ansible roles"
on:
pull_request:
branches:
- "master"
push:
branches:
- "master"
workflow_dispatch:
env:
SYSTEM_USER: "runner_42" # should match ansible_user (host_vars/github_ci/vars.yml)
SLEEP_BEFORE_LOADING_APP_URL_SECONDS: 120
SLEEP_BEFORE_SCREENSHOT_SECONDS: 10
jobs:
system:
runs-on: "ubuntu-22.04"
steps:
- uses: "actions/checkout@v4"
- name: "Install deploy keys for private dependencies"
uses: "webfactory/[email protected]"
with:
ssh-private-key: |
${{ secrets.GH_DEPLOYKEY_ANSIBLE_COLLECTION_SELFHOSTED }}
${{ secrets.GH_DEPLOYKEY_ANSIBLE_COLLECTION_SMARTHOME }}
${{ secrets.GH_DEPLOYKEY_ANSIBLE_COLLECTION_YAMS }}
- uses: "actions/setup-python@v5"
with:
python-version: "3.12"
- name: "Install dependencies"
run: |
/opt/pipx/venvs/ansible-core/bin/python -m pip install passlib
ansible-galaxy install -r requirements.yml
ansible --version
python --version
python3 --version
- name: "Run ansible playbook (tags: system,zsh)"
run: |
ansible-playbook playbook-github-ci.yml \
--vault-password-file vault.ci.sh \
--tags system,zsh \
-v
- name: "Test if ${{ env.SYSTEM_USER }} user exists"
run: "sudo passwd --status ${{ env.SYSTEM_USER }}"
docker:
runs-on: "ubuntu-22.04"
strategy:
matrix:
role:
[
{
name: "immich",
tags: "system,docker,media",
screenshot_url: "http://localhost:3001",
},
{
name: "jellyfin",
tags: "system,docker,media",
screenshot_url: "http://localhost:3002",
},
{
name: "jellyseerr",
tags: "system,docker,media",
screenshot_url: "http://localhost:3003",
},
{
name: "paperlessngx",
tags: "system,docker,media",
screenshot_url: "http://localhost:3004",
},
{
name: "prowlarr",
tags: "system,docker,media",
screenshot_url: "http://localhost:3005",
},
{
name: "radarr",
tags: "system,docker,media",
screenshot_url: "http://localhost:3006",
},
{
name: "sonarr",
tags: "system,docker,media",
screenshot_url: "http://localhost:3007",
},
{
name: "transmission",
tags: "system,docker,media",
screenshot_url: "http://runner_42:test4242@localhost:3008",
},
{
name: "duplicati",
tags: "system,docker,duplicati",
screenshot_url: "http://localhost:3009",
},
{
name: "filebrowser",
tags: "system,docker,storage",
screenshot_url: "http://localhost:3010",
},
{
name: "glances",
tags: "system,docker,monitoring",
screenshot_url: "http://localhost:61208",
},
{
name: "homebox",
tags: "system,docker,homebox",
screenshot_url: "http://localhost:3011",
},
{
name: "miniflux",
tags: "system,docker,rss",
screenshot_url: "http://localhost:3012",
},
{
name: "rssbridge",
tags: "system,docker,rss",
screenshot_url: "http://localhost:3013",
},
{
name: "vaultwarden",
tags: "system,docker,vaultwarden",
screenshot_url: "http://localhost:3014",
},
{
name: "wallos",
tags: "system,docker,wallos",
screenshot_url: "http://localhost:3015",
},
{
name: "wg-easy",
tags: "system,docker,wireguard",
screenshot_url: "http://localhost:3016",
},
{
name: "homeassistant",
tags: "system,docker,smarthome",
screenshot_url: "http://localhost:3017",
},
]
steps:
- uses: "actions/checkout@v4"
- name: "Install deploy keys for private dependencies"
uses: "webfactory/[email protected]"
with:
ssh-private-key: |
${{ secrets.GH_DEPLOYKEY_ANSIBLE_COLLECTION_SELFHOSTED }}
${{ secrets.GH_DEPLOYKEY_ANSIBLE_COLLECTION_SMARTHOME }}
${{ secrets.GH_DEPLOYKEY_ANSIBLE_COLLECTION_YAMS }}
- uses: "actions/setup-python@v5"
with:
python-version: "3.12"
- name: "Install dependencies"
run: |
/opt/pipx/venvs/ansible-core/bin/python -m pip install passlib
ansible-galaxy install -r requirements.yml
ansible --version
python --version
python3 --version
- name: "Run ansible playbook (tags: ${{ matrix.role.tags }})"
run: |
ansible-playbook playbook-github-ci.yml \
--vault-password-file vault.ci.sh \
--tags ${{ matrix.role.tags }} \
-v
- name: "Sleep before loading app"
run: "sleep ${{ env.SLEEP_BEFORE_LOADING_APP_URL_SECONDS }}"
- name: "Print docker processes"
run: "docker ps -a"
- name: "Make a screenshot of ${{ matrix.role.screenshot_url }}"
uses: "karol-brejna-i/webpage-screenshot-action@v1"
with:
url: "${{ matrix.role.screenshot_url }}"
scriptBefore: |
var waitTill = new Date(new Date().getTime() + ${{ env.SLEEP_BEFORE_SCREENSHOT_SECONDS }} * 1000);
while(waitTill > new Date()){}
output: "screenshot-${{ matrix.role.name }}.png"
- name: "Upload screenshots"
uses: "actions/upload-artifact@v3"
with:
name: "screenshots"
path: "${{ github.workspace }}/screenshot-*.png"