commit d379f9bc6cf4d50559e96f46f7ac2e68fc2c5b3f
parent 3adb0e5d138b6646320fa61c76789a17294a7dd3
Author: Antoine A <>
Date: Thu, 6 Feb 2025 21:38:30 +0100
common: add CI
Diffstat:
13 files changed, 150 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
@@ -1,4 +1,5 @@
.env
+.build
target
dev.conf
keys.json
\ No newline at end of file
diff --git a/common/taler-common/src/config.rs b/common/taler-common/src/config.rs
@@ -808,10 +808,12 @@ impl<T> Value<'_, T> {
mod test {
use std::{
fmt::{Debug, Display},
- fs::Permissions,
+ fs::{File, Permissions},
os::unix::fs::PermissionsExt,
};
+ use tracing::error;
+
use crate::{config::parser::ConfigSource, types::amount};
use super::{Config, Section, Value};
@@ -844,6 +846,10 @@ mod test {
config_file
.set_permissions(Permissions::from_mode(0o222))
.unwrap();
+ if File::open(&config_path).is_ok() {
+ error!("Cannot finish this test if root");
+ return;
+ }
check(format!(
"Could not read config at '{config_path_fmt}': permission denied"
));
diff --git a/contrib/ci/Containerfile b/contrib/ci/Containerfile
@@ -0,0 +1,26 @@
+FROM docker.io/library/debian:trixie
+
+ENV DEBIAN_FRONTEND=noninteractive
+# Persistent cargo cache
+ENV CARGO_HOME=/workdir/.build/cargo
+
+RUN apt-get update -yq && \
+ apt-get upgrade -yq && \
+ apt-get install -yq \
+ unzip \
+ rustup \
+ make \
+ po-debconf \
+ build-essential \
+ libssl-dev \
+ pkg-config \
+ debhelper-compat \
+ devscripts \
+ git-buildpackage \
+ postgresql \
+ sudo && \
+ rustup default stable
+
+WORKDIR /workdir
+
+CMD ["bash", "/workdir/ci/ci.sh"]
diff --git a/contrib/ci/ci.sh b/contrib/ci/ci.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+set -exvuo pipefail
+
+# Requires podman
+# Fails if not found in PATH
+OCI_RUNTIME=$(which podman)
+REPO_NAME=$(basename "${PWD}")
+JOB_NAME="${1}"
+JOB_ARCH=$((grep CONTAINER_ARCH contrib/ci/jobs/${JOB_NAME}/config.ini | cut -d' ' -f 3) || echo "${2:-amd64}")
+JOB_CONTAINER=$((grep CONTAINER_NAME contrib/ci/jobs/${JOB_NAME}/config.ini | cut -d' ' -f 3) || echo "localhost/${REPO_NAME}:${JOB_ARCH}")
+CONTAINER_BUILD=$((grep CONTAINER_BUILD contrib/ci/jobs/${JOB_NAME}/config.ini | cut -d' ' -f 3) || echo "True")
+
+echo "Image name: ${JOB_CONTAINER}"
+
+if [ "${CONTAINER_BUILD}" = "True" ] ; then
+ "${OCI_RUNTIME}" build \
+ --arch "${JOB_ARCH}" \
+ -t "${JOB_CONTAINER}" \
+ -f contrib/ci/Containerfile .
+fi
+
+"${OCI_RUNTIME}" run \
+ --rm \
+ -ti \
+ --arch "${JOB_ARCH}" \
+ --env CI_COMMIT_REF="$(git rev-parse HEAD)" \
+ --volume "${PWD}":/workdir \
+ --workdir /workdir \
+ "${JOB_CONTAINER}" \
+ contrib/ci/jobs/"${JOB_NAME}"/job.sh
+
+top_dir=$(dirname "${BASH_SOURCE[0]}")
+
+#"${top_dir}"/build.sh
diff --git a/contrib/ci/jobs/0-codespell/config.ini b/contrib/ci/jobs/0-codespell/config.ini
@@ -0,0 +1,6 @@
+[build]
+HALT_ON_FAILURE = False
+WARN_ON_FAILURE = True
+CONTAINER_BUILD = False
+CONTAINER_NAME = nixery.dev/shell/codespell
+CONTAINER_ARCH = amd64
diff --git a/contrib/ci/jobs/0-codespell/dictionary.txt b/contrib/ci/jobs/0-codespell/dictionary.txt
@@ -0,0 +1,7 @@
+# List of "words" that codespell should ignore in our sources.
+#
+# Note: The word sensitivity depends on how the to-be-ignored word is
+# spelled in codespell_lib/data/dictionary.txt. F.e. if there is a word
+# 'foo' and you add 'Foo' _here_, codespell will continue to complain
+# about 'Foo'.
+#
+\ No newline at end of file
diff --git a/contrib/ci/jobs/0-codespell/job.sh b/contrib/ci/jobs/0-codespell/job.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+set -exuo pipefail
+
+job_dir=$(dirname "${BASH_SOURCE[0]}")
+
+skip=$(cat <<EOF
+*/debian/*
+*/doc/prebuilt/*
+*/.git/*
+*/target/*
+*/contrib/ci/*
+EOF
+);
+
+echo Current directory: `pwd`
+
+codespell -I "${job_dir}"/dictionary.txt -S ${skip//$'\n'/,}
diff --git a/contrib/ci/jobs/1-build/build.sh b/contrib/ci/jobs/1-build/build.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+set -exuo pipefail
+
+make
diff --git a/contrib/ci/jobs/1-build/job.sh b/contrib/ci/jobs/1-build/job.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+set -exuo pipefail
+
+apt-get update -yq
+apt-get upgrade -yq
+rustup upgrade
+
+job_dir=$(dirname "${BASH_SOURCE[0]}")
+
+"${job_dir}"/build.sh
diff --git a/contrib/ci/jobs/2-test/config.ini b/contrib/ci/jobs/2-test/config.ini
@@ -0,0 +1,6 @@
+[build]
+HALT_ON_FAILURE = False
+WARN_ON_FAILURE = True
+CONTAINER_BUILD = True
+CONTAINER_NAME = localhost/taler-rust
+CONTAINER_ARCH = amd64
diff --git a/contrib/ci/jobs/2-test/job.sh b/contrib/ci/jobs/2-test/job.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+set -exuo pipefail
+
+apt-get update -yq
+apt-get upgrade -yq
+rustup upgrade
+
+job_dir=$(dirname "${BASH_SOURCE[0]}")
+
+"${job_dir}"/test.sh
diff --git a/contrib/ci/jobs/2-test/test.sh b/contrib/ci/jobs/2-test/test.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+set -evu
+
+sudo -u postgres pg_ctlcluster 17 main start
+sudo -u postgres createuser root --superuser
+sudo -u postgres createdb -O root taler_rust_check
+
+check_command()
+{
+ make check &> test-suite.log
+}
+
+if ! check_command ; then
+ cat test-suite.log
+ exit 1
+fi
diff --git a/contrib/ci/run-all-jobs.sh b/contrib/ci/run-all-jobs.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+set -eax
+for JOB in $(ls $(dirname $0)/jobs | sort -n); do
+ $(dirname $0)/ci.sh $JOB;
+done;