From 7f19a04f0f049720ff5f84f3ab1aa81014f2f4ed Mon Sep 17 00:00:00 2001
From: Oran Agra <oran@redislabs.com>
Date: Sun, 12 Jul 2020 13:55:26 +0300
Subject: [PATCH] update release scripts for new hosts, and CI to run more
 tests (#7480)

* update daily CI to include cluster and sentinel tests
* update daily CI to run when creating a new release
* update release scripts to work on the new redis.io hosts
---
 .github/workflows/daily.yml             | 26 ++++++++++++++++---
 utils/releasetools/01_create_tarball.sh |  3 +--
 utils/releasetools/02_upload_tarball.sh | 22 ++++++++++++++---
 utils/releasetools/03_test_release.sh   | 33 +++++++++++++------------
 utils/releasetools/04_release_hash.sh   | 10 ++++++--
 5 files changed, 68 insertions(+), 26 deletions(-)

diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml
index acc4dd33a..4d54fbc42 100644
--- a/.github/workflows/daily.yml
+++ b/.github/workflows/daily.yml
@@ -1,14 +1,16 @@
 name: Daily
 
 on:
+  release:
+    types: [created]
   schedule:
-    - cron: '0 7 * * *'
+    - cron: '0 0 * * *'
 
 jobs:
 
   test-jemalloc:
     runs-on: ubuntu-latest
-    timeout-minutes: 1200
+    timeout-minutes: 14400
     steps:
     - uses: actions/checkout@v1
     - name: make
@@ -19,10 +21,14 @@ jobs:
         ./runtest --accurate --verbose
     - name: module api test
       run: ./runtest-moduleapi --verbose
+    - name: sentinel tests
+      run: ./runtest-sentinel
+    - name: cluster tests
+      run: ./runtest-cluster
 
   test-libc-malloc:
     runs-on: ubuntu-latest
-    timeout-minutes: 1200
+    timeout-minutes: 14400
     steps:
     - uses: actions/checkout@v1
     - name: make
@@ -33,9 +39,14 @@ jobs:
         ./runtest --accurate --verbose
     - name: module api test
       run: ./runtest-moduleapi --verbose
+    - name: sentinel tests
+      run: ./runtest-sentinel
+    - name: cluster tests
+      run: ./runtest-cluster
 
   test-32bit:
     runs-on: ubuntu-latest
+    timeout-minutes: 14400
     steps:
     - uses: actions/checkout@v1
     - name: make
@@ -50,9 +61,14 @@ jobs:
       run: |
         make -C tests/modules 32bit # the script below doesn't have an argument, we must build manually ahead of time
         ./runtest-moduleapi --verbose
+    - name: sentinel tests
+      run: ./runtest-sentinel
+    - name: cluster tests
+      run: ./runtest-cluster
 
   test-tls:
     runs-on: ubuntu-latest
+    timeout-minutes: 14400
     steps:
     - uses: actions/checkout@v1
     - name: make
@@ -65,6 +81,10 @@ jobs:
         ./runtest --accurate --verbose --tls
     - name: module api test
       run: ./runtest-moduleapi --verbose --tls
+    - name: sentinel tests
+      run: ./runtest-sentinel
+    - name: cluster tests
+      run: ./runtest-cluster
 
   test-valgrind:
     runs-on: ubuntu-latest
diff --git a/utils/releasetools/01_create_tarball.sh b/utils/releasetools/01_create_tarball.sh
index 54bca8c04..366a61e2c 100755
--- a/utils/releasetools/01_create_tarball.sh
+++ b/utils/releasetools/01_create_tarball.sh
@@ -1,14 +1,13 @@
 #!/bin/sh
 if [ $# != "1" ]
 then
-    echo "Usage: ./mkrelease.sh <git-ref>"
+    echo "Usage: ./utils/releasetools/01_create_tarball.sh <version_tag>"
     exit 1
 fi
 
 TAG=$1
 TARNAME="redis-${TAG}.tar"
 echo "Generating /tmp/${TARNAME}"
-cd ~/hack/redis
 git archive $TAG --prefix redis-${TAG}/ > /tmp/$TARNAME || exit 1
 echo "Gizipping the archive"
 rm -f /tmp/$TARNAME.gz
diff --git a/utils/releasetools/02_upload_tarball.sh b/utils/releasetools/02_upload_tarball.sh
index ed7065388..6400efad7 100755
--- a/utils/releasetools/02_upload_tarball.sh
+++ b/utils/releasetools/02_upload_tarball.sh
@@ -1,6 +1,22 @@
 #!/bin/bash
+if [ $# != "1" ]
+then
+    echo "Usage: ./utils/releasetools/02_upload_tarball.sh <version_tag>"
+    exit 1
+fi
+
 echo "Uploading..."
-scp /tmp/redis-${1}.tar.gz antirez@antirez.com:/var/virtual/download.redis.io/httpdocs/releases/
-echo "Updating web site... (press any key if it is a stable release, or Ctrl+C)"
+scp /tmp/redis-${1}.tar.gz ubuntu@host.redis.io:/var/www/download/releases/
+echo "Updating web site... "
+echo "Please check the github action tests for the release."
+echo "Press any key if it is a stable release, or Ctrl+C to abort"
 read x
-ssh antirez@antirez.com "cd /var/virtual/download.redis.io/httpdocs; ./update.sh ${1}"
+ssh ubuntu@host.redis.io "cd /var/www/download;
+                          rm -rf redis-${1}.tar.gz;
+                          wget http://download.redis.io/releases/redis-${1}.tar.gz;
+                          tar xvzf redis-${1}.tar.gz;
+                          rm -rf redis-stable;
+                          mv redis-${1} redis-stable;
+                          tar cvzf redis-stable.tar.gz redis-stable;
+                          rm -rf redis-${1}.tar.gz;
+                          "
diff --git a/utils/releasetools/03_test_release.sh b/utils/releasetools/03_test_release.sh
index 3dfdcd6a3..169e965d5 100755
--- a/utils/releasetools/03_test_release.sh
+++ b/utils/releasetools/03_test_release.sh
@@ -1,7 +1,8 @@
 #!/bin/sh
+set -e
 if [ $# != "1" ]
 then
-    echo "Usage: ${0} <git-ref>"
+    echo "Usage: ./utils/releasetools/03_test_release.sh <version_tag>"
     exit 1
 fi
 
@@ -9,18 +10,18 @@ TAG=$1
 TARNAME="redis-${TAG}.tar.gz"
 DOWNLOADURL="http://download.redis.io/releases/${TARNAME}"
 
-ssh antirez@metal "export TERM=xterm;
-                   cd /tmp;
-                   rm -rf test_release_tmp_dir;
-                   cd test_release_tmp_dir;
-                   rm -f $TARNAME;
-                   rm -rf redis-${TAG};
-                   wget $DOWNLOADURL;
-                   tar xvzf $TARNAME;
-                   cd redis-${TAG};
-                   make;
-                   ./runtest;
-                   ./runtest-sentinel;
-                   if [ -x runtest-cluster ]; then
-                       ./runtest-cluster;
-                   fi"
+echo "Doing sanity test on the actual tarball"
+
+cd /tmp
+rm -rf test_release_tmp_dir
+cd test_release_tmp_dir
+rm -f $TARNAME
+rm -rf redis-${TAG}
+wget $DOWNLOADURL
+tar xvzf $TARNAME
+cd redis-${TAG}
+make
+./runtest
+./runtest-sentinel
+./runtest-cluster
+./runtest-moduleapi
diff --git a/utils/releasetools/04_release_hash.sh b/utils/releasetools/04_release_hash.sh
index 9d5c6ad4b..bc1ebb66c 100755
--- a/utils/releasetools/04_release_hash.sh
+++ b/utils/releasetools/04_release_hash.sh
@@ -1,8 +1,14 @@
 #!/bin/bash
+if [ $# != "1" ]
+then
+    echo "Usage: ./utils/releasetools/04_release_hash.sh <version_tag>"
+    exit 1
+fi
+
 SHA=$(curl -s http://download.redis.io/releases/redis-${1}.tar.gz | shasum -a 256 | cut -f 1 -d' ')
 ENTRY="hash redis-${1}.tar.gz sha256 $SHA http://download.redis.io/releases/redis-${1}.tar.gz"
 echo $ENTRY >> ~/hack/redis-hashes/README
-vi ~/hack/redis-hashes/README
+vi ../redis-hashes/README
 echo "Press any key to commit, Ctrl-C to abort)."
 read yes
-(cd ~/hack/redis-hashes; git commit -a -m "${1} hash."; git push)
+(cd ../redis-hashes; git commit -a -m "${1} hash."; git push)