Skip to content

fixes debug v2

fixes debug v2 #126

---
name: Molecule Testsing
on: # yamllint disable-line rule:truthy
push: null
pull_request:
branches:
- main
- master
permissions: read-all
concurrency:
group: >-
${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
env:
PREINSTALL_MOLECULE_REQUIREMENTS: 'true'
jobs:
test_bareos:
runs-on: ubuntu-latest
container:
image: ubuntu:latest
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
options: --privileged --cap-add SYS_ADMIN
permissions:
statuses: write
# strategy:
# fail-fast: false
# matrix:
# role:
# - bareos
# - something
steps:
- name: Install docker
uses: papodaca/install-docker-action@v1
- name: Checkout
uses: actions/checkout@v4
- name: Install python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Install other apt packages
run: apt-get install gnupg2 rsync openssh-client openssh-server -y
- name: Poetry install dependecies
run: |
export PATH="/github/home/.local/bin:$PATH"
ls -lha
poetry install --no-root --no-cache --ansi --no-interaction
- name: Show installed versions
run: |
poetry run python --version
poetry --version || true
ESC="$(printf "\033")"
printf "Packages:\n%s\n \n" "$(poetry --ansi run pip list | sed -e "s/ /${ESC}[1;35m /g; s/$/${ESC}[0m/g")"
# Use 'debug' word in commit message to debug molecule testing, use debug v[1..6] to enable verbose logging.
- name: Molecule test
shell: bash
run: |
printf "[defaults]\nremote_tmp = /tmp/.ansible-\${USER}/tmp" > $HOME/.ansible.cfg
cd roles/bareos
DEBUG_OPT=$([[ "$COMMIT_MSG" =~ .(debug) ]] && echo "--debug")
VERB_OPT=$([[ "$COMMIT_MSG" =~ .(debug).v([1-6]) ]] && (printf "-" && printf "%*s" ${COMMIT_MSG/*debug v/} | \
tr ' ' 'v'))
echo "DEBUG_OPT: $DEBUG_OPT"
echo "VERB_OPT: $VERB_OPT"
set -x
if $PREINSTALL_MOLECULE_REQUIREMENTS && [[ -f "molecule/default/requirements.yml" ]]; then
poetry --ansi run ansible-galaxy install -r molecule/default/requirements.yml \
--server https://old-galaxy.ansible.com --timeout 300 $VERB_OPT
fi
poetry --ansi run molecule $DEBUG_OPT $VERB_OPT test
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
COMMIT_MSG: ${{ github.event.head_commit.message }}