mirror of
https://github.com/JasonN3/build-container-installer.git
synced 2025-12-25 10:57:55 +01:00
split make file
This commit is contained in:
parent
1de61a8083
commit
ff74117fac
24 changed files with 249 additions and 172 deletions
14
test/Makefile
Normal file
14
test/Makefile
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
TESTS=$(filter-out README.md Makefile,$(wildcard *)) $(filter-out README.md Makefile,$(wildcard */*))
|
||||
|
||||
all: $(TESTS)
|
||||
|
||||
$(TESTS):
|
||||
$(eval DIR=$(firstword $(subst /, ,$@)))
|
||||
$(eval TARGET=$(subst $(DIR)/,,$@))
|
||||
$(MAKE) -w -C $(DIR) $(TARGET)
|
||||
|
||||
install-deps:
|
||||
if [ "$(PACKAGE_MANAGER)" =~ apt.* ]; then $(PACKAGE_MANAGER) update; fi
|
||||
$(PACKAGE_MANAGER) install -y qemu qemu-utils xorriso unzip qemu-system-x86 netcat socat jq isomd5sum ansible make coreutils squashfs-tools
|
||||
|
||||
.PHONY: all $(TESTS)
|
||||
28
test/iso/Makefile
Normal file
28
test/iso/Makefile
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
ISO_NAME=deploy.iso
|
||||
ISO_TESTS=$(filter-out README.md Makefile,$(wildcard *)))
|
||||
|
||||
all: $(ISO_TESTS)
|
||||
|
||||
$(ISO_TESTS):
|
||||
chmod +x $@
|
||||
ISO=../../$(ISO_NAME) ./$@
|
||||
|
||||
prep:
|
||||
$(eval _VARS = VERSION FLATPAK_REMOTE_NAME _FLATPAK_REPO_URL)
|
||||
|
||||
sudo modprobe loop
|
||||
sudo mkdir /mnt/iso /mnt/install
|
||||
sudo mount -o loop deploy.iso /mnt/iso
|
||||
sudo mount -t squashfs -o loop /mnt/iso/images/install.img /mnt/install
|
||||
|
||||
# install tests
|
||||
$(call run_tests,iso,install)
|
||||
|
||||
# flapak tests
|
||||
if [ -n "$(FLATPAK_REMOTE_REFS)" ]; then $(call run_tests,iso,flatpak); fi
|
||||
|
||||
# Cleanup
|
||||
sudo umount /mnt/install
|
||||
sudo umount /mnt/iso
|
||||
|
||||
.PHONY: all $(ISO_TESTS)
|
||||
1
test/iso/README.md
Normal file
1
test/iso/README.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
Place scripts that will test the ISO. The ISO file will be passed as the first argument
|
||||
37
test/iso/flatpak_repo_updated.sh
Normal file
37
test/iso/flatpak_repo_updated.sh
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash
|
||||
|
||||
add_line=$(grep flatpak_manager.add_remote /mnt/install/usr/lib64/python*/site-packages/pyanaconda/modules/payloads/payload/rpm_ostree/flatpak_installation.py)
|
||||
|
||||
add_line_repo=$(echo ${add_line} | grep ${FLATPAK_REMOTE_NAME})
|
||||
add_line_url=$(echo ${add_line} | grep ${_FLATPAK_REPO_URL})
|
||||
|
||||
result=0
|
||||
if [ -z "${add_line_repo}" ]
|
||||
then
|
||||
echo "Repo name not updated on add_remote line"
|
||||
result=1
|
||||
else
|
||||
echo "Repo name found on add_remote line"
|
||||
fi
|
||||
|
||||
if [ -z "${add_line_url}" ]
|
||||
then
|
||||
echo "Repo url not updated on add_remote line"
|
||||
result=1
|
||||
else
|
||||
echo "Repo url found on add_remote line"
|
||||
fi
|
||||
|
||||
replace_line=$(grep flatpak_manager.replace_installed_refs_remote /mnt/install/usr/lib64/python*/site-packages/pyanaconda/modules/payloads/payload/rpm_ostree/flatpak_installation.py)
|
||||
|
||||
replace_line_repo=$(echo ${replace_line} | grep ${FLATPAK_REMOTE_NAME})
|
||||
|
||||
if [ -z "${replace_line_repo}" ]
|
||||
then
|
||||
echo "Repo name not updated on replace_installed_refs line"
|
||||
result=1
|
||||
else
|
||||
echo "Repo name found on replace_installed_refs line"
|
||||
fi
|
||||
|
||||
exit ${result}
|
||||
6
test/iso/install_hash.sh
Normal file
6
test/iso/install_hash.sh
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
checkisomd5 ${ISO}
|
||||
cd $(dirname ${ISO}) && sha256sum -c $(basename ${ISO})-CHECKSUM
|
||||
14
test/iso/install_os-release.sh
Normal file
14
test/iso/install_os-release.sh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
FOUND_VERSION=$(cat /mnt/install/etc/os-release | grep VERSION_ID | cut -d= -f2)
|
||||
|
||||
if [[ ${FOUND_VERSION} != ${VERSION} ]]
|
||||
then
|
||||
echo "Version mismatch"
|
||||
echo "Expected: ${VERSION}"
|
||||
echo "Found: ${FOUND_VERSION}"
|
||||
exit 1
|
||||
else
|
||||
echo "Correct version found"
|
||||
exit 0
|
||||
fi
|
||||
9
test/repo/Makefile
Normal file
9
test/repo/Makefile
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
REPO_TESTS=$(filter-out README.md Makefile,$(shell ls))
|
||||
|
||||
all: $(REPO_TESTS)
|
||||
|
||||
$(REPO_TESTS):
|
||||
chmod +x $*
|
||||
./$*
|
||||
|
||||
.PHONY: $(REPO_TESTS)
|
||||
39
test/repo/vars.sh
Normal file
39
test/repo/vars.sh
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
|
||||
vars=()
|
||||
|
||||
while read -r line
|
||||
do
|
||||
if ! [[ $line =~ ^# ]]
|
||||
then
|
||||
vars+=$(echo $line | cut -d= -f1 | tr [:upper:] [:lower:])
|
||||
fi
|
||||
if [[ $line =~ ^########## ]]
|
||||
then
|
||||
break
|
||||
fi
|
||||
done < ../../Makefile
|
||||
|
||||
result=0
|
||||
|
||||
for var in $vars
|
||||
do
|
||||
grep "^| ${var}" README.md > /dev/null
|
||||
if [[ $? != 0 ]]
|
||||
then
|
||||
echo "$var not found in README.md"
|
||||
result=1
|
||||
fi
|
||||
done
|
||||
|
||||
for var in $vars
|
||||
do
|
||||
grep "^ ${var}:" action.yml > /dev/null
|
||||
if [[ $? != 0 ]]
|
||||
then
|
||||
echo "$var not found in action.yml"
|
||||
result=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit ${result}
|
||||
47
test/vm/Makefile
Normal file
47
test/vm/Makefile
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
VM_TESTS=$(filter-out README.md,$(shell ls))
|
||||
|
||||
# Get a list of tests for the feature
|
||||
# $1 = test type
|
||||
# $2 = feature
|
||||
run_tests = \
|
||||
tests="$(shell ls tests/$(1)/$(2)_*)"; \
|
||||
if [ -n "$$tests" ]; \
|
||||
then \
|
||||
chmod +x $$tests; \
|
||||
for test in $$tests; \
|
||||
do \
|
||||
$(foreach var,$(_VARS),$(var)=$($(var))) ./$${test}; \
|
||||
RC=$$?; \
|
||||
if [ $$RC != 0 ]; \
|
||||
then \
|
||||
exit $$RC; \
|
||||
fi; \
|
||||
done; \
|
||||
fi
|
||||
|
||||
$(VM_TESTS):
|
||||
$(eval _VARS = IMAGE_REPO IMAGE_NAME IMAGE_TAG)
|
||||
|
||||
ansible -i ansible_inventory -m ansible.builtin.wait_for_connection vm
|
||||
|
||||
# install tests
|
||||
$(call run_tests,vm,install)
|
||||
|
||||
# flapak tests
|
||||
if [ -n "$(FLATPAK_REMOTE_REFS)" ]; \
|
||||
then \
|
||||
$(call run_tests,vm,flatpak); \
|
||||
fi
|
||||
|
||||
ansible_inventory:
|
||||
echo "ungrouped:" > ansible_inventory
|
||||
echo " hosts:" >> ansible_inventory
|
||||
echo " vm:" >> ansible_inventory
|
||||
echo " ansible_host: ${VM_IP}" >> ansible_inventory
|
||||
echo " ansible_port: ${VM_PORT}" >> ansible_inventory
|
||||
echo " ansible_user: ${VM_USER}" >> ansible_inventory
|
||||
echo " ansible_password: ${VM_PASS}" >> ansible_inventory
|
||||
echo " ansible_become_pass: ${VM_PASS}" >> ansible_inventory
|
||||
echo " ansible_ssh_common_args: '-o StrictHostKeyChecking=no'" >> ansible_inventory
|
||||
|
||||
.PHONY: $(VM_TESTS)
|
||||
1
test/vm/README.md
Normal file
1
test/vm/README.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
Place scripts that will test the VM. The VM will be available at ${VM_IP} using username ${VM_USER} and password ${VM_PASS}
|
||||
16
test/vm/flatpak_fedora_repo_disabled.yml
Normal file
16
test/vm/flatpak_fedora_repo_disabled.yml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env -S ansible-playbook -i ./ansible_inventory
|
||||
---
|
||||
- name: Test for installed flatpaks
|
||||
hosts: vm
|
||||
gather_facts: no
|
||||
|
||||
tasks:
|
||||
- name: Collect facts about system services
|
||||
service_facts:
|
||||
register: services_state
|
||||
|
||||
- name: Check that flatpak-add-fedora-repos is disabled
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- services_state['ansible_facts']['services']['flatpak-add-fedora-repos.service']['status'] == 'disabled'
|
||||
fail_msg: 'flatpak-add-fedora-repos.service is not disabled'
|
||||
25
test/vm/flatpak_installed.yml
Normal file
25
test/vm/flatpak_installed.yml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env -S ansible-playbook -i ./ansible_inventory
|
||||
---
|
||||
- name: Test for installed flatpaks
|
||||
hosts: vm
|
||||
gather_facts: no
|
||||
|
||||
tasks:
|
||||
# Verifies that the flatpaks are installed
|
||||
- name: Get list of installed Flatpaks
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
cmd: /usr/bin/flatpak list
|
||||
register: flatpaks
|
||||
|
||||
- name: Check that VLC is installed
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'VLC' in flatpaks.stdout"
|
||||
fail_msg: 'VLC is not installed'
|
||||
|
||||
- name: Check that Firefox is installed
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'Firefox' in flatpaks.stdout"
|
||||
fail_msg: 'Firefox is not installed'
|
||||
12
test/vm/flatpak_update.yml
Normal file
12
test/vm/flatpak_update.yml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env -S ansible-playbook -i ./ansible_inventory
|
||||
---
|
||||
- name: Test for flatpaks
|
||||
hosts: vm
|
||||
gather_facts: no
|
||||
|
||||
tasks:
|
||||
# Verifies that the GPG key is functional
|
||||
- name: Test updating flatpak packages
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
cmd: /usr/bin/flatpak update -y --noninteractive
|
||||
25
test/vm/install_image_source.yml
Normal file
25
test/vm/install_image_source.yml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env -S ansible-playbook -i ./ansible_inventory
|
||||
---
|
||||
- name: Test Container Image source updates
|
||||
hosts: vm
|
||||
gather_facts: no
|
||||
|
||||
tasks:
|
||||
# Get list of origins
|
||||
- name: Get origin
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
cmd: /bin/bash -c "cat /ostree/deploy/default/deploy/*.origin"
|
||||
register: origin
|
||||
|
||||
- name: Get vars
|
||||
ansible.builtin.set_fact:
|
||||
image_repo: "{{ lookup('ansible.builtin.env', 'IMAGE_REPO') }}"
|
||||
image_name: "{{ lookup('ansible.builtin.env', 'IMAGE_NAME') }}"
|
||||
image_tag: "{{ lookup('ansible.builtin.env', 'IMAGE_TAG') }}"
|
||||
|
||||
- name: Tests
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- (image_repo + '/' + image_name + ':' + image_tag) in origin.stdout
|
||||
fail_msg: 'Origin not configured'
|
||||
Loading…
Add table
Add a link
Reference in a new issue