From 557e5189821b5b55c3ae2d9d64ba59c895bc7195 Mon Sep 17 00:00:00 2001 From: Bartosz Oleaczek Date: Fri, 6 Dec 2024 15:10:38 +0100 Subject: [PATCH] Remove private bindings when compile script finishes --- ci/add_private_bindings.sh | 9 +-------- ci/compile.sh | 8 +++++++- ci/remove_private_bindings.sh | 6 ++++++ ci/test.sh | 1 + 4 files changed, 15 insertions(+), 9 deletions(-) create mode 100755 ci/remove_private_bindings.sh diff --git a/ci/add_private_bindings.sh b/ci/add_private_bindings.sh index 464f7f36..a1796516 100644 --- a/ci/add_private_bindings.sh +++ b/ci/add_private_bindings.sh @@ -4,11 +4,4 @@ bindings_name=$1 bindings_path=$2 go mod edit -require="$bindings_name"@v0.0.0 -go mod edit -replace="$bindings_name"="$bindings_path" - -function revert_private_bindings { - go mod edit -droprequire="$bindings_name" - go mod edit -dropreplace="$bindings_name" -} - -trap revert_private_bindings EXIT \ No newline at end of file +go mod edit -replace="$bindings_name"="$bindings_path" \ No newline at end of file diff --git a/ci/compile.sh b/ci/compile.sh index 052cfa37..d1965ca9 100755 --- a/ci/compile.sh +++ b/ci/compile.sh @@ -62,6 +62,8 @@ tags="${FEATURES:-"telio drop"}" source "${WORKDIR}"/ci/set_bindings_version.sh libtelio source "${WORKDIR}"/ci/set_bindings_version.sh libdrop +private_bindings_rollback="" +trap -- '${WORKDIR}/ci/remove_private_bindings.sh moose/events; ${WORKDIR}/ci/remove_private_bindings.sh moose/worker; ${WORKDIR}/ci/remove_private_bindings.sh quench' EXIT if [[ $tags == *"moose"* ]]; then # Set correct events domain in case compiling with moose if [[ "${ENVIRONMENT}" == "prod" ]]; then @@ -74,12 +76,16 @@ if [[ $tags == *"moose"* ]]; then -X 'main.EventsDomain=${events_domain:-""}' \ -X 'main.EventsSubdomain=${EVENTS_SUBDOMAIN:-""}'" + # private_bindings_rollback="${WORKDIR}/ci/remove_private_bindings.sh moose/events; ${WORKDIR}/ci/remove_private_bindings.sh moose/worker;" + # trap -- "$private_bindings_rollback" EXIT source "${WORKDIR}"/ci/add_private_bindings.sh moose/events ./third-party/moose-events/moosenordvpnappgo/v14 source "${WORKDIR}"/ci/add_private_bindings.sh moose/worker ./third-party/moose-worker/mooseworkergo/v14 fi if [[ $tags == *"quench"* ]]; then - source "${WORKDIR}"/ci/add_private_bindings.sh quench ./third-party/libquench-go + private_bindings_rollback="${private_bindings_rollback} ${WORKDIR}/ci/remove_private_bindings.sh quench" + # trap -- "$private_bindings_rollback" EXIT + # source "${WORKDIR}"/ci/add_private_bindings.sh quench ./third-party/libquench-go fi for program in ${!names_map[*]}; do # looping over keys diff --git a/ci/remove_private_bindings.sh b/ci/remove_private_bindings.sh new file mode 100755 index 00000000..5d05d908 --- /dev/null +++ b/ci/remove_private_bindings.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +bindings_name=$1 + +go mod edit -droprequire="$bindings_name" +go mod edit -dropreplace="$bindings_name" \ No newline at end of file diff --git a/ci/test.sh b/ci/test.sh index 0ca4e5cd..c821b64c 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -18,6 +18,7 @@ tags="internal" # everything if [ "${1:-""}" = "full" ]; then # Apply moose patch in case compiling with moose + trap '${WORKDIR}/ci/remove_private_bindings.sh moose/events; ${WORKDIR}/ci/remove_private_bindings.sh moose/worker;' EXIT source "${WORKDIR}"/ci/add_private_bindings.sh moose/events ./third-party/moose-events/moosenordvpnappgo/v14 source "${WORKDIR}"/ci/add_private_bindings.sh moose/worker ./third-party/moose-worker/mooseworkergo/v14