Skip to content

Commit

Permalink
chore(release): add a simple script for testing the release on *nix
Browse files Browse the repository at this point in the history
  • Loading branch information
eysi09 committed Feb 24, 2020
1 parent 537b7d9 commit 5647522
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 0 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ To make a new release, set your current working directory to the garden root dir
* On a **Windows** machine, run `garden dev --hot=vote` in the `vote` example project.
* Change a file in the `vote` service and verify that the hot reload was successful.
* Open the dashboard, verify that the initial page loads without errors.
* On **macOS** or **Linux**, run the `./bin/test-release <version>` script. The script runs some simple tests to sanity check the release.
5. Go to our Github [Releases page](https://github.com/garden-io/garden/releases) and click the **Edit** button for the draft just created from CI. Note that for drafts, a new one is always created instead of replacing a previous one.
6. Write release notes. The notes should give an overview of the release and mention all relevant features. They should also **acknowledge all external contributors** and contain the changelog for that release.
* To generate a changelog for just that tag, run `git-chglog <tag-name>`
Expand Down
111 changes: 111 additions & 0 deletions bin/test-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/bin/bash -e

# Script that downloads a release based on the version argument, and runs some simple tests to sanity check it.

garden_root=$(cd `dirname $0` && cd .. && pwd)
version=$1

if [ ! "$version" ]; then
echo "Version is missing"
exit 1
fi

download_release() {
if [ "$(uname -s)" = "Darwin" ]; then
os=macos
else
os=`ldd 2>&1|grep musl >/dev/null && echo "alpine" || echo "linux"`
fi

platform=${os}-amd64
filename="garden-${version}-${platform}.tar.gz"
url="https://github.com/garden-io/garden/releases/download/${version}/${filename}"
dir=${HOME}/.garden-release
target_path=${dir}/bin

echo "→ Downloading release ${version} to ${dir}"
rm -rf $target_path
mkdir -p $target_path
cd $dir
curl -sLO $url
echo "→ Extracting to ${target_path}"
tar -xzf $filename
rm $filename
cp -r ${platform}/* bin/
chmod +x bin/garden
rm -rf $platform
cd $garden_root
return 0
}

test_release() {
# Mac doesn't have a timeout command so we alias to gtimeout (or exit if gtimeout is not installed).
if [[ "$OSTYPE" == "darwin"* ]]; then
if ! [ -x "$(command -v gtimeout)" ]; then
echo "Command gtimeout is missing - You can install it with 'brew install gtimeout' on macOS"
return 1
else
alias timeout=gtimeout
fi
fi

if [ ! "$version" ]; then
echo "Version is missing"
return 1
fi

garden_release=${HOME}/.garden-release/bin/garden

echo "→ Verify version"
release_version=$(${garden_release} --version)

echo $release_version

if [ "$version" != "v$release_version" ]; then
echo "Versions don't match, ${version} and ${release_version}"
return 1
fi

cd examples/demo-project
echo ""
echo "→ Running 'garden build' in demo project"
echo ""
${garden_release} build
echo ""
echo "→ Running 'garden deploy' in demo project"
echo ""
${garden_release} deploy
echo ""
echo "→ Running 'garden dev in' demo project - exits after 1 minute"
echo ""
# Can't call the gr alias with
gtimeout 1m ${garden_release} dev

echo ""
echo "→ Running 'garden dev' in vote project - exits after 2 minutes, use the chance to change services and test the dashboard"
echo "→ Try e.g. to change the status in the POST method in this file: ${garden_root}/examples/vote/api/app.py"
echo "→ It should break the integ test"
echo ""
cd ..
cd vote
gtimeout 2m ${garden_release} dev

echo ""
echo "→ Running 'garden deploy --hot=node-service' in hot-reload project - exits after 1 minute, use the chance to test if hot-reload works"
echo "→ Try e.g. to update this file: ${garden_root}/examples/hot-reload/node-service/app.js"
echo ""
cd ..
cd hot-reload
gtimeout 1m ${garden_release} deploy --hot node-service

# Remove the alias we set above
if [[ "$OSTYPE" == "darwin"* ]]; then
unalias timeout
fi

cd $garden_root
echo "Done!"
}

download_release
test_release

0 comments on commit 5647522

Please sign in to comment.