Integrated setup for integration tests

This commit is contained in:
2025-12-17 12:40:55 +01:00
parent da06943f29
commit c401ce4d52
9 changed files with 137 additions and 2 deletions

View File

@@ -153,7 +153,7 @@ test-lint: build-missing
test-unit: build-missing
@TEST_TYPE="unit" bash scripts/tests/code.sh
test-integration: build-missing
test-integration: setup-clean build-missing
@TEST_TYPE="integration" bash scripts/tests/code.sh
# Backwards compatible target (kept)
@@ -161,7 +161,7 @@ test-messy: test-lint test-unit test-integration
@echo "📑 Checking Ansible syntax…"
ansible-playbook -i localhost, -c local $(foreach f,$(wildcard group_vars/all/*.yml),-e @$(f)) playbook.yml --syntax-check
test: clean setup test-messy
test: setup-clean test-messy
@echo "✅ Full test (setup + tests) executed."
# Debug helper

View File

@@ -0,0 +1,37 @@
# Dotlinker (doli) 🧷
## Description
This Ansible role ensures the `doli` (dotlinker) CLI is installed (via `pkgmgr`)
and applies dotlinker mappings provided by the calling role.
The role is intentionally generic: it does not know anything about Nextcloud or other apps.
It can be included multiple times from different roles, each time with a different set of mappings.
## Usage
Call this role via `include_role` and pass mappings through `dotlinker_mappings`:
- `name`: unique mapping id
- `backend`: `cloud` or `chezmoi`
- `src`: source path (original location)
- `dest`: destination path (required for `cloud`)
The role will register mappings using `doli add` and can optionally run `doli pull`.
## Variables
- `dotlinker_user` (required): user to run `doli` as
- `dotlinker_config_path` (default: `~/.config/dotlinker/config.yaml`)
- `dotlinker_cli_name` (default: `doli`)
- `dotlinker_package_name` (default: `doli`)
- `dotlinker_replace` (default: `true`): pass `--replace` to `doli add`
- `dotlinker_apply` (default: `true`): run `doli pull` after adding mappings
## Credits 📝
Developed and maintained by **Kevin Veen-Birkenbach**.
Learn more at [www.veen.world](https://www.veen.world)
Part of the [Infinito.Nexus Project](https://s.infinito.nexus/code)
License: [Infinito.Nexus NonCommercial License](https://s.infinito.nexus/license)

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1,17 @@
# Package name in pkgmgr
dotlinker_package_name: "doli"
# Binary name
dotlinker_cli_name: "doli"
# If true, doli add will use --replace
dotlinker_replace: true
# If true, run doli pull after registering mappings
dotlinker_apply: true
# Default config path (can be overridden by caller)
dotlinker_config_path: "~/.config/dotlinker/config.yaml"
# Mappings provided by caller (list of dicts)
dotlinker_mappings: []

View File

@@ -0,0 +1,23 @@
---
galaxy_info:
author: "Kevin Veen-Birkenbach"
description: "Installs and applies dotlinker (doli) mappings (generic role)."
license: "Infinito.Nexus NonCommercial License"
license_url: "https://s.infinito.nexus/license"
company: |
Kevin Veen-Birkenbach
Consulting & Coaching Solutions
https://www.veen.world
min_ansible_version: "2.9"
platforms:
- name: Archlinux
versions:
- rolling
galaxy_tags:
- dotfiles
- cloud
- desktop
- automation
repository: https://s.infinito.nexus/code
issue_tracker_url: https://s.infinito.nexus/issues
documentation: "https://docs.infinito.nexus/"

View File

@@ -0,0 +1,7 @@
- name: Install dotlinker via pkgmgr
include_role:
name: pkgmgr-install
vars:
package_name: "{{ dotlinker_package_name }}"
- include_tasks: utils/once/flag.yml

View File

@@ -0,0 +1,42 @@
- name: Ensure dotlinker user is defined
ansible.builtin.assert:
that:
- dotlinker_user is defined
- dotlinker_user | length > 0
fail_msg: "dotlinker_user must be provided by the calling role."
- name: Ensure dotlinker config directory exists
ansible.builtin.file:
path: "{{ dotlinker_config_path | dirname }}"
state: directory
owner: "{{ dotlinker_user }}"
group: "{{ dotlinker_user }}"
mode: "0755"
- name: Register mappings in dotlinker
ansible.builtin.command:
argv: >-
{{
([dotlinker_cli_name, '-c', dotlinker_config_path, 'add']
+ (['--replace'] if (dotlinker_replace | bool) else [])
+ ['-N', item.name, '-b', item.backend, '-s', item.src]
+ (['-d', item.dest] if item.backend == 'cloud' else [])
)
}}
become: true
become_user: "{{ dotlinker_user }}"
loop: "{{ dotlinker_mappings }}"
loop_control:
label: "{{ item.name }}"
when: dotlinker_mappings | length > 0
- name: Apply dotlinker mappings (pull)
ansible.builtin.command: >
{{ dotlinker_cli_name | quote }}
-c {{ (dotlinker_config_path ) | quote }}
pull
become: true
become_user: "{{ dotlinker_user }}"
when:
- dotlinker_apply | bool
- dotlinker_mappings | length > 0

View File

@@ -0,0 +1,7 @@
---
# Install ONCE per play/host, but allow apply multiple times with different mappings
- include_tasks: 01_install.yml
when: run_once_desk_dotlinker is not defined
# Apply mappings EVERY time the role is included (with whatever dotlinker_mappings the caller passes)
- include_tasks: 02_apply.yml

View File

@@ -0,0 +1 @@
application_id: desk-dotlinker