diff options
author | Devan Carpenter <devan@taler.net> | 2023-10-12 13:33:54 -0400 |
---|---|---|
committer | Devan Carpenter <devan@taler.net> | 2023-12-13 15:37:42 -0500 |
commit | d618ade5bb37448ab931280340e84b468d13fe0e (patch) | |
tree | ff7dbf555dfa401e1f3b4b48ec86e055a55f1a91 /contrib/ci/ci.sh | |
parent | 364ebfdce668fd4ab863783c032d54217fc5b8d8 (diff) |
ci: add script to run CI locally
Diffstat (limited to 'contrib/ci/ci.sh')
-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 00000000..47c7a211 --- /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 |