diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.github/workflows/tmt-tests.yml b/.github/workflows/tmt-tests.yml new file mode 100644 index 0000000..6689d7c --- /dev/null +++ b/.github/workflows/tmt-tests.yml @@ -0,0 +1,50 @@ +name: TMT Tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + inputs: + plan_filter: + description: | + Test plan filter name, ie: tag:smoke. + If provided, only tests matching this filter will be run, otherwise all tests will be run. + required: false + default: '' + use_built_from_src: + description: 'Build console-login-helper-messages from source instead of install distro package' + required: false + default: 'false' + +jobs: + tmt-tests: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + set -x -e -o pipefail + sudo apt-get update + sudo apt-get install -y podman libblkid-dev rsync + pip install --user tmt + + - name: Run TMT tests + run: | + set -x -e -o pipefail + if [ "$ACT" = "true" ]; then + echo "Running locally using ACT" + TMT_PROVISION_OPTS="--how local --feeling-safe" + else + TMT_PROVISION_OPTS="--how container" + fi + if [ -n "${{ github.event.inputs.plan_filter }}" ]; then + PLAN_FILTER_PARAM="plan --filter '${{ github.event.inputs.plan_filter }}'" + fi + eval "tmt run --all --debug -vvvv provision $TMT_PROVISION_OPTS $PLAN_FILTER_PARAM" diff --git a/tests/core/core.fmf b/tests/core/core.fmf new file mode 100644 index 0000000..92dd722 --- /dev/null +++ b/tests/core/core.fmf @@ -0,0 +1,6 @@ +summary: check console-login-helper-messages package installation +tag: + - smoke +test: | + set -x -e -o pipefail + rpm -q console-login-helper-messages diff --git a/tests/tmt/plans/main.fmf b/tests/tmt/plans/main.fmf new file mode 100644 index 0000000..d178a67 --- /dev/null +++ b/tests/tmt/plans/main.fmf @@ -0,0 +1,36 @@ +# This prepare is used to control when console-login-helper-messages is installed using +# the distribution package or when it is built from source in the test environment +prepare: + - name: Set CLHM_BIN_DIR when built from source + when: use_built_from_src is defined and use_built_from_src == true + how: shell + script: | + set -x -e -o pipefail + echo "Preparing the test environment" + CLHM_BIN_NAME="gensnippet_os_release" + PARENT_DIR=$(dirname "${TMT_TREE}") + CLHM_BIN_FULL_PATH=$(find "${PARENT_DIR}" -type f -name "${CLHM_BIN_NAME}") + if [ -z "${CLHM_BIN_FULL_PATH}" ]; then + echo "gensnippet_os_release file not found." + exit 1 + fi + CLHM_BIN_DIR=$(dirname "${CLHM_BIN_FULL_PATH}") + echo "CLHM_BIN_DIR=${CLHM_BIN_DIR}" > /tmp/clhm_bin_dir + - name: Install console-login-helper-messages package + when: use_built_from_src is not defined or use_built_from_src == false + how: install + package: console-login-helper-messages + - name: Set CLHM_BIN_DIR when installed package + when: use_built_from_src is not defined or use_built_from_src == false + how: shell + script: | + set -x -e -o pipefail + echo "CLHM_BIN_DIR=/usr/libexec/console-login-helper-messages" > /tmp/clhm_bin_dir + - name: Enable console-login-helper-messages systemd units + when: use_built_from_src is not defined or use_built_from_src == false + how: shell + script: | + set -x -e -o pipefail + # Enable the required systemd units for kola tests + systemctl enable console-login-helper-messages-gensnippet-ssh-keys.service || true + systemctl enable console-login-helper-messages-gensnippet-os-release.service || true diff --git a/tests/tmt/plans/smoke.fmf b/tests/tmt/plans/smoke.fmf new file mode 100644 index 0000000..d86f03f --- /dev/null +++ b/tests/tmt/plans/smoke.fmf @@ -0,0 +1,8 @@ +summary: Basic smoke test +tag: + - smoke +discover: + how: fmf + filter: "tag: smoke" +execute: + how: tmt