forked from oamg/convert2rhel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
102 lines (84 loc) · 3.06 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
.PHONY: \
force-rebuild \
install \
tests-locally \
lint-locally \
clean \
images \
tests \
lint \
lint-errors \
tests8 \
rpms \
# Project constants
IMAGE ?= convert2rhel
PYTHON ?= python3
PIP ?= pip3
VENV ?= .venv3
PRE_COMMIT ?= pre-commit
SHOW_CAPTURE ?= no
all: clean images tests
install: .install .images .env .pre-commit
.install:
virtualenv --system-site-packages --python $(PYTHON) $(VENV); \
. $(VENV)/bin/activate; \
$(PIP) install --upgrade -r ./requirements/local.centos8.requirements.txt; \
touch $@
.pre-commit:
$(PRE_COMMIT) install --install-hooks
touch $@
.env:
cp .env.example .env
tests-locally: install
. $(VENV)/bin/activate; pytest
lint-locally: install
. $(VENV)/bin/activate; ./scripts/run_lint.sh
clean:
@rm -rf build/ dist/ *.egg-info .pytest_cache/
@find . -name '__pycache__' -exec rm -fr {} +
@find . -name '*.pyc' -exec rm -f {} +
@find . -name '*.pyo' -exec rm -f {} +
images: .images
.images:
@docker build -f Dockerfiles/centos7.Dockerfile -t $(IMAGE)/centos7 .
@docker build -f Dockerfiles/centos8.Dockerfile -t $(IMAGE)/centos8 .
@docker build -f Dockerfiles/rpmbuild.centos8.Dockerfile -t $(IMAGE)/centos8rpmbuild .
@docker build -f Dockerfiles/rpmbuild.centos7.Dockerfile -t $(IMAGE)/centos7rpmbuild .
touch $@
tests: images
@echo 'CentOS Linux 7 tests'
@docker run --user=$(id -ur):$(id -gr) --rm -v $(shell pwd):/data:Z $(IMAGE)/centos7 pytest --show-capture=$(SHOW_CAPTURE)
@echo 'CentOS Linux 8 tests'
@docker run --user=$(id -ur):$(id -gr) --rm -v $(shell pwd):/data:Z $(IMAGE)/centos8 pytest --show-capture=$(SHOW_CAPTURE)
lint: images
@docker run --rm -v $(shell pwd):/data:Z $(IMAGE)/centos8 bash -c "scripts/run_lint.sh"
lint-errors: images
@docker run --rm -v $(shell pwd):/data:Z $(IMAGE)/centos8 bash -c "scripts/run_lint.sh --errors-only"
tests8: images
@docker run --rm -v $(shell pwd):/data:Z $(IMAGE)/centos8 pytest --show-capture=$(SHOW_CAPTURE)
rpms: images
mkdir -p .rpms
rm -frv .rpms/*
docker build -f Dockerfiles/rpmbuild.centos8.Dockerfile -t $(IMAGE)/centos8rpmbuild .
docker build -f Dockerfiles/rpmbuild.centos7.Dockerfile -t $(IMAGE)/centos7rpmbuild .
docker cp $$(docker create $(IMAGE)/centos8rpmbuild):/data/.rpms .
docker cp $$(docker create $(IMAGE)/centos7rpmbuild):/data/.rpms .
docker rm $$(docker ps -aq) -f
copr-build: rpms
mkdir -p .srpms
rm -frv .srpms/*
docker cp $$(docker create $(IMAGE)/centos8rpmbuild):/data/.srpms .
docker cp $$(docker create $(IMAGE)/centos7rpmbuild):/data/.srpms .
docker rm $$(docker ps -aq) -f
copr-cli --config .copr.conf build --nowait @oamg/convert2rhel .srpms/*
update-vms:
virsh start c2r_centos8_template
virsh start c2r_centos7_template
virsh start c2r_oracle8_template
virsh start c2r_oracle7_template
sleep 10
ansible-playbook -v -c community.libvirt.libvirt_qemu -i c2r_centos8_template,c2r_centos7_template,c2r_oracle8_template,c2r_oracle7_template tests/ansible_collections/update_templates.yml
virsh shutdown c2r_centos8_template
virsh shutdown c2r_centos7_template
virsh shutdown c2r_oracle8_template
virsh shutdown c2r_oracle7_template