diff options
author | Devan Carpenter <devan@taler.net> | 2023-10-05 15:40:41 -0400 |
---|---|---|
committer | Devan Carpenter <devan@taler.net> | 2023-12-13 10:39:23 -0500 |
commit | 8803e416e262bad58268e39f124d17ffbfcb5c74 (patch) | |
tree | 56df275070015f20b2fb64af14f8de1cfc47958f /contrib | |
parent | 0609f1f2d482d0edca33b4ca190c05bb818fd199 (diff) |
ci: add script for running CI locally
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/ci/ci.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/contrib/ci/ci.sh b/contrib/ci/ci.sh new file mode 100755 index 000000000..47c7a211e --- /dev/null +++ b/contrib/ci/ci.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -exvuo pipefail + +# Use podman if available, otherwise use docker. +# Fails if neither is found in PATH +OCI_RUNTIME=$(which podman || which docker) +REPO_NAME=$(basename "${PWD}") +JOB_NAME="${1}" +JOB_CONTAINER=$((grep CONTAINER_NAME contrib/ci/jobs/${JOB_NAME}/config.ini | cut -d' ' -f 3) || echo "${REPO_NAME}") +JOB_ARCH=$((grep CONTAINER_ARCH contrib/ci/jobs/${JOB_NAME}/config.ini | cut -d' ' -f 3) || echo "${2:-amd64}") +CONTAINER_BUILD=$((grep CONTAINER_BUILD contrib/ci/jobs/${JOB_NAME}/config.ini | cut -d' ' -f 3) || echo "True") + +echo "${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 |