# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Contributor: fossdd <fossdd@pwned.life>
# Maintainer: fossdd <fossdd@pwned.life>
pkgname=ansible-lint
pkgver=24.12.2
pkgrel=0
pkgdesc="check ansible playbooks"
url="https://github.com/ansible/ansible-lint"
arch="noarch"
license="MIT"
depends="
	ansible-core
	black
	git
	py3-ansible-compat
	py3-filelock
	py3-importlib-metadata
	py3-jinja2
	py3-jsonschema
	py3-packaging
	py3-requests
	py3-rich
	py3-ruamel.yaml
	py3-wcmatch
	py3-yaml
	python3
	yamllint
	"
makedepends="
	py3-gpep517
	py3-installer
	py3-setuptools
	py3-setuptools_scm
	py3-wheel
	"
checkdepends="
	py3-flaky
	py3-license-expression
	py3-psutil
	py3-pylint
	py3-pytest
	py3-pytest-cov
	py3-pytest-mock
	py3-pytest-mypy
	py3-pytest-xdist
	yamllint
	"
subpackages="$pkgname-pyc"
source="https://pypi.io/packages/source/a/ansible-lint/ansible_lint-$pkgver.tar.gz
	no-version-check.patch
	"
builddir="$srcdir/ansible_lint-$pkgver"
provides="py3-ansible-lint=$pkgver-r$pkgrel" # for backward compatibility
replaces="py3-ansible-lint"                  # for backward compatibility
options="net" # tests

prepare() {
	default_prepare

	sed -i 's|/bin/bash|/bin/sh|' tools/install-reqs.sh
}

build() {
	export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	# can take long without output, because ansible-galaxy is downloading stuff
	PYTHONPATH="$PWD/build/lib" .testenv/bin/python3 -m pytest \
		--ignore "src/ansiblelint/rules" \
		--deselect "test/test_main.py::test_call_from_outside_venv" \
		--deselect "test/test_cli_role_paths.py::test_run_single_role_path_no_trailing_slash_script" \
		--deselect "test/test_with_skip_tagid.py::test_run_skip_rule"\
		--deselect "test/rules/test_syntax_check.py::test_syntax_check_role" \
		--deselect "test/test_file_utils.py::test_normpath_path" \
		--deselect "test/test_file_utils.py::test_discover_lintables_silent" \
		--deselect "test/test_include_miss_file_with_role.py::test_cases_warning_message" \
		--deselect "test/test_include_miss_file_with_role.py::test_cases_that_do_not_report" \
		--deselect "test/test_rules_collection.py::test_rules_id_format" \
		--deselect "test/test_runner.py::test_include_wrong_syntax" \
		--deselect "test/test_skip_inside_yaml.py::test_role_tasks_with_block" \
		--deselect "test/test_task_includes.py::test_included_tasks" \
		--deselect "test/test_transformer.py::test_transformer" \
		--deselect "test/test_schemas.py::test_spdx"
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/ansible_lint-$pkgver-py3-none-any.whl
}

sha512sums="
0050f5c14165dc4114846096518d500fe2c400f05a6a943d36331042b02f8ae038ede8924a6a036e846eafa03c6bde8e24699b41cef85bcf6d770289f71fc162  ansible_lint-24.12.2.tar.gz
314fa02e0b30db8a8886824b0cce825ae4ffe227e2c5be434bc96e1c3ab8a6239548574d9ed0869def67b94c684a67abbf594f78aadbc64286fe8187502ba275  no-version-check.patch
"
