Skip to content

Commit

Permalink
Merge pull request #118 from roc-lang/use-latest-release-examples
Browse files Browse the repository at this point in the history
use examples of latest release for test_latest_release.yml
  • Loading branch information
Anton-4 authored Nov 4, 2023
2 parents bb98ddd + eb8afaa commit 06bad99
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test_latest_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion ci/all_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions ci/get_latest_release_examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/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

cd ..
5 changes: 4 additions & 1 deletion ci/test_latest_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 06bad99

Please sign in to comment.