Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to test release #832

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ erl_crash.dump
/archethic-proposal-validator
/.devnet
/data*
/test_release

# autogenerated by archethic.testnet mix task
/docker-compose.json
Expand Down
2 changes: 2 additions & 0 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ config :archethic,
"data_#{System.get_env("ARCHETHIC_CRYPTO_SEED", "node1")}"
)

config :archethic, :root_mut_dir, System.get_env("ARCHETHIC_ROOT_MUT_DIR", "./data")

config :telemetry_poller, :default, period: 5_000

# Set a higher stacktrace during development. Avoid configuring such
Expand Down
8 changes: 2 additions & 6 deletions lib/mix/tasks/clean_db.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ defmodule Mix.Tasks.Archethic.CleanDb do
use Mix.Task

def run(_arg) do
"_build/dev/lib/archethic/data*"
|> Path.wildcard()
|> Enum.each(fn path ->
IO.puts("#{path} will be removed")
File.rm_rf!(path)
end)
Application.get_env(:archethic, :root_mut_dir)
|> File.rm_rf!()

IO.puts("Database dropped")
end
Expand Down
97 changes: 97 additions & 0 deletions scripts/test-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/bin/bash

set -e
trap 'echo "******* FAILED *******" 1>&2' ERR

SCRIPT_DIR=$(dirname $(readlink -f $0))
INSTALL_DIR=$(readlink -f $SCRIPT_DIR/../test_release)

UPGRADE=0
INSTALL=0

usage() {
echo "Usage:"
echo ""
echo " Create a test release Archethic node binary"
echo ""
echo " " release.sh -i " Create and install release"
echo " " release.sh -u " Upgrade the release"
echo " " release.sh -h " Print the help usage"
echo ""
}

while getopts ":uih" option
do
case "${option}"
in
u) UPGRADE=1;;
i) INSTALL=1;;
h)
usage
exit 0
;;
*)
usage
exit 1
;;
esac
done
shift $((OPTIND -1))



if [[ $(($UPGRADE ^ $INSTALL)) == 1 ]]
then
cd $SCRIPT_DIR/..

# Install updated versions of hex/rebar
mix local.rebar --force
mix local.hex --if-missing --force

export MIX_ENV=dev

# Fetch deps and compile
mix deps.get

# Builds WEB assets in production mode
cd assets
npm i
cd ..
mix assets.saas
mix assets.deploy

VERSION=$(grep 'version:' mix.exs | cut -d '"' -f2)
echo ""
echo "Version: ${VERSION}"
echo "Installation dir: ${INSTALL_DIR}"

mkdir -p $INSTALL_DIR

if [ $UPGRADE == 1 ]
then
# Build upgrade releases
echo "Build the upgrade release"
MIX_ENV=dev mix distillery.release --upgrade

echo "Copy upgraded release into ${INSTALL_DIR}/releases/${VERSION}"
mkdir -p $INSTALL_DIR/releases/$VERSION
cp _build/dev/rel/archethic_node/releases/$VERSION/archethic_node.tar.gz $INSTALL_DIR/releases/$VERSION/archethic_node.tar.gz

echo "Run the upgrade"
$INSTALL_DIR/bin/archethic_node upgrade $VERSION
else
# Build and install the releases

echo "Generate release"
MIX_ENV=dev mix distillery.release

echo "Install release"
tar zxvf _build/dev/rel/archethic_node/releases/$VERSION/archethic_node.tar.gz -C $INSTALL_DIR
echo "Release has been installed on ${INSTALL_DIR}"
echo "To run the release: ./test_release/bin/archethic_node console"
echo "To test the upgrade, change git branch, update mix.exs version and run ./script/test-release.sh -u"
fi
else
usage
exit 1
fi