diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ef8f77d..72eb459 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -81,3 +81,65 @@ jobs: pushd $OSC_CHECKOUT_DIR osc ar osc commit -m "GitHub Actions automated update to reference ${{ github.sha }}" + + obs-commit-image: + name: Commit to OBS to generate a container image + runs-on: ubuntu-20.04 + if: github.ref == 'refs/heads/main' || github.event_name == 'release' + needs: [tlint] + container: + image: ghcr.io/trento-project/continuous-delivery:main + env: + FOLDER: packaging/suse/container + NAME: trento-checks-image + OBS_PASS: ${{ secrets.OBS_PASS }} + OBS_PROJECT: ${{ secrets.OBS_PROJECT }} + OBS_USER: ${{ secrets.OBS_USER }} + OSC_CHECKOUT_DIR: /tmp/trento-checks-image + REPOSITORY: ${{ github.repository }} + options: -u 0:0 + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.12.1 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions-ecosystem/action-get-latest-tag@v1 + id: latest-tag + with: + semver_only: true + initial_version: 0.0.1 + - name: Configure OSC + run: | + mkdir -p $HOME/.config/osc + cp /home/osc/.config/osc/oscrc $HOME/.config/osc + /scripts/init_osc_creds.sh + - name: Prepare .changes file + # The .changes file is updated only in release creation. This current task should be improved + # in order to add the current rolling release notes + if: github.event_name == 'release' + run: | + CHANGES_FILE=$NAME.changes + osc checkout $OBS_PROJECT $NAME $CHANGES_FILE + mv $CHANGES_FILE $FOLDER + VERSION=${{ steps.latest-tag.outputs.tag }} + hack/gh_release_to_obs_changeset.py $REPOSITORY -a shap-staff@suse.de -t $VERSION -f $FOLDER/$CHANGES_FILE + - name: Set version + run: | + git config --global --add safe.directory /__w/checks/checks + VERSION=$(./hack/get_version_from_git.sh) + # "+" character is not allowed in OBS dockerfile version strings + VERSION=${VERSION//[+]/-} + sed -i 's~%%VERSION%%~'"${VERSION}"'~' $FOLDER/Dockerfile + - name: Commit on OBS + run: | + OBS_PACKAGE=$OBS_PROJECT/$NAME + osc checkout $OBS_PACKAGE -o $OSC_CHECKOUT_DIR + cp -r $FOLDER/* $OSC_CHECKOUT_DIR + tar --transform 's,^./,/checks/,' -zcvf $OSC_CHECKOUT_DIR/checks.tar.gz --exclude=./.git ./* + cd $OSC_CHECKOUT_DIR + osc ar + osc commit -m "New development version of $NAME released" + diff --git a/bin/trento-install-checks b/bin/trento-install-checks new file mode 100755 index 0000000..39a657d --- /dev/null +++ b/bin/trento-install-checks @@ -0,0 +1,39 @@ +#!/bin/sh +# +# trento-install-checks +# +# This script installs the checks into the directory Wanda expects them. It +# is required, for Kubernetes style sidecar containers and should not be used +# in regular deployments using docker +# + +checks_src="/usr/local/src/trento-checks/checks" +checks_dst="/usr/share/trento/checks" + +if [ -d "$checks_dst" ] && [ -n "$(find "$checks_dst" -maxdepth 0 -type d -empty 2>/dev/null)" ]; then + if [ ! -d "$checks_src" ]; then + echo "Make sure the checks are installed to $checks_src" 1>&2 + + # FIXME: handle via trap + unset checks_src + unset checks_dst + + exit 1 + fi + + install -p -m 0644 "$checks_src"/* "$checks_dst" || echo "Make sure $checks_dst exists, is empty and accessible" 1>&2 + + # FIXME: handle via trap + unset checks_src + unset checks_dst + + exit $? +fi + +echo "Make sure $checks_dst exists, is empty and accessible" 1>&2 + +# FIXME: handle via trap +unset checks_src +unset checks_dst + +exit 1 diff --git a/packaging/suse/container/Dockerfile b/packaging/suse/container/Dockerfile new file mode 100644 index 0000000..d0e05f9 --- /dev/null +++ b/packaging/suse/container/Dockerfile @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 +#!BuildTag: trento/trento-checks:latest +#!BuildTag: trento/trento-checks:%%VERSION%% +#!BuildTag: trento/trento-checks:%%VERSION%%-build%RELEASE% +#!UseOBSRepositories +#!ExclusiveArch: x86_64 +FROM bci/bci-base:15.4 + +LABEL org.opencontainers.image.source="https://github.com/trento-project/checks" + +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US:en +ENV LC_ALL en_US.UTF-8 + +# tar is required by kubectl cp +RUN zypper --non-interactive in -y tar && \ + zypper --non-interactive clean + +COPY checks /usr/local/src/trento-checks/checks + +COPY bin/trento-install-checks /usr/local/bin/trento-install-checks +RUN chmod +x /usr/local/bin/trento-install-checks + +ENTRYPOINT ["/usr/local/bin/trento-install-checks"] diff --git a/packaging/suse/container/_constraints b/packaging/suse/container/_constraints new file mode 100644 index 0000000..6213041 --- /dev/null +++ b/packaging/suse/container/_constraints @@ -0,0 +1,7 @@ + + + + 8 + + + diff --git a/packaging/suse/container/_service b/packaging/suse/container/_service new file mode 100644 index 0000000..adafa36 --- /dev/null +++ b/packaging/suse/container/_service @@ -0,0 +1,4 @@ + + + +