mirror of
https://github.com/NLnetLabs/rtrtr.git
synced 2024-05-11 05:55:07 +00:00
Revert " First attempt to use a reusable pkg workflow from another (NLnet Labs) Git repo."
This reverts commit 711272adad
.
This commit is contained in:
77
.github/workflows/pkg-docker.yml
vendored
Normal file
77
.github/workflows/pkg-docker.yml
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
# Based on: https://github.com/docker/build-push-action/blob/master/docs/advanced/test-before-push.md
|
||||
# Trigger and tag naming rules are based on the settings we were previously using at Docker Hub.
|
||||
|
||||
name: Packaging Docker
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Extract metadata for tagging the Docker image
|
||||
id: meta
|
||||
uses: docker/metadata-action@v3
|
||||
with:
|
||||
images: nlnetlabs/rtrtr
|
||||
flavor: |
|
||||
latest=false
|
||||
tags: |
|
||||
type=semver,pattern={{version}},prefix=v
|
||||
type=raw,value=unstable,enable=${{ github.ref == 'refs/heads/main' }}
|
||||
type=raw,value=latest,enable=${{ github.ref != 'refs/heads/main' && !contains(github.ref, '-') }}
|
||||
|
||||
- name: Log into Docker Hub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_HUB_ID }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
|
||||
# Build the image and tag it with a test tag we can use in the subsequent step when we invoke 'docker run'.
|
||||
- name: Build Docker image
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64
|
||||
push: false
|
||||
load: true
|
||||
tags: nlnetlabs/rtrtr:sanitycheck
|
||||
|
||||
# Do a basic sanity check of the created image using the test tag to select the image to run.
|
||||
- name: Sanity check
|
||||
run: |
|
||||
docker run --rm nlnetlabs/rtrtr:sanitycheck --version
|
||||
|
||||
# Push the image and tags to Docker Hub.
|
||||
# The build uses the cached build outputs from the step above so we don't have to wait for the build again.
|
||||
#
|
||||
# On push of a tag to refs/tags/v1.2.3 the Docker tags will be 'v1.2.3' and 'latest' because of:
|
||||
# type=semver,pattern={{version}},prefix=v
|
||||
# type=raw,value=latest,enable=${{ github.ref != 'refs/heads/main' && !contains(github.ref, '-') }}
|
||||
# ^^^^^^^^^^^^^ true, not main ^^^^^^^^^ true, no dash found
|
||||
#
|
||||
# Note: we don't use semver,pattern={{raw}} because while that preserves the leading v in v1.2.3 it
|
||||
# discards the leading v in v1.2.3-rc4.
|
||||
#
|
||||
# On push of a tag to refs/tags/v1.2.3-rc1 the Docker tags will be 'v1.2.3' but NOT 'latest' because of:
|
||||
# type=semver,pattern={{raw}}
|
||||
# type=raw,value=latest,enable=${{ github.ref != 'refs/heads/main' && !contains(github.ref, '-') }}
|
||||
# ^^^^^^^^^^^^^ true, not main ^^^^^^^^^ false, dash found
|
||||
#
|
||||
# On push to refs/heads/main the Docker tag will be 'unstable' because of:
|
||||
# type=raw,value=unstable,enable=${{ github.ref == 'refs/heads/main' }}
|
||||
- name: Push built Docker image to Docker Hub
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
571
.github/workflows/pkg.yml
vendored
571
.github/workflows/pkg.yml
vendored
@ -1,33 +1,562 @@
|
||||
name: Packaging
|
||||
# GitHub Actions workflow for building and testing RTRTR O/S packages. Uses
|
||||
# GitHub Actions caching to avoid rebuilding Rust cargo deb, cargo
|
||||
# generate-rpm and RTRTR compiled dependencies on every run.
|
||||
#
|
||||
# Note: at the time of writing the GH cache contents expire after a week if
|
||||
# not used so the next build may be much slower as it will have to
|
||||
# re-download/build/install lots of Rust crates.
|
||||
#
|
||||
# Packages are built inside Docker containers as GH Runners have extra libraries
|
||||
# and packages installed which can cause package building to succeed but package
|
||||
# installation on a real target O/S to fail, due to being built against too
|
||||
# recent version of a package such as libssl or glibc.
|
||||
#
|
||||
# Packages are tested inside LXC/LXD containers because Docker containers don't
|
||||
# by default support init managers such as systemd but we want to test systemd
|
||||
# service unit installation and activation.
|
||||
|
||||
name: Packaging
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- v*
|
||||
|
||||
# Triggering on PRs and arbitrary branch pushes is not enabled because most of the time only the CI build should be
|
||||
# triggered, not the packaging build. In cases where you want to test changes to this workflow this trigger enables
|
||||
# you to manually invoke this workflow on an arbitrary branch as needed.
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
defaults:
|
||||
run:
|
||||
# see: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell
|
||||
shell: bash --noprofile --norc -eo pipefail -x {0}
|
||||
|
||||
jobs:
|
||||
package:
|
||||
uses: ximon18/.github/.github/workflows/pkg.yml@main
|
||||
secrets:
|
||||
DOCKER_HUB_ID: ximoneighteen
|
||||
DOCKER_HUB_TOKEN: ${{ secrets.TEST_DOCKER_HUB_TOKEN }}
|
||||
with:
|
||||
#docker_org: nlnetlabs
|
||||
#docker_repo: rtrtr
|
||||
docker_org: ximoneighteen
|
||||
docker_repo: ximontest
|
||||
# Cross-compile packages in a separate job so that we can run it on the GitHub Actions runner host directly rather
|
||||
# than inside a Docker container (as is done by the `pkg` workflow). We do this because we use `cargo cross` to handle
|
||||
# the complexity of using the right compile-time tooling and dependencies for cross compilation to work, and
|
||||
# `cargo cross` works by launching its own Docker container. Trying to launch a Docker container from within a Docker
|
||||
# container, the so-called Docker-in-Docker scenario, is more difficult for `cargo cross` to handle correctly and
|
||||
# didn't work when I tried it, even with `CROSS_DOCKER_IN_DOCKER=true` set in the environment, hence this approach.
|
||||
#
|
||||
# See: https://github.com/rust-embedded/cross#docker-in-docker
|
||||
cross:
|
||||
strategy:
|
||||
matrix:
|
||||
target:
|
||||
- 'armv7-unknown-linux-musleabihf'
|
||||
- 'aarch64-unknown-linux-musl'
|
||||
name: cross
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Git clone the code in the branch we were invoked on.
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v1
|
||||
|
||||
cross_build_rules_path: pkg/rules/cross-targets.yml
|
||||
docker_build_rules_path: pkg/rules/docker-images-to-build.yml
|
||||
package_build_rules_path: pkg/rules/packages-to-build.yml
|
||||
package_test_rules_path: pkg/rules/packages-to-test.yml
|
||||
package_test_scripts_path: pkg/test-scripts/test-<package>.sh
|
||||
- name: Install cargo cross
|
||||
run: |
|
||||
cargo install cross
|
||||
- name: Cross compile
|
||||
env:
|
||||
CROSS_TARGET: ${{ matrix.target }}
|
||||
run: |
|
||||
cross build --locked --release --target ${CROSS_TARGET}
|
||||
- name: Upload built binaries
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ matrix.target }}
|
||||
path: |
|
||||
target/${{ matrix.target }}/release/rtrtr
|
||||
|
||||
deb_maintainer: The NLnet Labs RPKI Team <rpki@nlnetlabs.nl>
|
||||
# Use the cargo-deb and cargo-generate-rpm Rust crates to build Debian and RPM
|
||||
# packages respectively for installing RTRTR.
|
||||
# See:
|
||||
# - https://github.com/mmstick/cargo-deb
|
||||
# - https://github.com/cat-in-136/cargo-generate-rpm
|
||||
pkg:
|
||||
needs: cross
|
||||
strategy:
|
||||
matrix:
|
||||
image: # can't use complex values here, only primitive values are allowed
|
||||
- "ubuntu:xenial" # ubuntu/16.04
|
||||
- "ubuntu:bionic" # ubuntu/18.04
|
||||
- "ubuntu:focal" # ubuntu/20.04
|
||||
- "ubuntu:jammy" # ubuntu/22.04
|
||||
- "debian:stretch" # debian/9
|
||||
- "debian:buster" # debian/10
|
||||
- "debian:bullseye" # debian/11
|
||||
- "centos:7"
|
||||
- "centos:8"
|
||||
target:
|
||||
- 'x86_64'
|
||||
include:
|
||||
# package for the Raspberry Pi 4b as an ARMv7 cross compiled variant of the Debian Bullseye upon which
|
||||
# Raspbian 11 is based.
|
||||
- image: 'debian:bullseye'
|
||||
target: 'armv7-unknown-linux-musleabihf'
|
||||
|
||||
# package for the ROCK64 as an AARCH64 cross compiled variant of Debian Buster upon which Armbian 21 is based.
|
||||
- image: 'debian:buster'
|
||||
target: 'aarch64-unknown-linux-musl'
|
||||
env:
|
||||
CARGO_DEB_VER: 1.28.0
|
||||
CARGO_GENERATE_RPM_VER: 0.4.0
|
||||
# A RTRTR version of the form 'x.y.z-dev' denotes a dev build that is
|
||||
# newer than the released x.y.z version but is not yet a new release.
|
||||
NEXT_VER_LABEL: dev
|
||||
name: pkg
|
||||
runs-on: ubuntu-latest
|
||||
# Build on the oldest platform we are targeting in order to avoid
|
||||
# https://github.com/rust-lang/rust/issues/57497. Specifying container
|
||||
# causes all of the steps in this job to run inside a Docker container.
|
||||
container: ${{ matrix.image }}
|
||||
|
||||
steps:
|
||||
- name: Set vars
|
||||
id: setvars
|
||||
shell: bash
|
||||
run: |
|
||||
# Get the operating system and release name (e.g. ubuntu and xenial) from
|
||||
# the image name (e.g. ubuntu:xenial) by extracting only the parts before
|
||||
# and after but not including the colon:
|
||||
echo "OS_NAME=${MATRIX_IMAGE%:*}" >> $GITHUB_ENV
|
||||
echo "OS_REL=${MATRIX_IMAGE#*:}" >> $GITHUB_ENV
|
||||
env:
|
||||
MATRIX_IMAGE: ${{ matrix.image }}
|
||||
|
||||
# Git clone the RTRTR code in the branch we were invoked on.
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v1
|
||||
|
||||
# Allow CentOS 8 to continue working now that it is EOL
|
||||
# See: https://stackoverflow.com/a/70930049
|
||||
- name: CentOS 8 EOL workaround
|
||||
if: matrix.image == 'centos:8'
|
||||
run: |
|
||||
sed -i -e 's|mirrorlist=|#mirrorlist=|g' -e 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*
|
||||
|
||||
# Install Rust the hard way rather than using a GH Action because the action
|
||||
# doesn't work inside a Docker container.
|
||||
- name: Install Rust
|
||||
run: |
|
||||
case ${OS_NAME} in
|
||||
debian|ubuntu)
|
||||
apt-get update
|
||||
apt-get install -y curl
|
||||
;;
|
||||
centos)
|
||||
yum update -y
|
||||
;;
|
||||
esac
|
||||
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --profile minimal -y
|
||||
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
- name: Install compilation and other dependencies
|
||||
run: |
|
||||
case ${OS_NAME} in
|
||||
debian|ubuntu)
|
||||
apt-get install -y build-essential jq lintian pkg-config
|
||||
;;
|
||||
centos)
|
||||
yum install epel-release -y
|
||||
yum update -y
|
||||
yum install -y jq rpmlint
|
||||
yum groupinstall -y "Development Tools"
|
||||
;;
|
||||
esac
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
# Speed up RTRTR Rust builds by caching unchanged built dependencies.
|
||||
# See: https://github.com/actions/cache/blob/master/examples.md#rust---cargo
|
||||
- name: Cache Dot Cargo
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
key: ${{ matrix.image }}-${{ matrix.target}}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
# Speed up tooling installation by only re-downloading and re-building
|
||||
# dependent crates if we change the version of the tool that we are using.
|
||||
- name: Cache Cargo Deb if available
|
||||
id: cache-cargo-deb
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.cargo/bin/cargo-deb
|
||||
key: ${{ matrix.image }}-cargo-deb-${{ env.CARGO_DEB_VER }}
|
||||
|
||||
- name: Cache Cargo Generate RPM if available
|
||||
id: cache-cargo-generate-rpm
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.cargo/bin/cargo-generate-rpm
|
||||
key: ${{ matrix.image }}-cargo-generate-rpm-${{ env.CARGO_GENERATE_RPM_VER }}
|
||||
|
||||
# Only install cargo-deb or cargo-generate-rpm if not already fetched from the cache.
|
||||
- name: Install Cargo Deb if needed
|
||||
if: steps.cache-cargo-deb.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
case ${OS_NAME} in
|
||||
debian|ubuntu)
|
||||
cargo install cargo-deb --version ${CARGO_DEB_VER}
|
||||
;;
|
||||
esac
|
||||
|
||||
- name: Install Cargo Generate RPM if needed
|
||||
if: steps.cache-cargo-generate-rpm.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
case ${OS_NAME} in
|
||||
centos)
|
||||
# Temporary workaround for https://github.com/cat-in-136/cargo-generate-rpm/issues/21
|
||||
rustup toolchain install 1.52.0
|
||||
cargo +1.52.0 install cargo-generate-rpm --version ${CARGO_GENERATE_RPM_VER} --locked
|
||||
;;
|
||||
esac
|
||||
|
||||
- name: Download cross compiled binaries
|
||||
if: ${{ matrix.target != 'x86_64' }}
|
||||
id: download
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: ${{ matrix.target }}
|
||||
path: target/${{ matrix.target }}/release
|
||||
|
||||
# Instruct cargo-deb or cargo-generate-rpm to build the package based on
|
||||
# Cargo.toml settings and command line arguments.
|
||||
- name: Create the package
|
||||
env:
|
||||
MATRIX_IMAGE: ${{ matrix.image }}
|
||||
CROSS_TARGET: ${{ matrix.target }}
|
||||
run: |
|
||||
# Debian
|
||||
# =====================================================================
|
||||
# Packages for different distributions (e.g. Stretch, Buster) of the
|
||||
# same O/S (e.g. Debian) when served from a single package repository
|
||||
# MUST have unique package_ver_architecture triples. Cargo deb can vary
|
||||
# the name based on the 'variant' config section in use, but doesn't do
|
||||
# so according to Debian policy (as it modifies the package name, not
|
||||
# the package version).
|
||||
# Format: package_ver_architecture
|
||||
# Where ver has format: [epoch:]upstream_version[-debian_revision]
|
||||
# And debian_version should be of the form: 1<xxx>
|
||||
# Where it is common to set <xxx> to the O/S name.
|
||||
# See:
|
||||
# - https://unix.stackexchange.com/a/190899
|
||||
# - https://www.debian.org/doc/debian-policy/ch-controlfields.html#version
|
||||
# Therefore we generate the version ourselves.
|
||||
#
|
||||
# In addition, Semantic Versioning and Debian version policy cannot
|
||||
# express a pre-release label in the same way. For example 0.8.0-rc.1
|
||||
# is a valid Cargo.toml [package].version value but when used as a
|
||||
# Debian package version 0.8.0-rc.1 would be considered _NEWER_ than
|
||||
# the final 0.8.0 release. To express this in a Debian compatible way
|
||||
# we must replace the dash '-' with a tilda '~'.
|
||||
#
|
||||
# RPM
|
||||
# =====================================================================
|
||||
# Handle the release candidate case where the version string needs to
|
||||
# have dash replaced by tilda. The cargo build command won't work if
|
||||
# the version key in Cargo.toml contains a tilda but we have to put the
|
||||
# tilda there for when we run cargo generate-rpm so that it uses it.
|
||||
#
|
||||
# For background on RPM versioning see:
|
||||
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/
|
||||
#
|
||||
# COMMON
|
||||
# =====================================================================
|
||||
# Finally, sometimes we want a version to be NEWER than the latest
|
||||
# release but without having to decide what higher semver number to
|
||||
# bump to. In this case we do NOT want dash '-' to become '~' because
|
||||
# `-` is treated as higher and tilda is treated as lower.
|
||||
RTRTR_VER=$(cargo read-manifest | jq -r '.version')
|
||||
RTRTR_NEW_VER=$(echo $RTRTR_VER | tr '-' '~')
|
||||
PKG_RTRTR_VER=$(echo $RTRTR_NEW_VER | sed -e "s/~$NEXT_VER_LABEL/-$NEXT_VER_LABEL/")
|
||||
|
||||
case ${OS_NAME} in
|
||||
debian|ubuntu)
|
||||
case ${OS_REL} in
|
||||
xenial|bionic|stretch) VARIANT_NAME="minimal" ;;
|
||||
*) VARIANT_NAME="" ;;
|
||||
esac
|
||||
|
||||
MAINTAINER="The NLnet Labs RPKI Team <rpki@nlnetlabs.nl>"
|
||||
|
||||
# Generate the RFC 5322 format date by hand instead of using date --rfc-email
|
||||
# because that option doesn't exist on Ubuntu 16.04 and Debian 9
|
||||
RFC5322_TS=$(LC_TIME=en_US.UTF-8 date +'%a, %d %b %Y %H:%M:%S %z')
|
||||
|
||||
# Generate the changelog file that Debian packages are required to have.
|
||||
# See: https://www.debian.org/doc/manuals/maint-guide/dreq.en.html#changelog
|
||||
if [ ! -d target/debian ]; then
|
||||
mkdir -p target/debian
|
||||
fi
|
||||
echo "rtrtr (${PKG_RTRTR_VER}) unstable; urgency=medium" >target/debian/changelog
|
||||
echo " * See: https://github.com/NLnetLabs/rtrtr/releases/tag/v${RTRTR_NEW_VER}" >>target/debian/changelog
|
||||
echo " -- maintainer ${MAINTAINER} ${RFC5322_TS}" >>target/debian/changelog
|
||||
|
||||
if [[ "${CROSS_TARGET}" == "x86_64" ]]; then
|
||||
EXTRA_CARGO_DEB_ARGS=
|
||||
case ${OS_REL} in
|
||||
xenial|bionic|stretch) VARIANT_NAME="minimal" ;;
|
||||
*) VARIANT_NAME="" ;;
|
||||
esac
|
||||
else
|
||||
EXTRA_CARGO_DEB_ARGS="--no-build --no-strip --target ${CROSS_TARGET} --output target/debian"
|
||||
VARIANT_NAME="minimal-cross"
|
||||
fi
|
||||
|
||||
DEB_VER="${PKG_RTRTR_VER}-1${OS_REL}"
|
||||
|
||||
if [[ "${VARIANT_NAME}" == "" ]]; then
|
||||
cargo deb --deb-version ${DEB_VER} -v ${EXTRA_CARGO_DEB_ARGS} -- --locked
|
||||
else
|
||||
cargo deb --deb-version ${DEB_VER} --variant ${VARIANT_NAME} -v ${EXTRA_CARGO_DEB_ARGS} -- --locked
|
||||
fi
|
||||
;;
|
||||
centos)
|
||||
# Build and strip RTRTR as cargo generate-rpm doesn't do this for us
|
||||
cargo build --release --locked
|
||||
strip -s target/release/rtrtr
|
||||
|
||||
# Fix the version string to be used for the RPM package
|
||||
sed -i -e "s/$RTRTR_VER/$PKG_RTRTR_VER/" Cargo.toml
|
||||
|
||||
# Select the correct systemd service unit file for the target operating system
|
||||
case ${MATRIX_IMAGE} in
|
||||
centos:7)
|
||||
SYSTEMD_SERVICE_UNIT_FILE="rtrtr-minimal.rtrtr.service"
|
||||
;;
|
||||
*)
|
||||
SYSTEMD_SERVICE_UNIT_FILE="rtrtr.rtrtr.service"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Copy the chosen systemd service unit file to where Cargo.toml expects it to be
|
||||
mkdir -p target/rpm
|
||||
cp pkg/common/${SYSTEMD_SERVICE_UNIT_FILE} target/rpm/rtrtr.service
|
||||
|
||||
cargo generate-rpm
|
||||
;;
|
||||
esac
|
||||
|
||||
# See what O/S specific linting tools think of our package.
|
||||
- name: Verify the package
|
||||
env:
|
||||
CROSS_TARGET: ${{ matrix.target }}
|
||||
run: |
|
||||
case ${OS_NAME} in
|
||||
debian|ubuntu)
|
||||
dpkg --info target/debian/*.deb
|
||||
if [[ "${CROSS_TARGET}" == "x86_64" ]]; then
|
||||
EXTRA_LINTIAN_ARGS=
|
||||
else
|
||||
EXTRA_LINTIAN_ARGS="--suppress-tags unstripped-binary-or-object,statically-linked-binary"
|
||||
fi
|
||||
lintian --version
|
||||
lintian -v ${EXTRA_LINTIAN_ARGS} target/debian/*.deb
|
||||
;;
|
||||
centos)
|
||||
# cargo generate-rpm creates RPMs that rpmlint considers to have
|
||||
# errors so don't use the rpmlint exit code otherwise we will always
|
||||
# abort the workflow.
|
||||
rpmlint target/generate-rpm/*.rpm || true
|
||||
;;
|
||||
esac
|
||||
|
||||
# Upload the produced package. The artifact will be available via the GH
|
||||
# Actions job summary and build log pages, but only to users logged in to GH
|
||||
# with sufficient rights in this project. The uploaded artifact is also
|
||||
# downloaded by the next job (see below) to sanity check that it can be
|
||||
# installed and results in a working RTRTR installation.
|
||||
- name: Upload package
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ env.OS_NAME }}_${{ env.OS_REL }}_${{ matrix.target }}
|
||||
path: |
|
||||
target/debian/*.deb
|
||||
target/generate-rpm/*.rpm
|
||||
|
||||
# Delete the temporary artifact that contains binaries produced by the `cross` job that ran before us. All artifacts
|
||||
# existing once the workflow completes are expected by the packages.nlnetlabs.nl scripting to contain DEB or RPM or
|
||||
# other supported package archives, not intermediate artifacts such as binaries to be packaged. Failure to delete
|
||||
# this temporary artifact will cause later publication to packages.nlnetlabs.nl using artifacts from this workflow
|
||||
# run to fail.
|
||||
- name: Delete temporary cross compiled binaries artifact
|
||||
if: ${{ matrix.target != 'x86_64' }}
|
||||
id: delete
|
||||
uses: geekyeggo/delete-artifact@v1
|
||||
with:
|
||||
name: ${{ matrix.target }}
|
||||
|
||||
# Download and sanity check on target operating systems the packages created
|
||||
# by previous jobs (see above). Don't test on GH runners as they come with
|
||||
# lots of software and libraries pre-installed and thus are not representative
|
||||
# of the actual deployment targets, nor do GH runners support all targets that
|
||||
# we want to test. Don't test in Docker containers as they do not support
|
||||
# systemd.
|
||||
pkg-test:
|
||||
name: pkg-test
|
||||
needs: pkg
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
image: # can't use complex values here, only primitive values are allowed
|
||||
- "ubuntu:xenial" # ubuntu/16.04
|
||||
- "ubuntu:bionic" # ubuntu/18.04
|
||||
- "ubuntu:focal" # ubuntu/20.04
|
||||
- "ubuntu:jammy" # ubuntu/22.04
|
||||
- "debian:stretch" # debian/9
|
||||
- "debian:buster" # debian/10 (disabled, see issue #26)
|
||||
- "debian:bullseye" # debian/11
|
||||
- "centos:7"
|
||||
- "centos:8"
|
||||
target:
|
||||
- 'x86_64'
|
||||
steps:
|
||||
# Set some environment variables that will be available to "run" steps below
|
||||
# in this job, and some output variables that will be available in GH Action
|
||||
# step definitions below.
|
||||
- name: Set vars
|
||||
id: setvars
|
||||
shell: bash
|
||||
run: |
|
||||
# Get the operating system and release name (e.g. ubuntu and xenial) from
|
||||
# the image name (e.g. ubuntu:xenial) by extracting only the parts before
|
||||
# and after but not including the colon:
|
||||
OS_NAME=${MATRIX_IMAGE%:*}
|
||||
OS_REL=${MATRIX_IMAGE#*:}
|
||||
|
||||
echo "OS_NAME=${OS_NAME}" >> $GITHUB_ENV
|
||||
echo "OS_REL=${OS_REL}" >> $GITHUB_ENV
|
||||
|
||||
case ${MATRIX_IMAGE} in
|
||||
centos:8)
|
||||
# the CentOS 8 LXD image no longer exists since CentOS 8 hit EOL.
|
||||
# use the Rocky Linux (a CentOS 8 compatible O/S) LXD image instead.
|
||||
echo "LXC_IMAGE=images:rockylinux/8/cloud" >> $GITHUB_ENV
|
||||
;;
|
||||
*)
|
||||
echo "LXC_IMAGE=images:${OS_NAME}/${OS_REL}/cloud" >> $GITHUB_ENV
|
||||
;;
|
||||
esac
|
||||
env:
|
||||
MATRIX_IMAGE: ${{ matrix.image }}
|
||||
|
||||
- name: Download package
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: ${{ env.OS_NAME }}_${{ env.OS_REL }}_${{ matrix.target }}
|
||||
|
||||
- name: Add current user to LXD group
|
||||
run: |
|
||||
sudo usermod --append --groups lxd $(whoami)
|
||||
|
||||
- name: Initialize LXD
|
||||
run: |
|
||||
sudo lxd init --auto
|
||||
|
||||
- name: Check LXD configuration
|
||||
run: |
|
||||
sg lxd -c "lxc info"
|
||||
|
||||
# Use of IPv6 sometimes prevents yum update being able to resolve
|
||||
# mirrorlist.centos.org.
|
||||
- name: Disable LXD assignment of IPv6 addresses
|
||||
run: |
|
||||
sg lxd -c "lxc network set lxdbr0 ipv6.address none"
|
||||
|
||||
- name: Launch LXC container
|
||||
run: |
|
||||
# security.nesting=true is needed to avoid error "Failed to set up mount
|
||||
# namespacing: Permission denied" in a Debian 10 container.
|
||||
sg lxd -c "lxc launch ${LXC_IMAGE} -c security.nesting=true testcon"
|
||||
|
||||
# Run package update and install man and sudo support (missing in some
|
||||
# LXC/LXD O/S images) but first wait for cloud-init to finish otherwise the
|
||||
# network isn't yet ready. Don't use cloud-init status --wait as that isn't
|
||||
# supported on older O/S's like Ubuntu 16.04 and Debian 9. Use the sudo
|
||||
# package provided configuration files otherwise when using sudo we get an
|
||||
# error that the root user isn't allowed to use sudo.
|
||||
- name: Prepare container
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Waiting for cloud-init.."
|
||||
while ! sudo lxc exec testcon -- ls -la /var/lib/cloud/data/result.json; do
|
||||
sleep 1s
|
||||
done
|
||||
|
||||
case ${OS_NAME} in
|
||||
debian|ubuntu)
|
||||
sg lxd -c "lxc exec testcon -- apt-get update"
|
||||
sg lxd -c "lxc exec testcon -- apt-get install -y -o Dpkg::Options::=\"--force-confnew\" man sudo"
|
||||
;;
|
||||
centos)
|
||||
if [[ "${MATRIX_IMAGE}" == "centos:8" ]]; then
|
||||
# allow CentOS 8 to continue working now that it is EOL
|
||||
# see: https://stackoverflow.com/a/70930049
|
||||
sg lxd -c "lxc exec testcon -- sed -i -e 's|mirrorlist=|#mirrorlist=|g' -e 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*"
|
||||
fi
|
||||
sg lxd -c "lxc exec testcon -- yum update -y"
|
||||
sg lxd -c "lxc exec testcon -- yum install -y man"
|
||||
;;
|
||||
esac
|
||||
|
||||
- name: Copy package into the LXC container
|
||||
run: |
|
||||
case ${OS_NAME} in
|
||||
debian|ubuntu)
|
||||
DEB_FILE=$(ls -1 debian/*.deb)
|
||||
sg lxd -c "lxc file push ${DEB_FILE} testcon/tmp/"
|
||||
echo "PKG_FILE=$(basename $DEB_FILE)" >> $GITHUB_ENV
|
||||
;;
|
||||
centos)
|
||||
RPM_FILE=$(ls -1 generate-rpm/*.rpm)
|
||||
sg lxd -c "lxc file push ${RPM_FILE} testcon/tmp/"
|
||||
echo "PKG_FILE=$(basename $RPM_FILE)" >> $GITHUB_ENV
|
||||
;;
|
||||
esac
|
||||
|
||||
- name: Install new package
|
||||
run: |
|
||||
case ${OS_NAME} in
|
||||
debian|ubuntu)
|
||||
sg lxd -c "lxc exec testcon -- apt-get -y install /tmp/${PKG_FILE}"
|
||||
;;
|
||||
centos)
|
||||
sg lxd -c "lxc exec testcon -- yum install -y /tmp/${PKG_FILE}"
|
||||
;;
|
||||
esac
|
||||
|
||||
- name: Test installed packages
|
||||
run: |
|
||||
echo -e "\nRTRTR VERSION:"
|
||||
sg lxd -c "lxc exec testcon -- rtrtr --version"
|
||||
|
||||
echo -e "\nRTRTR CONF:"
|
||||
sg lxd -c "lxc exec testcon -- cat /etc/rtrtr.conf"
|
||||
|
||||
echo -e "\nRTRTR HOME DIR:"
|
||||
sg lxd -c "lxc exec testcon -- ls -la /var/lib/rtrtr"
|
||||
|
||||
echo -e "\nRTRTR SERVICE STATUS BEFORE ENABLE:"
|
||||
sg lxd -c "lxc exec testcon -- systemctl status rtrtr || true"
|
||||
|
||||
echo -e "\nENABLE RTRTR SERVICE:"
|
||||
sg lxd -c "lxc exec testcon -- systemctl enable rtrtr"
|
||||
|
||||
echo -e "\nRTRTR SERVICE STATUS AFTER ENABLE:"
|
||||
sg lxd -c "lxc exec testcon -- systemctl status rtrtr || true"
|
||||
|
||||
echo -e "\nSTART RTRTR SERVICE:"
|
||||
sg lxd -c "lxc exec testcon -- systemctl start rtrtr"
|
||||
|
||||
sleep 15s
|
||||
echo -e "\nRTRTR LOGS AFTER START:"
|
||||
sg lxd -c "lxc exec testcon -- journalctl --unit=rtrtr"
|
||||
|
||||
echo -e "\nRTRTR SERVICE STATUS AFTER START:"
|
||||
sg lxd -c "lxc exec testcon -- systemctl status rtrtr"
|
||||
|
@ -93,10 +93,7 @@ assets = [
|
||||
{ source = "pkg/common/service.preset", dest = "/lib/systemd/system-preset/50-rtrtr.preset", mode = "644" },
|
||||
{ source = "pkg/rpm/postinst", dest = "/usr/share/rtrtr/rpm/postinst", mode = "755" },
|
||||
]
|
||||
# These get set using cargo-generate-rpm --set-metadata at package build time.
|
||||
#post_install_script = ...
|
||||
#pre_uninstall_script = ...
|
||||
#post_uninstall_script = ...
|
||||
post_install_script = "/usr/share/rtrtr/rpm/postinst $*"
|
||||
|
||||
# ensure that the useradd tool is present by depending on its package
|
||||
[package.metadata.generate-rpm.requires]
|
||||
|
@ -1,4 +0,0 @@
|
||||
---
|
||||
# must be one of: https://github.com/cross-rs/cross#supported-targets
|
||||
- 'armv7-unknown-linux-musleabihf'
|
||||
- 'aarch64-unknown-linux-musl'
|
@ -1,36 +0,0 @@
|
||||
---
|
||||
# matrix field notes:
|
||||
# platform: used by Docker to use the right architecture base image.
|
||||
# the set of supported values can be seen at:
|
||||
# https://go.dev/doc/install/source#environment
|
||||
# from: https://github.com/docker-library/official-images#architectures-other-than-amd64
|
||||
# from: https://docs.docker.com/desktop/multi-arch/
|
||||
# one must also take any "normalization" into account, e.g. arm64v8 -> arm64, see:
|
||||
# https://github.com/containerd/containerd/blob/v1.4.3/platforms/database.go#L83
|
||||
# see also:
|
||||
# https://stackoverflow.com/a/70889505
|
||||
# shortname: used by us to tag the architecture specific "manifest" image.
|
||||
# crosstarget: (optional) used to download the correct cross-compiled binary that was produced earlier by the
|
||||
# 'cross' job above.
|
||||
# mode: (optional) set to 'copy' for cross-compiled targets.
|
||||
# cargo_args: (optional) can be used when testing, e.g. set to '--no-default-features' to speed up the Krill
|
||||
# build.
|
||||
include:
|
||||
- platform: 'linux/amd64'
|
||||
shortname: 'amd64'
|
||||
mode: 'build'
|
||||
|
||||
- platform: 'linux/arm/v6'
|
||||
shortname: 'armv6'
|
||||
crosstarget: 'arm-unknown-linux-musleabihf'
|
||||
mode: 'copy'
|
||||
|
||||
- platform: 'linux/arm/v7'
|
||||
shortname: 'armv7'
|
||||
crosstarget: 'armv7-unknown-linux-musleabihf'
|
||||
mode: 'copy'
|
||||
|
||||
- platform: 'linux/arm64'
|
||||
shortname: 'arm64'
|
||||
crosstarget: 'aarch64-unknown-linux-musl'
|
||||
mode: 'copy'
|
@ -1,45 +0,0 @@
|
||||
---
|
||||
# matrix field notes:
|
||||
# platform: used by Docker to use the right architecture base image.
|
||||
# the set of supported values can be seen at:
|
||||
# https://go.dev/doc/install/source#environment
|
||||
# from: https://github.com/docker-library/official-images#architectures-other-than-amd64
|
||||
# from: https://docs.docker.com/desktop/multi-arch/
|
||||
# one must also take any "normalization" into account, e.g. arm64v8 -> arm64, see:
|
||||
# https://github.com/containerd/containerd/blob/v1.4.3/platforms/database.go#L83
|
||||
# see also:
|
||||
# https://stackoverflow.com/a/70889505
|
||||
# shortname: used by us to tag the architecture specific "manifest" image.
|
||||
# crosstarget: (optional) used to download the correct cross-compiled binary that was produced earlier by the
|
||||
# 'cross' job above.
|
||||
# mode: (optional) set to 'copy' for cross-compiled targets.
|
||||
# cargo_args: (optional) can be used when testing, e.g. set to '--no-default-features' to speed up the Krill
|
||||
# build.
|
||||
image: # can't use complex values here, only primitive values are allowed
|
||||
- "ubuntu:xenial" # ubuntu/16.04
|
||||
- "ubuntu:bionic" # ubuntu/18.04
|
||||
- "ubuntu:focal" # ubuntu/20.04
|
||||
- "ubuntu:jammy" # ubuntu/22.04
|
||||
- "debian:stretch" # debian/9
|
||||
- "debian:buster" # debian/10
|
||||
- "debian:bullseye" # debian/11
|
||||
- "centos:7"
|
||||
- 'rockylinux:8' # compatible with EOL centos:8
|
||||
target:
|
||||
- 'x86_64'
|
||||
include:
|
||||
- image: "centos:7"
|
||||
systemd_service_unit_file: pkg/common/rtrtr-minimal.rtrtr.service
|
||||
|
||||
- image: 'rockylinux:8'
|
||||
systemd_service_unit_file: pkg/common/rtrtr.rtrtr.service
|
||||
os: 'centos:8'
|
||||
|
||||
# package for the Raspberry Pi 4b as an ARMv7 cross compiled variant of the Debian Bullseye upon which
|
||||
# Raspbian 11 is based.
|
||||
- image: 'debian:bullseye'
|
||||
target: 'armv7-unknown-linux-musleabihf'
|
||||
|
||||
# package for the ROCK64 as an AARCH64 cross compiled variant of Debian Buster upon which Armbian 21 is based.
|
||||
- image: 'debian:buster'
|
||||
target: 'aarch64-unknown-linux-musl'
|
@ -1,17 +0,0 @@
|
||||
---
|
||||
pkg:
|
||||
- 'rtrtr'
|
||||
image: # can't use complex values here, only primitive values are allowed
|
||||
- "ubuntu:xenial" # ubuntu/16.04
|
||||
- "ubuntu:bionic" # ubuntu/18.04
|
||||
- "ubuntu:focal" # ubuntu/20.04
|
||||
- "ubuntu:jammy" # ubuntu/22.04
|
||||
- "debian:stretch" # debian/9
|
||||
- "debian:buster" # debian/10 (disabled, see issue #26)
|
||||
- "debian:bullseye" # debian/11
|
||||
- "centos:7"
|
||||
- "centos:8"
|
||||
mode:
|
||||
- 'fresh-install'
|
||||
target:
|
||||
- 'x86_64'
|
@ -1,39 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eo pipefail
|
||||
set -x
|
||||
|
||||
case $1 in
|
||||
post-install)
|
||||
echo -e "\nRTRTR VERSION:"
|
||||
rtrtr --version
|
||||
|
||||
echo -e "\nRTRTR CONF:"
|
||||
cat /etc/rtrtr.conf
|
||||
|
||||
echo -e "\nRTRTR HOME DIR:"
|
||||
ls -la /var/lib/rtrtr
|
||||
|
||||
echo -e "\nRTRTR SERVICE STATUS BEFORE ENABLE:"
|
||||
systemctl status rtrtr || true
|
||||
|
||||
echo -e "\nENABLE RTRTR SERVICE:"
|
||||
systemctl enable rtrtr
|
||||
|
||||
echo -e "\nRTRTR SERVICE STATUS AFTER ENABLE:"
|
||||
systemctl status rtrtr || true
|
||||
|
||||
echo -e "\nSTART RTRTR SERVICE:"
|
||||
systemctl start rtrtr
|
||||
|
||||
sleep 15s
|
||||
echo -e "\nRTRTR LOGS AFTER START:"
|
||||
journalctl --unit=rtrtr
|
||||
|
||||
echo -e "\nRTRTR SERVICE STATUS AFTER START:"
|
||||
systemctl status rtrtr
|
||||
;;
|
||||
|
||||
post-upgrade)
|
||||
;;
|
||||
esac
|
Reference in New Issue
Block a user