Skip to content

Commit

Permalink
Split build and test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
josesa-xx authored and sakai135 committed Sep 26, 2022
1 parent 1159cf2 commit 21bdf0f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ This will build and import the distro.
```sh
git clone https://github.com/sakai135/wsl-vpnkit.git
cd wsl-vpnkit/

./distro/test.sh
./build.sh
./test.sh
```

## Using `wsl-vpnkit` as a standalone script
Expand Down
20 changes: 20 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#! /bin/sh -xe

# run from repo root
# ./build.sh

USERPROFILE="$(powershell.exe -c 'Write-Host -NoNewline $env:USERPROFILE')"
DUMP=wsl-vpnkit.tar.gz
TAG_NAME=wslvpnkit

# build
docker build -t $TAG_NAME -f ./distro/Dockerfile .
CONTAINER_ID=$(docker create $TAG_NAME)
docker export $CONTAINER_ID | gzip > $DUMP
docker container rm $CONTAINER_ID
ls -la $DUMP

# reinstall
wsl.exe --unregister wsl-vpnkit || :
wsl.exe --import wsl-vpnkit "$USERPROFILE\\wsl-vpnkit" $DUMP --version 2
rm $DUMP
29 changes: 8 additions & 21 deletions distro/test.sh → test.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
#! /bin/sh -xe

# run from repo root
# ./distro/test.sh

USERPROFILE="$(powershell.exe -c 'Write-Host -NoNewline $env:USERPROFILE')"
DUMP=wsl-vpnkit.tar.gz
TAG_NAME=wslvpnkit

# build
docker build -t $TAG_NAME -f ./distro/Dockerfile .
CONTAINER_ID=$(docker create $TAG_NAME)
docker export $CONTAINER_ID | gzip > $DUMP
docker container rm $CONTAINER_ID
ls -la $DUMP

# reinstall
wsl.exe --unregister wsl-vpnkit || :
wsl.exe --import wsl-vpnkit "$USERPROFILE\\wsl-vpnkit" $DUMP --version 2
rm $DUMP
# ensuring distro is stopped before running tests
if wsl.exe -d wsl-vpnkit service wsl-vpnkit status; then
wsl.exe -d wsl-vpnkit service wsl-vpnkit stop || \
wsl.exe -t wsl-vpnkit
fi

# tests
for debug_value in '1' ''; do
for debug_value in '1' '2' ''; do
if [ -n "${debug_value}" ]; then
debug_str="DEBUG=${debug_value}"
else
debug_str=""
fi
echo "####### Test Round with debug_str [${debug_str}] #######"
echo "####### Test Round with debug_str [${debug_str}] #######" | grep --colour=always .

# start service
wsl.exe -d wsl-vpnkit ${debug_str} service wsl-vpnkit start
Expand Down Expand Up @@ -59,4 +46,4 @@ for debug_value in '1' ''; do
wsl.exe -d wsl-vpnkit sh -c 'echo 1 | source /etc/profile'
done

echo "$0 Finished"
echo "$0 Finished" | grep --colour=always .

0 comments on commit 21bdf0f

Please sign in to comment.