diff --git a/.gitignore b/.gitignore index f2ec759..d6ee9df 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ rabbitmq-data workflow-pr-repos __pycache__/ /workflow-pr/workflow-pr +/build diff --git a/Makefile b/Makefile index 99d7223..d6b8f5a 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,61 @@ -up: - podman-compose up +# We want to be able to test in four **modes**: +# A. bots are used from official package as defined in */Dockerfile.package +# B. bots are build from source of upstream gitea repo (aka bots-obs) +# C. bots are build from source of forked gitea repo (aka bots-ibs) +# D. bots are just build locally from custom gitea fork/branch +# +# Switching between modes may require command: podman-compose build workflow-pr (sometimes used below explicitly) + +# this will just use prebuilt containers, works for all modes +up: + podman-compose up -d + +# tear down in all modes should look thes same down: podman-compose down +# mode A +up-bots-package: + GIWTF_WORKFLOW_PR_IMAGE_SUFFIX=.package podman-compose up -d + +# modes B C D depending on pre-built binaries located in corresponding folder(s) +# as defined in */Dockerfile.local +up-bots-local: + GIWTF_WORKFLOW_PR_IMAGE_SUFFIX=.local podman-compose up -d + rmi: podman rmi -f $$(podman images --filter=reference='giwtf_*' -q) -up-local-bots: - GIWTF_WORKFLOW_PR_IMAGE_SUFFIX=.local podman-compose up --force-recreate --build +up-obs: down bots-obs-build up-bots-local +up-ibs: down bots-ibs-build up-bots-local + + +BOT_PRJ_ORG=git-workflow +BOT_PRJ_BRANCH=main + +# prepares binaries for mode B, will not rebuild it unless bots-obs-clean is used +bots-obs-build: bots-build +# make sure the binaries are rebuild on next run for mode B +bots-obs-clean: bots-clean + +# this just defines some variables, do not use explicitly +bots-ibs%: BOT_PRJ_ORG=adrianSuSe +bots-ibs%: BOT_PRJ_BRANCH=ibs_state + +# prepares binaries for mode C, will not rebuild it unless bots-ibs-clean is used +bots-ibs-build: bots-build +# make sure the binaries are rebuild on next run for mode B +bots-ibs-clean: bots-clean + + +bots-build: + mkdir -p build/${BOT_PRJ_ORG} + if test -d build/${BOT_PRJ_ORG}/autogits; then :; else git clone https://src.opensuse.org/${BOT_PRJ_ORG}/autogits -b ${BOT_PRJ_BRANCH} build/${BOT_PRJ_ORG}/autogits; fi + ( cd build/${BOT_PRJ_ORG}/autogits/workflow-pr; go build ) + cp build/${BOT_PRJ_ORG}/autogits/workflow-pr/workflow-pr workflow-pr + GIWTF_WORKFLOW_PR_IMAGE_SUFFIX=.local podman-compose build workflow-pr + +bots-clean: + rm -rf --interactive=once build/${BOT_PRJ_ORG}/autogits diff --git a/workflow-pr/Dockerfile.local b/workflow-pr/Dockerfile.local index 09dbcc6..de7c3a8 100644 --- a/workflow-pr/Dockerfile.local +++ b/workflow-pr/Dockerfile.local @@ -6,7 +6,7 @@ COPY rabbitmq-config/certs/cert.pem /usr/share/pki/trust/anchors/gitea-rabbitmq- RUN update-ca-certificates # Install git and ssh -RUN zypper -n in git-core openssh-clients +RUN zypper -n in git-core openssh-clients binutils # Copy the pre-built binary into the container COPY workflow-pr/workflow-pr /usr/local/bin/workflow-pr diff --git a/workflow-pr/entrypoint.sh b/workflow-pr/entrypoint.sh index 583b4cb..04b3361 100644 --- a/workflow-pr/entrypoint.sh +++ b/workflow-pr/entrypoint.sh @@ -60,6 +60,7 @@ exe=${exe:-/usr/local/bin/workflow-pr} package=$(rpm -qa | grep autogits-workflow-pr) || : -echo !!!!!!!!!!!!!!!! using binary $exe; installed package: $package +echo "!!!!!!!!!!!!!!!! using binary $exe; installed package: $package" +which strings > /dev/null 2>&1 && strings "$exe" | grep -A 2 vcs.revision= | head -4 || : exec "$exe" "$@"