feat(ci): add multi-platform CI testing via Docker
Add CI infrastructure that tests the Ansible role on every distro declared in meta/main.yml (EL 8/9, Debian bullseye/bookworm, Ubuntu focal/jammy/noble) using Docker containers. - ci/build_matrix.py: parse meta/main.yml platforms into JSON matrix - ci/test_playbook.yml: test playbook (state=present + validate) - ci/Dockerfile.el, ci/Dockerfile.debian: per-family Docker images - Makefile: orchestrator (make test, make test-<slug>, make lint) - .gitea/workflows/ci.yml: Gitea Actions with dynamic matrix - .gitlab-ci.yml: GitLab CI pipeline - Jenkinsfile: Jenkins pipeline with parallel stages - .yamllint.yml: linter configuration - .dockerignore: exclude .git and CI configs from Docker context
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
.PHONY: help matrix lint test clean
|
||||
|
||||
SHELL := /bin/bash
|
||||
IMAGE_PREFIX := remote-users-fact-test
|
||||
|
||||
help: ## Show this help
|
||||
@grep -E '^[a-zA-Z_-]+:.*##' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*##"}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
matrix: ## Print the test matrix as JSON
|
||||
@python3 ci/build_matrix.py
|
||||
|
||||
lint: ## Run yamllint and ansible-lint
|
||||
yamllint roles/
|
||||
ansible-lint
|
||||
|
||||
test: ## Run tests on all distros from the matrix
|
||||
@python3 ci/build_matrix.py | python3 -c "\
|
||||
import sys, json; \
|
||||
matrix = json.load(sys.stdin); \
|
||||
[print(e['slug'] + ' ' + e['image'] + ' ' + e['platform']) for e in matrix]" | \
|
||||
while read slug image platform; do \
|
||||
$(MAKE) _test-one SLUG=$$slug IMAGE=$$image PLATFORM=$$platform; \
|
||||
done
|
||||
|
||||
test-%: ## Run test on a single distro (e.g. make test-el9)
|
||||
@python3 ci/build_matrix.py | python3 -c "\
|
||||
import sys, json; \
|
||||
slug = '$(*)';\
|
||||
matrix = json.load(sys.stdin); \
|
||||
matches = [e for e in matrix if e['slug'] == slug]; \
|
||||
assert matches, f'Unknown slug: {slug}. Valid: {[e[\"slug\"] for e in matrix]}'; \
|
||||
e = matches[0]; print(e['slug'] + ' ' + e['image'] + ' ' + e['platform'])" | \
|
||||
while read slug image platform; do \
|
||||
$(MAKE) _test-one SLUG=$$slug IMAGE=$$image PLATFORM=$$platform; \
|
||||
done
|
||||
|
||||
_test-one:
|
||||
@echo "=== Testing $(SLUG) ($(IMAGE)) ==="
|
||||
@dockerfile=ci/Dockerfile.el; \
|
||||
if [ "$(PLATFORM)" = "Debian" ] || [ "$(PLATFORM)" = "Ubuntu" ]; then \
|
||||
dockerfile=ci/Dockerfile.debian; \
|
||||
fi; \
|
||||
docker build \
|
||||
--build-arg "IMAGE=$(IMAGE)" \
|
||||
-t "$(IMAGE_PREFIX)-$(SLUG)" \
|
||||
-f "$$dockerfile" . \
|
||||
&& docker run --rm "$(IMAGE_PREFIX)-$(SLUG)"
|
||||
@echo "=== $(SLUG) OK ==="
|
||||
|
||||
clean: ## Remove test Docker images
|
||||
@python3 ci/build_matrix.py | python3 -c "\
|
||||
import sys, json; \
|
||||
[print('$(IMAGE_PREFIX)-' + e['slug']) for e in json.load(sys.stdin)]" | \
|
||||
while read img; do \
|
||||
docker rmi $$img 2>/dev/null || true; \
|
||||
done
|
||||
@echo "Clean done."
|
||||
Reference in New Issue
Block a user