Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tmt packit automation #28

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
36 changes: 36 additions & 0 deletions .packit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
# See the documentation for more information:
# https://packit.dev/docs/configuration/

upstream_project_url: https://github.com/containers/initoverlayfs
issue_repository: https://github.com/containers/initoverlayfs
specfile_path: initoverlayfs.spec
upstream_package_name: initoverlayfs

update_release: false

srpm_build_deps:
- make

actions:
post-upstream-clone:
- bash -c 'git config --global --add safe.directory $(pwd)'
- bash -c './build-scripts/create-spec.sh'

get-current-version:
- bash -c './build-scripts/version.sh'

jobs:
- job: copr_build
trigger: pull_request
# x86_64 is assumed by default
targets:
dougsland marked this conversation as resolved.
Show resolved Hide resolved
- fedora-39-x86_64
- centos-stream-9

- job: tests
trigger: pull_request
identifier: integration-tiers
tmt_plan: /integration/plans/tier-0
targets:
- fedora-39-x86_64
14 changes: 14 additions & 0 deletions build-scripts/create-spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash -xe
# SPDX-License-Identifier: LGPL-2.1-or-later

VERSION_SCRIPT=$(dirname "$(readlink -f "$0")")/version.sh

VERSION="$(${VERSION_SCRIPT} short)"
RELEASE="$(${VERSION_SCRIPT} release)"

# Set version and release
sed \
-e "s|@VERSION@|${VERSION}|g" \
-e "s|@RELEASE@|${RELEASE}|g" \
< initoverlayfs.spec.in \
> initoverlayfs.spec
29 changes: 29 additions & 0 deletions build-scripts/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash -e
# SPDX-License-Identifier: LGPL-2.1-or-later

# Current version of initoverlayfs
VERSION=0.98
# Specify if build is a official release or a snapshot build
IS_RELEASE=false
# Used for official releases. Increment if necessary
RELEASE="1"

function short(){
echo ${VERSION}
}

function long(){
echo "$(short)-$(release)"
}

function release(){
# Package release

if [ $IS_RELEASE = false ]; then
# Used for nightly builds
RELEASE="0.$(date +%04Y%02m%02d%02H%02M).git$(git rev-parse --short ${GITHUB_SHA:-HEAD})"
fi
echo $RELEASE
}

[ -z $1 ] && short || $1
5 changes: 2 additions & 3 deletions initoverlayfs.spec → initoverlayfs.spec.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Name: initoverlayfs
Version: 0.98
Release: 1%{?dist}
Version: @VERSION@
Release: @RELEASE@%{?dist}
Summary: An initial scalable filesystem for Linux operating systems

License: GPL-2.0-only
URL: https://github.com/containers/initoverlayfs
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
Expand Down
42 changes: 42 additions & 0 deletions integration/plans/tier-0.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
summary: Tier 0 - initoverlayfs

discover:
how: fmf
filter: tier:0

provision:
how: local

adjust:
- when: distro == centos-stream-9
prepare+:
- name: Prepare c9s Repo
how: shell
order: 10
script: |
dnf install -y epel-release

- when: scenario == manual
prepare+:
- name: Prepare Repos
how: shell
order: 10
script: |
dnf copr enable -y @centos-automotive-sig/next

prepare:
- name: Install rpms
Yarboa marked this conversation as resolved.
Show resolved Hide resolved
how: install
package: initoverlayfs

- name: Verify rpm
how: shell
script: |
echo $(rpm -qa | grep -i initoverlayfs)

execute:
how: tmt

report:
how: junit

5 changes: 5 additions & 0 deletions integration/tests/boot-validation/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
summary: test verify install is working
test: ./test.sh
tier: 0
framework: shell

44 changes: 44 additions & 0 deletions integration/tests/boot-validation/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

set -x

if [ "${TMT_REBOOT_COUNT}" == "1" ];then
echo -n "machine is up"
storage_init=$(journalctl -r | grep "init -> usr/sbin/storage-init" | tail -1)
exit_code="$?"
if [ "$exit_code" != "0" ]; then
echo -n "initoverlayfs, storage-init messages not found in journal"
exit "$exit_code"
fi
echo -n "initoverlayfs boot complete"
exit 0
fi

RPM_EXIST=$(rpm -qa | grep -i initoverlayfs)

if [ -z "${RPM_EXIST}" ]; then
echo -n "initoverlayfs rpm is missing"
exit 127
fi

echo -n "Install initoverlayfs"
/usr/bin/initoverlayfs-install

exit_code="$?"

if [ "$exit_code" != "0" ]; then
echo -n "initoverlayfs-install completeted with $exit_code"
exit "$exit_code"
fi

echo -n "Verifying initoverlayfs in /boot"
du -sh /boot/init* | grep initoverlayfs

exit_code="$?"
if [ "$exit_code" != "0" ]; then
echo -n "initoverlayfs not found under /boot please check runnin machine"
exit "$exit_code"
fi

/usr/local/bin/tmt-reboot