Skip to content

Commit feb9ae2

Browse files
committed
Fix docker_shell script to automatically copy batteries if necessary
1 parent f33a099 commit feb9ae2

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

ci/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ COPY src ./src
2929
COPY templates ./templates
3030
COPY __main__.py ./
3131

32-
RUN rm -r ci/LDKSwift/Sources/LDKHeaders
33-
RUN rm -r ci/LDKSwift/Sources/LDKSwift
32+
RUN rm -rf ci/LDKSwift/Sources/LDKHeaders
33+
RUN rm -rf ci/LDKSwift/Sources/LDKSwift
3434
RUN chmod +x ci/run_tests.sh
3535

3636
COPY bindings/batteries ci/LDKSwift/Sources/LDKSwift/batteries

ci/docker_shell.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
pushd ../
22
PROJECT_DIRECTORY=`pwd`
33
LDK_DIRECTORY=$1
4+
MOUNT_CI_FOLDER=$2
45
LDK_SUBDIRECTORY="$LDK_DIRECTORY/lightning-c-bindings"
5-
# echo $LDK_SUBDIRECTORY
66

7-
[ "${LDK_DIRECTORY}" = "" ] && echo "Usage: ./docker_shell.sh /path/to/ldk-c-bindings" && exit 1;
7+
[[ "${LDK_DIRECTORY}" = "" || "${MOUNT_CI_FOLDER}" = "" ]] && echo "Usage: ./docker_shell.sh /path/to/ldk-c-bindings true/false" && exit 1;
88
[ ! -d "${LDK_DIRECTORY}" ] && echo "Provided directory does not exist" && exit 1;
9-
# [ ! -d "${LDK_SUBDIRECTORY}" ] && echo "Provided directory does not contain lightning-c-bindings directory." && exit 1;
9+
[ ! -d "${LDK_SUBDIRECTORY}" ] && echo "Provided directory does not contain lightning-c-bindings directory." && exit 1;
1010

11-
# use for direct ci folder access
12-
# note: batteries will be missing. In parent directory, run `cp -R bindings/batteries ci/LDKSwift/Sources/LDKSwift`
13-
# docker run --name "swift-generator-shell" -i -v $PROJECT_DIRECTORY/ci:/ci -v $LDK_DIRECTORY:/ldk-c-bindings --rm -t swift-generation-ci /bin/bash
14-
15-
docker run --name "swift-generator-shell" -i -v $LDK_DIRECTORY:/ldk-c-bindings --rm -t swift-generation-ci /bin/bash
11+
if [[ "${MOUNT_CI_FOLDER}" = "true" ]]; then
12+
# use for direct ci folder access
13+
# note: batteries will be missing. In parent directory, run `cp -R bindings/batteries ci/LDKSwift/Sources/LDKSwift`
14+
cp -R bindings/batteries ci/LDKSwift/Sources/LDKSwift
15+
docker run --name "swift-generator-shell" -e MOUNTED_CI_FOLDER=true -i -v $PROJECT_DIRECTORY/ci:/ci -v $LDK_DIRECTORY:/ldk-c-bindings --rm -t swift-generation-ci /bin/bash
16+
elif [ "${MOUNT_CI_FOLDER}" = "false" ]; then
17+
docker run --name "swift-generator-shell" -e MOUNTED_CI_FOLDER=false -i -v $LDK_DIRECTORY:/ldk-c-bindings --rm -t swift-generation-ci /bin/bash
18+
else
19+
echo "Usage: ./docker_shell.sh /path/to/ldk-c-bindings true/false" && exit 1;
20+
fi

ci/run_tests.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
set -e
22
set -x
33

4-
# find all directories and files within LDKSwift sources, exclude batteries.
4+
# find all directories and files within LDKSwift sources, exclude batteries.
55
# If at least one result (xargs -r), remove recursively (rm -r)
6+
7+
# remove everything except the batteries folder from the sources
68
find ./LDKSwift/Sources/LDKSwift/* -maxdepth 0 -not -name 'batteries' | xargs -r rm -r
9+
710
# rm -i -r ./LDKSwift/Sources/LDKSwift/^(batteries)*
811

912
pushd ../

0 commit comments

Comments
 (0)