From 09ef8c7534c267eb33105fd6bc1ee679984d83bd Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sat, 4 Nov 2023 14:23:53 +0100 Subject: [PATCH 1/2] use examples of latest release --- .github/workflows/test_latest_release.yml | 5 ++++- ci/all_tests.sh | 3 ++- ci/get_latest_release_examples.sh | 20 ++++++++++++++++++++ ci/test_latest_release.sh | 5 ++++- 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 ci/get_latest_release_examples.sh diff --git a/.github/workflows/test_latest_release.yml b/.github/workflows/test_latest_release.yml index bc364f89..a0ab659a 100644 --- a/.github/workflows/test_latest_release.yml +++ b/.github/workflows/test_latest_release.yml @@ -12,6 +12,9 @@ jobs: runs-on: [ubuntu-20.04] steps: - uses: actions/checkout@v3 + + - name: Get the examples of the latest basic-cli release + run: ./ci/get_latest_release_examples.sh - name: Run all tests with latest roc release + latest basic-cli release - run: ./ci/test_latest_release.sh + run: EXAMPLES_DIR=./latest-release-examples ./ci/test_latest_release.sh diff --git a/ci/all_tests.sh b/ci/all_tests.sh index 3aaeb0b4..9b3ada15 100755 --- a/ci/all_tests.sh +++ b/ci/all_tests.sh @@ -5,7 +5,8 @@ set -euxo pipefail roc='./roc_nightly/roc' -examples_dir='./examples/' +# Use EXAMPLES_DIR if set, otherwise use a default value +examples_dir="${EXAMPLES_DIR:-./examples/}" # roc check for roc_file in $examples_dir*.roc; do diff --git a/ci/get_latest_release_examples.sh b/ci/get_latest_release_examples.sh new file mode 100644 index 00000000..5b842ef8 --- /dev/null +++ b/ci/get_latest_release_examples.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +set -euxo pipefail + +mkdir latest-basic-cli-src && cd latest-basic-cli-src + +# get basic-cli +git clone --depth 1 https://github.com/roc-lang/basic-cli + +# Fetch all tags +git fetch --tags + +# Get the latest tag name +latestTag=$(git describe --tags $(git rev-list --tags --max-count=1)) + +# Checkout the latest tag +git checkout $latestTag + +mv basic-cli/examples ../latest-release-examples \ No newline at end of file diff --git a/ci/test_latest_release.sh b/ci/test_latest_release.sh index a619acee..bbcc9eaf 100755 --- a/ci/test_latest_release.sh +++ b/ci/test_latest_release.sh @@ -30,8 +30,11 @@ mv "$NIGHTLY_FOLDER" roc_nightly CLI_RELEASES_JSON=$(curl -s https://api.github.com/repos/roc-lang/basic-cli/releases) CLI_RELEASE_URL=$(echo $CLI_RELEASES_JSON | jq -r '.[0].assets | .[] | select(.name | test("\\.tar\\.br$")) | .browser_download_url') +# Use EXAMPLES_DIR if set, otherwise use a default value +examples_dir="${EXAMPLES_DIR:-./examples/}" + # Use the latest basic-cli release as the platform for every example -sed -i "s|../src/main.roc|$CLI_RELEASE_URL|g" ./examples/*.roc +sed -i "s|../src/main.roc|$CLI_RELEASE_URL|g" $examples_dir/*.roc # Install required packages for tests if they're not already available command -v ncat &>/dev/null || sudo apt install -y ncat From eb8afaab506d477289350e67d88fb8542cd2818c Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sat, 4 Nov 2023 14:27:53 +0100 Subject: [PATCH 2/2] forgot cd --- ci/get_latest_release_examples.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/get_latest_release_examples.sh b/ci/get_latest_release_examples.sh index 5b842ef8..4aa85313 100644 --- a/ci/get_latest_release_examples.sh +++ b/ci/get_latest_release_examples.sh @@ -17,4 +17,6 @@ latestTag=$(git describe --tags $(git rev-list --tags --max-count=1)) # Checkout the latest tag git checkout $latestTag -mv basic-cli/examples ../latest-release-examples \ No newline at end of file +mv basic-cli/examples ../latest-release-examples + +cd .. \ No newline at end of file