Skip to content

Commit

Permalink
Remove private bindings when compile script finishes
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszWojciechO committed Dec 6, 2024
1 parent 4b094ef commit e2b5328
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
9 changes: 1 addition & 8 deletions ci/add_private_bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
go mod edit -replace="$bindings_name"="$bindings_path"
5 changes: 5 additions & 0 deletions ci/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ tags="${FEATURES:-"telio drop"}"
source "${WORKDIR}"/ci/set_bindings_version.sh libtelio
source "${WORKDIR}"/ci/set_bindings_version.sh libdrop

private_bindings_rollback=""
if [[ $tags == *"moose"* ]]; then
# Set correct events domain in case compiling with moose
if [[ "${ENVIRONMENT}" == "prod" ]]; then
Expand All @@ -74,11 +75,15 @@ 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
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

Expand Down
6 changes: 6 additions & 0 deletions ci/remove_private_bindings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

bindings_name=$1

go mod edit -droprequire="$bindings_name"
go mod edit -dropreplace="$bindings_name"
1 change: 1 addition & 0 deletions ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e2b5328

Please sign in to comment.