mirror of
https://github.com/JasonN3/build-container-installer.git
synced 2025-12-25 02:47:56 +01:00
Add tests (#76)
This commit is contained in:
parent
3dc05c0efc
commit
3d85c93010
12 changed files with 458 additions and 43 deletions
34
.github/workflows/bot_run_tests.yml
vendored
Normal file
34
.github/workflows/bot_run_tests.yml
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
name: Run tests on PR
|
||||
on: issue_comment
|
||||
|
||||
jobs:
|
||||
pr_commented:
|
||||
name: Check Permissions
|
||||
if: >
|
||||
github.event.issue.pull_request &&
|
||||
contains(github.event.comment.body, '/run tests')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check association
|
||||
run: |
|
||||
allowed=("OWNER" "COLLABORATOR")
|
||||
value="\<${{ github.event.issue.author_association }}\>"
|
||||
|
||||
if [[ ${allowed[@]} =~ $value ]]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run-tests:
|
||||
name: Run Tests
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
statuses: write
|
||||
needs:
|
||||
- pr_commented
|
||||
uses: ./.github/workflows/build-and-test.yml
|
||||
with:
|
||||
pr: ${{ github.event.issue.number }}
|
||||
256
.github/workflows/build-and-test.yml
vendored
256
.github/workflows/build-and-test.yml
vendored
|
|
@ -6,8 +6,16 @@ on:
|
|||
- 'main'
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
pull_request:
|
||||
|
||||
workflow_call:
|
||||
inputs:
|
||||
pr:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
|
@ -20,25 +28,62 @@ env:
|
|||
IMAGE_REPO: 'quay.io/fedora-ostree-desktops'
|
||||
IMAGE_TAG: '39'
|
||||
VARIANT: 'Server'
|
||||
FLATPAK_REMOTE_REFS_DIR: /github/workspace/flatpak_refs
|
||||
FLATPAK_REMOTE_REFS_DIR: flatpak_refs
|
||||
SECURE_BOOT_KEY_URL: 'https://github.com/ublue-os/akmods/raw/main/certs/public_key.der'
|
||||
ENROLLMENT_PASSWORD: 'container-installer'
|
||||
|
||||
jobs:
|
||||
build-container:
|
||||
if: >
|
||||
github.event_name == 'push' ||
|
||||
github.event_name == 'issue_comment' ||
|
||||
( github.event_name == 'pull_request' &&
|
||||
contains(github.event.pull_request.labels.*.name, 'auto-test') )
|
||||
name: Build Container Image
|
||||
env:
|
||||
JOB_NAME: Build Container Image
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
statuses: write
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
fetch-tags: 'true'
|
||||
|
||||
- name: Switch branch
|
||||
if: inputs.pr
|
||||
env:
|
||||
GITHUB_USER: ${{ github.actor }}
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y hub
|
||||
hub pr checkout ${{ inputs.pr }}
|
||||
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_ENV
|
||||
|
||||
- name: Get Current Job Log URL
|
||||
if: inputs.pr && always()
|
||||
uses: Tiryoh/gha-jobid-action@v1
|
||||
id: jobs
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
job_name: "Run Tests / ${{ env.JOB_NAME }}"
|
||||
|
||||
- name: Set status
|
||||
if: inputs.pr && always()
|
||||
uses: myrotvorets/set-commit-status-action@v2.0.1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
context: ${{ env.JOB_NAME }}
|
||||
sha: ${{ env.sha }}
|
||||
targetUrl: ${{ steps.jobs.outputs.html_url }}
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
|
|
@ -66,15 +111,28 @@ jobs:
|
|||
tags: ${{ steps.build-image.outputs.tags }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ github.token }}
|
||||
|
||||
- name: Set status
|
||||
if: inputs.pr && always()
|
||||
uses: myrotvorets/set-commit-status-action@v2.0.1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
context: ${{ env.JOB_NAME }}
|
||||
sha: ${{ env.sha }}
|
||||
targetUrl: ${{ steps.jobs.outputs.html_url }}
|
||||
|
||||
build-and-push-iso:
|
||||
name: Build ISO
|
||||
env:
|
||||
JOB_NAME: Build ISO
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build-container
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
statuses: write
|
||||
continue-on-error: false
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
|
@ -88,8 +146,39 @@ jobs:
|
|||
iso_name-39: ${{ steps.save_output.outputs.iso_name-39 }}
|
||||
iso_name-40: ${{ steps.save_output.outputs.iso_name-40 }}
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Switch branch
|
||||
if: inputs.pr
|
||||
env:
|
||||
GITHUB_USER: ${{ github.actor }}
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y hub
|
||||
hub pr checkout ${{ inputs.pr }}
|
||||
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_ENV
|
||||
|
||||
- name: Get Current Job Log URL
|
||||
if: inputs.pr && always()
|
||||
uses: Tiryoh/gha-jobid-action@v1
|
||||
id: jobs
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
job_name: "Run Tests / ${{ env.JOB_NAME }}"
|
||||
|
||||
- name: Set status
|
||||
if: inputs.pr && always()
|
||||
uses: myrotvorets/set-commit-status-action@v2.0.1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
context: ${{ env.JOB_NAME }}
|
||||
sha: ${{ env.sha }}
|
||||
targetUrl: ${{ steps.jobs.outputs.html_url }}
|
||||
|
||||
- name: Lowercase Registry
|
||||
id: registry_case
|
||||
|
|
@ -115,10 +204,10 @@ jobs:
|
|||
image_tag: ${{ matrix.version }}
|
||||
version: ${{ matrix.version }}
|
||||
variant: ${{ env.VARIANT }}
|
||||
flatpak_remote_refs_dir: ${{ env.FLATPAK_REMOTE_REFS_DIR }}
|
||||
flatpak_remote_refs_dir: /github/workspace/${{ env.FLATPAK_REMOTE_REFS_DIR }}
|
||||
secure_boot_key_url: ${{ env.SECURE_BOOT_KEY_URL }}
|
||||
enrollment_password: ${{ env.ENROLLMENT_PASSWORD }}
|
||||
iso_name: ${{ env.IMAGE_NAME }}-${{ matrix.version }}-${{ matrix.version }}.iso
|
||||
iso_name: ${{ env.IMAGE_NAME }}-${{ matrix.version }}-${{ github.event.pull_request.number || github.ref }}.iso
|
||||
|
||||
- name: Save output
|
||||
id: save_output
|
||||
|
|
@ -139,14 +228,26 @@ jobs:
|
|||
compression-level: 0
|
||||
overwrite: true
|
||||
|
||||
test-qemu:
|
||||
- name: Set status
|
||||
if: inputs.pr && always()
|
||||
uses: myrotvorets/set-commit-status-action@v2.0.1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
context: ${{ env.JOB_NAME }}
|
||||
sha: ${{ env.sha }}
|
||||
targetUrl: ${{ steps.jobs.outputs.html_url }}
|
||||
|
||||
test-iso:
|
||||
name: Test ISO
|
||||
env:
|
||||
JOB_NAME: Test ISO
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build-and-push-iso
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
statuses: write
|
||||
continue-on-error: false
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
|
@ -156,21 +257,46 @@ jobs:
|
|||
- 39
|
||||
- 40
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Switch branch
|
||||
if: inputs.pr
|
||||
env:
|
||||
GITHUB_USER: ${{ github.actor }}
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y hub
|
||||
hub pr checkout ${{ inputs.pr }}
|
||||
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_ENV
|
||||
|
||||
- name: Get Current Job Log URL
|
||||
if: inputs.pr && always()
|
||||
uses: Tiryoh/gha-jobid-action@v1
|
||||
id: jobs
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
job_name: "Run Tests / ${{ env.JOB_NAME }}"
|
||||
|
||||
- name: Set status
|
||||
if: inputs.pr && always()
|
||||
uses: myrotvorets/set-commit-status-action@v2.0.1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
context: ${{ env.JOB_NAME }}
|
||||
sha: ${{ env.sha }}
|
||||
targetUrl: ${{ steps.jobs.outputs.html_url }}
|
||||
|
||||
- name: Install test tools
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y make
|
||||
sudo make install-test-deps PACKAGE_MANAGER=apt-get
|
||||
|
||||
- name: Create disk
|
||||
run: |
|
||||
qemu-img create -f qcow2 disk.qcow2 50G
|
||||
|
||||
- name: Download generated ISO
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
|
|
@ -195,8 +321,83 @@ jobs:
|
|||
SECURE_BOOT_KEY_URL=${{ env.SECURE_BOOT_KEY_URL }} \
|
||||
ENROLLMENT_PASSWORD=${{ env.ENROLLMENT_PASSWORD }}
|
||||
|
||||
- name: Set status
|
||||
if: inputs.pr && always()
|
||||
uses: myrotvorets/set-commit-status-action@v2.0.1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
context: ${{ env.JOB_NAME }}
|
||||
sha: ${{ env.sha }}
|
||||
targetUrl: ${{ steps.jobs.outputs.html_url }}
|
||||
|
||||
test-deployment:
|
||||
name: Test deployment
|
||||
env:
|
||||
JOB_NAME: Test deployment
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build-and-push-iso
|
||||
permissions:
|
||||
contents: read
|
||||
statuses: write
|
||||
continue-on-error: false
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
version:
|
||||
- 38
|
||||
- 39
|
||||
- 40
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Switch branch
|
||||
if: inputs.pr
|
||||
env:
|
||||
GITHUB_USER: ${{ github.actor }}
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y hub
|
||||
hub pr checkout ${{ inputs.pr }}
|
||||
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_ENV
|
||||
|
||||
- name: Get Current Job Log URL
|
||||
if: inputs.pr && always()
|
||||
uses: Tiryoh/gha-jobid-action@v1
|
||||
id: jobs
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
job_name: "Run Tests / ${{ env.JOB_NAME }}"
|
||||
|
||||
- name: Set status
|
||||
if: inputs.pr && always()
|
||||
uses: myrotvorets/set-commit-status-action@v2.0.1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
context: ${{ env.JOB_NAME }}
|
||||
sha: ${{ env.sha }}
|
||||
targetUrl: ${{ steps.jobs.outputs.html_url }}
|
||||
|
||||
- name: Install test tools
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y make
|
||||
sudo make install-test-deps PACKAGE_MANAGER=apt-get
|
||||
|
||||
- name: Download generated ISO
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ${{ needs['build-and-push-iso']['outputs'][format('iso_name-{0}', matrix.version)] }}
|
||||
|
||||
- name: Add Kickstart and Grub options to ISO
|
||||
run: |
|
||||
mv ${{ needs['build-and-push-iso']['outputs'][format('iso_name-{0}', matrix.version)] }} deploy.iso
|
||||
sudo mkdir /mnt/iso || true
|
||||
sudo mount -o loop deploy.iso /mnt/iso
|
||||
cp /mnt/iso/boot/grub2/grub.cfg grub.cfg
|
||||
|
|
@ -225,9 +426,13 @@ jobs:
|
|||
-end
|
||||
EOF
|
||||
|
||||
- name: Create VM disk
|
||||
run: |
|
||||
qemu-img create -f qcow2 disk.qcow2 50G
|
||||
|
||||
- name: Install the test VM
|
||||
run: |
|
||||
timeout 1h qemu-system-x86_64 -name "Anaconda" -boot d -m 4096 -cpu qemu64 -display none -cdrom test.iso -smp 2 -hda disk.qcow2 -serial telnet:localhost:4321,server,nowait & QEMU_PID=$!
|
||||
timeout 1h qemu-system-x86_64 -name "Anaconda" -boot d -m 4096 -cpu qemu64 -display none -cdrom test.iso -smp 2 -hda disk.qcow2 -serial telnet:localhost:4321,server=on,wait=off & QEMU_PID=$!
|
||||
echo "PID: $QEMU_PID"
|
||||
timeout 1m bash -c "while ! (echo > /dev/tcp/127.0.0.1/4321); do sleep 0.1; done"
|
||||
(nc localhost 4321 | tee vm.stdout) &
|
||||
|
|
@ -243,12 +448,12 @@ jobs:
|
|||
mkfifo vm.stdin
|
||||
qemu-system-x86_64 -name "Anaconda" \
|
||||
-m 4096 -cpu qemu64 -display none -smp 2 \
|
||||
-chardev socket,path=/tmp/qga.sock,server,nowait,id=qga0 \
|
||||
-chardev socket,path=/tmp/qga.sock,server=on,wait=off,id=qga0 \
|
||||
-device e1000,netdev=net0 \
|
||||
-netdev user,id=net0,hostfwd=tcp::${VM_PORT}-:22 \
|
||||
-device virtio-serial \
|
||||
-device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 \
|
||||
-boot c -hda disk.qcow2 -serial telnet:localhost:4321,server,nowait & export QEMU_PID=$!
|
||||
-boot c -hda disk.qcow2 -serial telnet:localhost:4321,server=on,wait=off & export QEMU_PID=$!
|
||||
echo "PID: $QEMU_PID"
|
||||
|
||||
timeout 1m bash -c "while ! (echo > /dev/tcp/127.0.0.1/4321); do sleep 0.1; done"
|
||||
|
|
@ -263,5 +468,24 @@ jobs:
|
|||
|
||||
echo "VM ready for tests at IP ${VM_IP}:${VM_PORT}"
|
||||
|
||||
make test-vm VM_IP=${VM_IP} VM_PORT=${VM_PORT} VM_USER=${VM_USER} VM_PASS=${VM_PASS}
|
||||
make test-vm VM_IP=${VM_IP} VM_PORT=${VM_PORT} VM_USER=${VM_USER} VM_PASS=${VM_PASS} \
|
||||
ARCH=${{ env.ARCH}} \
|
||||
IMAGE_NAME=${{ env.IMAGE_NAME}} \
|
||||
IMAGE_REPO=${{ env.IMAGE_REPO}} \
|
||||
IMAGE_TAG=${{ matrix.version }} \
|
||||
VERSION=${{ matrix.version }} \
|
||||
VARIANT=${{ env.VARIANT }} \
|
||||
FLATPAK_REMOTE_REFS_DIR=${{ env.FLATPAK_REMOTE_REFS_DIR }} \
|
||||
SECURE_BOOT_KEY_URL=${{ env.SECURE_BOOT_KEY_URL }} \
|
||||
ENROLLMENT_PASSWORD=${{ env.ENROLLMENT_PASSWORD }}
|
||||
kill $QEMU_PID
|
||||
|
||||
- name: Set status
|
||||
if: inputs.pr && always()
|
||||
uses: myrotvorets/set-commit-status-action@v2.0.1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
context: ${{ env.JOB_NAME }}
|
||||
sha: ${{ env.sha }}
|
||||
targetUrl: ${{ steps.jobs.outputs.html_url }}
|
||||
|
|
|
|||
27
.github/workflows/variables.yml
vendored
Normal file
27
.github/workflows/variables.yml
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
name: Repo Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
tags:
|
||||
- 'v*'
|
||||
pull_request:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
variables:
|
||||
name: Check variables are listed
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Run test
|
||||
run: |
|
||||
/bin/bash tests/repo/vars.sh
|
||||
51
Makefile
51
Makefile
|
|
@ -20,9 +20,12 @@ FLATPAK_REMOTE_REFS_DIR =
|
|||
# Secure boot
|
||||
ENROLLMENT_PASSWORD =
|
||||
SECURE_BOOT_KEY_URL =
|
||||
|
||||
###################
|
||||
# Hidden vars
|
||||
|
||||
# Cache
|
||||
DNF_CACHE =
|
||||
|
||||
PACKAGE_MANAGER = dnf
|
||||
|
||||
# Functions
|
||||
|
|
@ -32,6 +35,20 @@ PACKAGE_MANAGER = dnf
|
|||
get_templates = $(shell ls lorax_templates/$(1)_*.tmpl) \
|
||||
$(foreach file,$(notdir $(shell ls lorax_templates/scripts/post/$(1)_*)),lorax_templates/post_$(file).tmpl)
|
||||
|
||||
# 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
|
||||
|
||||
# Converts a post script to a template
|
||||
# $1 = script to convert
|
||||
# $2 = file on ISO to write
|
||||
|
|
@ -217,8 +234,10 @@ install-test-deps:
|
|||
|
||||
test: test-iso test-vm
|
||||
|
||||
test-repo:
|
||||
bash tests/repo/vars.sh
|
||||
|
||||
test-iso:
|
||||
$(eval _TESTS = $(filter-out README.md,$(shell ls tests/iso)))
|
||||
$(eval _VARS = VERSION FLATPAK_REMOTE_NAME _FLATPAK_REPO_URL)
|
||||
|
||||
sudo modprobe loop
|
||||
|
|
@ -227,21 +246,10 @@ test-iso:
|
|||
sudo mount -t squashfs -o loop /mnt/iso/images/install.img /mnt/install
|
||||
|
||||
# install tests
|
||||
chmod +x $(foreach test,$(filter install_%,$(_TESTS)),tests/iso/$(test))
|
||||
for test in $(_TESTS); \
|
||||
do \
|
||||
$(foreach var,$(_VARS),$(var)=$($(var))) ./tests/iso/$${test}; \
|
||||
done
|
||||
|
||||
$(call run_tests,iso,install)
|
||||
|
||||
# flapak tests
|
||||
if [ -n "$(FLATPAK_REMOTE_REFS)" ]; \
|
||||
then \
|
||||
chmod +x $(foreach test,$(filter flatpak_%,$(_TESTS)),tests/iso/$(test)); \
|
||||
for test in $(_TESTS); \
|
||||
do \
|
||||
$(foreach var,$(_VARS),$(var)=$($(var))) ./tests/iso/$${test}; \
|
||||
done; \
|
||||
fi
|
||||
if [ -n "$(FLATPAK_REMOTE_REFS)" ]; then $(call run_tests,iso,flatpak); fi
|
||||
|
||||
# Cleanup
|
||||
sudo umount /mnt/install
|
||||
|
|
@ -259,9 +267,14 @@ ansible_inventory:
|
|||
echo " ansible_ssh_common_args: '-o StrictHostKeyChecking=no'" >> ansible_inventory
|
||||
|
||||
test-vm: ansible_inventory
|
||||
$(eval _VARS = IMAGE_REPO IMAGE_NAME IMAGE_TAG)
|
||||
|
||||
ansible -i ansible_inventory -m ansible.builtin.wait_for_connection vm
|
||||
$(eval _TESTS = $(filter-out README.md,$(shell ls tests/vm)))
|
||||
chmod +x $(foreach test,$(_TESTS),tests/vm/$(test))
|
||||
for test in $(_TESTS); do ./tests/vm/$${test}; done
|
||||
|
||||
# install tests
|
||||
$(call run_tests,vm,install)
|
||||
|
||||
# flapak tests
|
||||
if [ -n "$(FLATPAK_REMOTE_REFS)" ]; then $(call run_tests,vm,flatpak); fi
|
||||
|
||||
.PHONY: clean install-deps install-test-deps test test-iso test-vm
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ The following variables can be used to customize the created ISO.
|
|||
| image_repo | Repository containing the source container image | quay.io/fedora-ostree-desktops | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| image_tag | Tag of the source container image | *VERSION* | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| iso_name | Name of the ISO you wish to output when completed | build/deploy.iso | :white_check_mark: | :x: | :x: |
|
||||
| repos | List of repo files for Lorax to use | /etc/yum.repos.d/*.repo | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| rootfs_size | The size (in GiB) for the squashfs runtime volume | 2 | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| secure_boot_key_url | Secure boot key that is installed from URL location\*\* | \[empty\] | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| variant | Source container variant\* | Server | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| version | Fedora version of installer to build | 39 | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
|
|
|
|||
16
action.yml
16
action.yml
|
|
@ -62,6 +62,11 @@ inputs:
|
|||
description: "Name of the resulting ISO. Relative paths are relative to github.workspace"
|
||||
required: false
|
||||
default: build/deploy.iso
|
||||
repos:
|
||||
description: List of repo files for Lorax to use
|
||||
required: false
|
||||
rootfs_size:
|
||||
description: The size (in GiB) for the squashfs runtime volume
|
||||
secure_boot_key_url:
|
||||
description: Secure boot key that is installed from URL location
|
||||
required: false
|
||||
|
|
@ -131,16 +136,19 @@ runs:
|
|||
ACTION_REF: ${{ github.action_ref }}
|
||||
shell: bash
|
||||
run: |
|
||||
image="ghcr.io/jasonn3/build-container-installer"
|
||||
# Check if running inside of the action repo
|
||||
if [[ -z "${ACTION_REPO}" || "${ACTION_REPO}" == "${{ github.repository }}" ]]
|
||||
then
|
||||
if [[ "${{ github.ref_name }}" =~ (.*)/merge ]]
|
||||
then tag=pr-${BASH_REMATCH[1]}
|
||||
then
|
||||
tag="pr-${BASH_REMATCH[1]}"
|
||||
image="docker.io/jasonn3/build-container-installer"
|
||||
else
|
||||
tag=${{ github.ref_name }}
|
||||
tag="${{ github.ref_name }}"
|
||||
fi
|
||||
else
|
||||
tag=${ACTION_REF}
|
||||
tag="${ACTION_REF}"
|
||||
fi
|
||||
if [[ "${{ inputs.enable_cache_dnf }}" == "true" ]]
|
||||
then
|
||||
|
|
@ -167,7 +175,7 @@ runs:
|
|||
vars="${vars} FLATPAK_REMOTE_REFS_DIR=\"${{ inputs.flatpak_remote_refs_dir }}\""
|
||||
fi
|
||||
fi
|
||||
docker run --privileged --volume ${{ github.workspace }}:/github/workspace/ ${cache} ghcr.io/jasonn3/build-container-installer:${tag} \
|
||||
docker run --privileged --volume ${{ github.workspace }}:/github/workspace/ ${cache} ${image}:${tag} \
|
||||
ADDITIONAL_TEMPLATES="${{ inputs.additional_templates }}" \
|
||||
ARCH="${{ inputs.arch }}" \
|
||||
DNF_CACHE="/cache/dnf" \
|
||||
|
|
|
|||
|
|
@ -6,6 +6,3 @@ replace "flatpak_manager\.add_remote\(\".*\", \".*\"\)" "flatpak_manager.add_rem
|
|||
replace "flatpak_manager\.replace_installed_refs_remote\(\".*\"\)" "flatpak_manager.replace_installed_refs_remote(\"${flatpak_remote_name}\")" /usr/lib64/python*/site-packages/pyanaconda/modules/payloads/payload/rpm_ostree/flatpak_installation.py
|
||||
% endif
|
||||
|
||||
%if flatpak_remote_name != 'fedora':
|
||||
systemctl disable flatpak-add-fedora-repos.service
|
||||
% endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<%page args="_flatpak_repo_gpg"/>
|
||||
<%page args="_flatpak_repo_gpg, flatpak_remote_name"/>
|
||||
|
||||
if [[ -d /ostree/deploy/default/var/lib/flatpak/repo ]]
|
||||
then
|
||||
|
|
@ -9,3 +9,8 @@ then
|
|||
else
|
||||
echo "Could not find Flatpaks repo"
|
||||
fi
|
||||
|
||||
if [[ "${flatpak_remote_name}" != 'fedora' ]]
|
||||
then
|
||||
systemctl disable flatpak-add-fedora-repos.service
|
||||
fi
|
||||
|
|
|
|||
39
tests/repo/vars.sh
Normal file
39
tests/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}
|
||||
16
tests/vm/flatpak_fedora_repo_disabled.yml
Normal file
16
tests/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
tests/vm/flatpak_installed.yml
Normal file
25
tests/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'
|
||||
25
tests/vm/install_image_source.yml
Normal file
25
tests/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