From 88c7bf2e33be67d25c0977c1b93136d5f082b281 Mon Sep 17 00:00:00 2001
From: Anton-4 <17049058+Anton-4@users.noreply.github.com>
Date: Tue, 27 Dec 2022 13:24:50 +0100
Subject: [PATCH 1/2] build tutorial with roc nightly
---
ci/get_latest_release_url.sh | 6 +++---
ci/get_today_release_url.sh | 16 ++++++++++++++++
www/build.sh | 25 ++++++++++++++++++++-----
3 files changed, 39 insertions(+), 8 deletions(-)
create mode 100755 ci/get_today_release_url.sh
diff --git a/ci/get_latest_release_url.sh b/ci/get_latest_release_url.sh
index 3d8e5f26b5..afd5950bbf 100755
--- a/ci/get_latest_release_url.sh
+++ b/ci/get_latest_release_url.sh
@@ -5,12 +5,12 @@
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -euxo pipefail
-LATEST_RELEASE_URL=`cat roc_releases.json | jq --arg arch $1 --arg today $(date +'%Y-%m-%d') '.[0] | .assets | map(.browser_download_url) | map(select(. | contains("\($arch)-\($today)"))) | .[0]'`
+LATEST_RELEASE_URL=`cat roc_releases.json | jq --arg arch $1 '.[0] | .assets | map(.browser_download_url) | map(select(. | contains("\($arch)-"))) | last'`
if [[ "$LATEST_RELEASE_URL" == "null" ]]
then
- echo "I expected to get a url but I got null instead. Today's release may not have been uploaded?"
+ echo "I expected to get a url but I got null instead. The provided argument for this bash script may not have had any matches when used as arch in the jq query above."
exit 1
else
echo $LATEST_RELEASE_URL | sed s/\"//g
-fi
\ No newline at end of file
+fi
diff --git a/ci/get_today_release_url.sh b/ci/get_today_release_url.sh
new file mode 100755
index 0000000000..7a9386f565
--- /dev/null
+++ b/ci/get_today_release_url.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+# assumes roc_releases.json is present
+
+# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
+set -euxo pipefail
+
+TODAY_RELEASE_URL=`cat roc_releases.json | jq --arg arch $1 --arg today $(date +'%Y-%m-%d') '.[0] | .assets | map(.browser_download_url) | map(select(. | contains("\($arch)-\($today)"))) | .[0]'`
+
+if [[ "$TODAY_RELEASE_URL" == "null" ]]
+then
+ echo "I expected to get a url but I got null instead. Today's release may not have been uploaded?"
+ exit 1
+else
+ echo $TODAY_RELEASE_URL | sed s/\"//g
+fi
diff --git a/www/build.sh b/www/build.sh
index f664aac337..e5bff959e4 100755
--- a/www/build.sh
+++ b/www/build.sh
@@ -52,11 +52,26 @@ mv generated-docs/ www/build/builtins # move all the folders to build/builtins/
# Manually add this tip to all the builtin docs.
find www/build/builtins -type f -name 'index.html' -exec sed -i 's!!
!' {} \;
-# TODO to enable this, we either need to install LLVM on Netlify or get it working using the dev backend.
-# echo 'Building tutorial.html from tutorial.md...'
-# mkdir www/build/tutorial
-# cargo run --release run www/generate_tutorial/src/tutorial.roc -- www/generate_tutorial/src/input/ www/build/tutorial/
-# mv www/build/tutorial/tutorial.html www/build/tutorial/index.html
+
+echo 'Fetching latest roc nightly...'
+curl https://api.github.com/repos/roc-lang/roc/releases > roc_releases.json
+# get the url of the latest release
+export ROC_RELEASE_URL=$(./ci/get_latest_release_url.sh linux_x86_64)
+# get roc release archive
+curl -OL $ROC_RELEASE_URL
+# extract archive
+ls | grep "roc_nightly" | xargs tar --one-top-level=roc_nightly -xzvf
+# delete archive
+ls | grep "roc_nightly.*tar.gz" | xargs rm
+
+echo 'Building tutorial.html from tutorial.md...'
+mkdir www/build/tutorial
+./roc_nightly/roc version
+./roc_nightly/roc run www/generate_tutorial/src/tutorial.roc -- www/generate_tutorial/src/input/ www/build/tutorial/
+mv www/build/tutorial/tutorial.html www/build/tutorial/index.html
+
+# cleanup roc
+rm -rf roc_nightly roc_releases.json
echo 'Generating CLI example platform docs...'
# Change ROC_DOCS_ROOT_DIR=builtins so that links will be generated relative to
From 61d8ef853908b16e08d99d5762376a0408066b96 Mon Sep 17 00:00:00 2001
From: Anton-4 <17049058+Anton-4@users.noreply.github.com>
Date: Tue, 27 Dec 2022 13:28:22 +0100
Subject: [PATCH 2/2] make nightly tests use today's release
---
.github/workflows/test_nightly_macos_apple_silicon.yml | 2 +-
.github/workflows/test_nightly_many_os.yml | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/test_nightly_macos_apple_silicon.yml b/.github/workflows/test_nightly_macos_apple_silicon.yml
index 0e6d765907..d84f818bda 100644
--- a/.github/workflows/test_nightly_macos_apple_silicon.yml
+++ b/.github/workflows/test_nightly_macos_apple_silicon.yml
@@ -16,7 +16,7 @@ jobs:
run: curl https://api.github.com/repos/roc-lang/roc/releases > roc_releases.json
- name: get the url of today`s release for macos apple silicon
- run: echo "RELEASE_URL=$(./ci/get_latest_release_url.sh silicon)" >> $GITHUB_ENV
+ run: echo "RELEASE_URL=$(./ci/get_today_release_url.sh silicon)" >> $GITHUB_ENV
- name: Get the archive from the url.
run: curl -OL ${{ env.RELEASE_URL }}
diff --git a/.github/workflows/test_nightly_many_os.yml b/.github/workflows/test_nightly_many_os.yml
index 11127bc11a..10734325c8 100644
--- a/.github/workflows/test_nightly_many_os.yml
+++ b/.github/workflows/test_nightly_many_os.yml
@@ -29,11 +29,11 @@ jobs:
- name: get the url of today`s release for linux (x86_64)
if: startsWith(matrix.os, 'ubuntu')
- run: echo "RELEASE_URL=$(./ci/get_latest_release_url.sh linux_x86_64)" >> $GITHUB_ENV
+ run: echo "RELEASE_URL=$(./ci/get_today_release_url.sh linux_x86_64)" >> $GITHUB_ENV
- name: get the url of today`s release for macos (x86_64)
if: startsWith(matrix.os, 'macos')
- run: echo "RELEASE_URL=$(./ci/get_latest_release_url.sh macos_x86_64)" >> $GITHUB_ENV
+ run: echo "RELEASE_URL=$(./ci/get_today_release_url.sh macos_x86_64)" >> $GITHUB_ENV
- name: get the archive from the url
run: curl -OL ${{ env.RELEASE_URL }}