From 6f5e81d46d06775154dc3318d92daecfdd6a1bbc Mon Sep 17 00:00:00 2001 From: Tulip Blossom Date: Thu, 12 Dec 2024 12:15:54 -0300 Subject: [PATCH] feat: add justfile + containerfile for local build testing (#63) * feat: add justfile + containerfile for local build testing * fix(just, containerfile): properly get build files * feat(just): clean target --- .gitignore | 1 + Containerfile | 21 +++++++++++++++++++++ Justfile | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 .gitignore create mode 100644 Containerfile create mode 100644 Justfile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea1472e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +output/ diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..d533007 --- /dev/null +++ b/Containerfile @@ -0,0 +1,21 @@ +FROM registry.fedoraproject.org/fedora:latest AS builder +ARG TARGET_SPEC="${TARGET_SPEC:-staging/devpod/devpod.spec}" + +COPY . /app + +RUN dnf update -y && dnf upgrade -y && dnf install rpkg spectool -y && dnf clean all + +WORKDIR /app +RUN cp -rf $(dirname $TARGET_SPEC)/* /tmp && \ + rpkg --path $(dirname $TARGET_SPEC) spec --outdir /tmp --spec $(basename $TARGET_SPEC) + +WORKDIR /tmp +RUN export SPEC=$(basename $TARGET_SPEC) && \ + dnf -y builddep $SPEC && \ + spectool -ag $SPEC -C /tmp && \ + rpkg local --spec $SPEC --outdir /tmp && \ + find /tmp + +FROM scratch AS artifacts + +COPY --from=builder /tmp/*/*.rpm / diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..e3dc955 --- /dev/null +++ b/Justfile @@ -0,0 +1,41 @@ +# Run renovate locally to test modules +renovate dry-run="lookup" log-level="debug": + #!/usr/bin/env bash + if ! command -v "renovate" &> /dev/null ; then + echo "You need to install renovate first" + echo "It should be available on brew and on npm." + exit 1 + fi + if [ "$GITHUB_COM_TOKEN" == "" ] ; then + echo "Warning: No Github token found, renovate will nag at you for this." + echo "Set it with GITHUB_COM_TOKEN=(your token)" + fi + LOG_LEVEL=${LOG_LEVEL:-debug} renovate --platform=local --dry-run={{dry-run}} + echo "Updates can be found in a section of the logs called \"packageFiles with updates\"" + +build package="staging/devpod/devpod.spec": + #!/usr/bin/env bash + PKGNAME={{package}} + PKGNAME="${PKGNAME##*/}" + PKGNAME="${PKGNAME%.*}" + buildah bud -f Containerfile -t localhost/${PKGNAME}:latest --build-arg TARGET_SPEC={{package}} . + +extract package="staging/devpod/devpod.spec" extract_rpm="0": + #!/usr/bin/env bash + PKGNAME={{package}} + PKGNAME="${PKGNAME##*/}" + PKGNAME="${PKGNAME%.*}" + rm -rf output + mkdir -p output + podman export $(podman create localhost/${PKGNAME}:latest) | tar xf - -C output + if [ {{extract_rpm}} -ne 1 ] ; then + exit 0 + fi + pushd output + for rpm_file in $(find . -iname "*.rpm"); do + rpm2cpio "$rpm_file" | cpio -idmv + done + popd + +clean: + rm -rf output