2015-05-08 23:52:18 +00:00
|
|
|
PYTHON ?= /usr/bin/python3
|
2010-12-08 13:16:13 +00:00
|
|
|
DESTDIR ?= /
|
2018-09-16 07:49:51 +00:00
|
|
|
PREFIX ?= /usr
|
|
|
|
mandir ?= $(PREFIX)/share/man
|
2019-11-12 11:15:36 +00:00
|
|
|
DOCKER ?= podman
|
2021-03-04 00:32:47 +00:00
|
|
|
PODMAN ?= $(DOCKER)
|
2019-03-26 22:46:03 +00:00
|
|
|
DOCS_VERSION ?= next
|
2019-06-24 18:19:12 +00:00
|
|
|
RUN_TESTS ?= ci
|
2020-09-30 21:53:29 +00:00
|
|
|
BACKEND ?= osbuild-composer
|
2008-10-05 05:51:17 +00:00
|
|
|
|
2010-12-02 12:36:22 +00:00
|
|
|
PKGNAME = lorax
|
|
|
|
VERSION = $(shell awk '/Version:/ { print $$2 }' $(PKGNAME).spec)
|
|
|
|
RELEASE = $(shell awk '/Release:/ { print $$2 }' $(PKGNAME).spec | sed -e 's|%.*$$||g')
|
2013-02-28 19:53:34 +00:00
|
|
|
TAG = lorax-$(VERSION)-$(RELEASE)
|
2010-12-02 12:36:22 +00:00
|
|
|
|
2018-10-30 19:24:19 +00:00
|
|
|
IMAGE_RELEASE = $(shell awk -F: '/FROM/ { print $$2}' Dockerfile.test)
|
2010-12-02 12:36:22 +00:00
|
|
|
|
2019-04-12 18:17:28 +00:00
|
|
|
ifeq ($(TEST_OS),)
|
2019-11-06 14:50:47 +00:00
|
|
|
OS_ID = $(shell awk -F= '/^ID/ {print $$2}' /etc/os-release)
|
|
|
|
OS_VERSION = $(shell awk -F= '/^VERSION_ID/ {print $$2}' /etc/os-release)
|
|
|
|
TEST_OS = $(OS_ID)-$(OS_VERSION)
|
2019-04-12 18:17:28 +00:00
|
|
|
endif
|
|
|
|
export TEST_OS
|
|
|
|
VM_IMAGE=$(CURDIR)/test/images/$(TEST_OS)
|
|
|
|
|
2019-11-21 11:25:00 +00:00
|
|
|
ifeq ($(REPOS_DIR),)
|
|
|
|
REPOS_DIR = /etc/yum.repos.d
|
|
|
|
endif
|
|
|
|
|
2010-12-02 12:36:22 +00:00
|
|
|
default: all
|
2008-10-05 05:51:17 +00:00
|
|
|
|
2018-05-11 16:21:12 +00:00
|
|
|
src/composer/version.py: lorax.spec
|
|
|
|
echo "num = '$(VERSION)-$(RELEASE)'" > src/composer/version.py
|
|
|
|
|
2011-10-24 22:49:39 +00:00
|
|
|
src/pylorax/version.py: lorax.spec
|
|
|
|
echo "num = '$(VERSION)-$(RELEASE)'" > src/pylorax/version.py
|
|
|
|
|
2018-05-11 16:21:12 +00:00
|
|
|
all: src/pylorax/version.py src/composer/version.py
|
2008-10-05 05:51:17 +00:00
|
|
|
$(PYTHON) setup.py build
|
|
|
|
|
2010-12-02 12:36:22 +00:00
|
|
|
install: all
|
2018-09-16 07:49:51 +00:00
|
|
|
$(PYTHON) setup.py install --root=$(DESTDIR) --prefix=$(PREFIX)
|
2013-07-26 22:01:14 +00:00
|
|
|
mkdir -p $(DESTDIR)/$(mandir)/man1
|
2019-10-09 22:48:34 +00:00
|
|
|
install -m 644 docs/man/*.1 $(DESTDIR)/$(mandir)/man1
|
2018-07-31 13:39:38 +00:00
|
|
|
mkdir -p $(DESTDIR)/etc/bash_completion.d
|
2018-10-08 16:23:47 +00:00
|
|
|
install -m 644 etc/bash_completion.d/composer-cli $(DESTDIR)/etc/bash_completion.d
|
2008-10-05 05:51:17 +00:00
|
|
|
|
2014-05-08 18:43:00 +00:00
|
|
|
check:
|
|
|
|
@echo "*** Running pylint ***"
|
2015-05-08 23:20:39 +00:00
|
|
|
PYTHONPATH=$(PYTHONPATH):./src/ ./tests/pylint/runpylint.py
|
2014-05-08 18:43:00 +00:00
|
|
|
|
2017-10-05 12:44:39 +00:00
|
|
|
test:
|
|
|
|
@echo "*** Running tests ***"
|
2020-10-06 17:24:43 +00:00
|
|
|
PYTHONPATH=$(PYTHONPATH):./src/ $(PYTHON) -X dev -m pytest -v --cov-branch \
|
2020-09-30 21:53:29 +00:00
|
|
|
--cov=pylorax --cov=composer \
|
|
|
|
./tests/pylorax/ ./tests/composer/
|
2018-01-12 16:57:55 +00:00
|
|
|
|
2017-10-05 12:44:39 +00:00
|
|
|
coverage3 report -m
|
|
|
|
[ -f "/usr/bin/coveralls" ] && [ -n "$(COVERALLS_REPO_TOKEN)" ] && coveralls || echo
|
2018-09-19 12:00:25 +00:00
|
|
|
|
2019-06-24 18:19:12 +00:00
|
|
|
test_cli:
|
|
|
|
sudo -E ./tests/test_cli.sh
|
|
|
|
|
2019-10-09 22:48:34 +00:00
|
|
|
test_mkksiso:
|
|
|
|
sudo -E ./tests/mkksiso/test_mkksiso.sh
|
|
|
|
|
2019-01-16 09:23:22 +00:00
|
|
|
clean_cloud_envs:
|
2019-01-25 16:52:21 +00:00
|
|
|
# clean beakerlib logs from previous executions
|
|
|
|
sudo rm -rf /var/tmp/beakerlib-*/
|
2019-01-16 09:23:22 +00:00
|
|
|
sudo -E ./tests/cleanup/remove_old_objects_aws.sh
|
2019-01-15 13:30:46 +00:00
|
|
|
sudo -E ./tests/cleanup/remove_old_objects_openstack.sh
|
2019-01-25 14:07:33 +00:00
|
|
|
sudo -E ./tests/cleanup/remove_old_objects_azure.sh
|
2019-02-21 14:28:48 +00:00
|
|
|
sudo -E ./tests/cleanup/remove_old_objects_vmware.sh
|
2019-01-25 16:52:21 +00:00
|
|
|
# make sure all cleanup scripts finished successfully
|
|
|
|
sudo sh -c 'grep RESULT_STRING /var/tmp/beakerlib-*/TestResults | grep -v PASS && exit 1 || exit 0'
|
2019-01-16 09:23:22 +00:00
|
|
|
|
2008-10-05 05:51:17 +00:00
|
|
|
clean:
|
2011-10-24 22:49:39 +00:00
|
|
|
-rm -rf build src/pylorax/version.py
|
2018-05-11 16:21:12 +00:00
|
|
|
-rm -rf build src/composer/version.py
|
2010-10-12 16:23:29 +00:00
|
|
|
|
2010-12-02 12:36:22 +00:00
|
|
|
tag:
|
|
|
|
git tag -f $(TAG)
|
|
|
|
|
2015-04-08 21:02:26 +00:00
|
|
|
docs:
|
2018-10-24 17:06:12 +00:00
|
|
|
$(MAKE) -C docs apidoc html man
|
2015-04-08 21:02:26 +00:00
|
|
|
|
2019-03-26 22:46:03 +00:00
|
|
|
# This is needed to reset the ownership of the new docs files after they are created in a container
|
|
|
|
set-docs-owner:
|
|
|
|
chown -R $(LOCAL_UID):$(LOCAL_GID) docs/
|
|
|
|
|
2013-08-01 16:48:28 +00:00
|
|
|
archive:
|
2010-12-02 12:36:22 +00:00
|
|
|
@git archive --format=tar --prefix=$(PKGNAME)-$(VERSION)/ $(TAG) > $(PKGNAME)-$(VERSION).tar
|
2019-04-12 18:17:28 +00:00
|
|
|
@gzip -f $(PKGNAME)-$(VERSION).tar
|
2013-02-28 20:11:05 +00:00
|
|
|
@echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz"
|
2010-10-19 15:35:50 +00:00
|
|
|
|
2013-08-01 16:48:28 +00:00
|
|
|
dist: tag archive
|
|
|
|
scp $(PKGNAME)-$(VERSION).tar.gz fedorahosted.org:lorax
|
|
|
|
|
2019-04-12 18:17:28 +00:00
|
|
|
srpm: archive $(PKGNAME).spec
|
|
|
|
rpmbuild -bs \
|
|
|
|
--define "_sourcedir $(CURDIR)" \
|
|
|
|
--define "_srcrpmdir $(CURDIR)" \
|
|
|
|
lorax.spec
|
|
|
|
|
2010-12-02 12:36:22 +00:00
|
|
|
local:
|
2013-02-28 20:11:05 +00:00
|
|
|
@rm -rf $(PKGNAME)-$(VERSION).tar.gz
|
|
|
|
@rm -rf /var/tmp/$(PKGNAME)-$(VERSION)
|
|
|
|
@dir=$$PWD; cp -a $$dir /var/tmp/$(PKGNAME)-$(VERSION)
|
|
|
|
@rm -rf /var/tmp/$(PKGNAME)-$(VERSION)/.git
|
|
|
|
@dir=$$PWD; cd /var/tmp; tar --gzip -cSpf $$dir/$(PKGNAME)-$(VERSION).tar.gz $(PKGNAME)-$(VERSION)
|
|
|
|
@rm -rf /var/tmp/$(PKGNAME)-$(VERSION)
|
|
|
|
@echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz"
|
2015-07-21 20:24:21 +00:00
|
|
|
|
2018-10-30 19:24:19 +00:00
|
|
|
test-in-copy:
|
2020-11-17 18:58:13 +00:00
|
|
|
rsync -a --exclude=.git /lorax-ro/ /lorax/
|
2019-06-24 18:19:12 +00:00
|
|
|
make -C /lorax/ $(RUN_TESTS)
|
2018-11-14 01:06:40 +00:00
|
|
|
cp /lorax/.coverage /test-results/
|
2018-10-30 19:24:19 +00:00
|
|
|
|
2021-03-04 00:32:47 +00:00
|
|
|
test-in-docker: test-in-podman
|
|
|
|
|
|
|
|
test-in-podman:
|
2018-10-30 19:24:19 +00:00
|
|
|
sudo $(DOCKER) build -t welder/lorax-tests:$(IMAGE_RELEASE) -f Dockerfile.test .
|
2019-02-25 22:37:57 +00:00
|
|
|
@mkdir -p `pwd`/.test-results
|
2019-06-24 18:19:12 +00:00
|
|
|
sudo $(DOCKER) run --rm -it -v `pwd`/.test-results/:/test-results \
|
|
|
|
-v `pwd`:/lorax-ro:ro --security-opt label=disable \
|
|
|
|
--env RUN_TESTS="$(RUN_TESTS)" \
|
|
|
|
welder/lorax-tests:$(IMAGE_RELEASE) make test-in-copy
|
2018-04-26 07:20:55 +00:00
|
|
|
|
2021-03-04 00:32:47 +00:00
|
|
|
|
|
|
|
docs-in-docker: docs-in-podman
|
|
|
|
|
|
|
|
docs-in-podman:
|
2019-03-26 22:46:03 +00:00
|
|
|
sudo $(DOCKER) run -it --rm -v `pwd`:/lorax-ro:ro \
|
|
|
|
-v `pwd`/docs/:/lorax-ro/docs/ \
|
|
|
|
--env LORAX_VERSION=$(DOCS_VERSION) \
|
|
|
|
--env LOCAL_UID=`id -u` --env LOCAL_GID=`id -g` \
|
|
|
|
--security-opt label=disable welder/lorax-tests:$(IMAGE_RELEASE) make docs set-docs-owner
|
2018-09-06 21:08:49 +00:00
|
|
|
|
2017-10-05 12:44:39 +00:00
|
|
|
ci: check test
|
2018-03-15 19:20:22 +00:00
|
|
|
|
2019-04-12 18:17:28 +00:00
|
|
|
$(VM_IMAGE): TAG=HEAD
|
|
|
|
$(VM_IMAGE): srpm bots
|
2019-11-22 11:19:50 +00:00
|
|
|
rm -f $(VM_IMAGE) $(VM_IMAGE).qcow2
|
2019-04-12 18:17:28 +00:00
|
|
|
srpm=$(shell rpm --qf '%{Name}-%{Version}-%{Release}.src.rpm\n' -q --specfile lorax.spec | head -n1) ; \
|
|
|
|
bots/image-customize -v \
|
|
|
|
--resize 20G \
|
|
|
|
--upload $$srpm:/var/tmp \
|
|
|
|
--upload $(CURDIR)/test/vm.install:/var/tmp/vm.install \
|
|
|
|
--upload $(realpath tests):/ \
|
|
|
|
--run-command "chmod +x /var/tmp/vm.install" \
|
2020-07-22 12:43:16 +00:00
|
|
|
--run-command "cd /var/tmp; BACKEND=$(BACKEND) /var/tmp/vm.install $$srpm" \
|
2019-04-12 18:17:28 +00:00
|
|
|
$(TEST_OS)
|
2019-05-31 12:36:32 +00:00
|
|
|
[ -f ~/.config/lorax-test-env ] && bots/image-customize \
|
2019-05-28 11:06:31 +00:00
|
|
|
--upload ~/.config/lorax-test-env:/var/tmp/lorax-test-env \
|
|
|
|
$(TEST_OS) || echo
|
|
|
|
|
2019-04-12 18:17:28 +00:00
|
|
|
|
|
|
|
# convenience target for the above
|
|
|
|
vm: $(VM_IMAGE)
|
|
|
|
echo $(VM_IMAGE)
|
|
|
|
|
2019-10-22 13:03:20 +00:00
|
|
|
# grab all repositories from the host system, overwriting what's inside the VM
|
|
|
|
# and update the image. Mostly used when testing downstream snapshots to make
|
|
|
|
# sure VM_IMAGE is as close as possible to the host!
|
|
|
|
vm-local-repos: vm
|
|
|
|
bots/image-customize -v \
|
2019-11-21 11:25:00 +00:00
|
|
|
--run-command "rm -rf /etc/yum.repos.d" \
|
|
|
|
$(TEST_OS)
|
|
|
|
bots/image-customize -v \
|
|
|
|
--upload $(REPOS_DIR):/etc/yum.repos.d \
|
2019-11-27 11:43:14 +00:00
|
|
|
--run-command "yum -y remove composer-cli $(BACKEND)" \
|
2019-10-22 13:03:20 +00:00
|
|
|
--run-command "yum -y update" \
|
2019-11-27 11:43:14 +00:00
|
|
|
--run-command "yum -y install composer-cli $(BACKEND)" \
|
|
|
|
--run-command "systemctl enable $(BACKEND).socket" \
|
2019-10-22 13:03:20 +00:00
|
|
|
$(TEST_OS)
|
|
|
|
|
2019-04-12 18:17:28 +00:00
|
|
|
vm-reset:
|
|
|
|
rm -f $(VM_IMAGE) $(VM_IMAGE).qcow2
|
|
|
|
|
2019-09-23 15:12:47 +00:00
|
|
|
# checkout Cockpit's bots for standard test VM images and API to launch them
|
|
|
|
# must be from master, as only that has current and existing images; but testvm.py API is stable
|
2019-10-14 12:37:48 +00:00
|
|
|
# support CI testing against a bots change
|
2019-04-12 18:17:28 +00:00
|
|
|
bots:
|
2019-10-14 12:37:48 +00:00
|
|
|
git clone --quiet --reference-if-able $${XDG_CACHE_HOME:-$$HOME/.cache}/cockpit-project/bots https://github.com/cockpit-project/bots.git
|
|
|
|
if [ -n "$$COCKPIT_BOTS_REF" ]; then git -C bots fetch --quiet --depth=1 origin "$$COCKPIT_BOTS_REF"; git -C bots checkout --quiet FETCH_HEAD; fi
|
|
|
|
@echo "checked out bots/ ref $$(git -C bots rev-parse HEAD)"
|
2019-04-12 18:17:28 +00:00
|
|
|
|
2018-11-30 09:11:32 +00:00
|
|
|
.PHONY: ci_after_success
|
|
|
|
ci_after_success:
|
|
|
|
# nothing to do here, but Jenkins expects this to be present, otherwise fails
|
|
|
|
|
2021-03-04 00:32:47 +00:00
|
|
|
.PHONY: docs check test srpm vm vm-reset docs-in-docker docs-in-podman test-in-docker test-in-podman
|