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

feat: add justfile + containerfile for local build testing #63

Merged
merged 3 commits into from
Dec 12, 2024
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 .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output/
21 changes: 21 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -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 /
41 changes: 41 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -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
Loading