Skip to content

Commit

Permalink
Install .swift-version toolchain on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun committed Oct 3, 2020
1 parent 8cc56bf commit 61a6b65
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
export SWIFTENV_ROOT="$HOME/.swiftenv"
export PATH="$SWIFTENV_ROOT/bin:$PATH"
eval "$(swiftenv init -)"
./scripts/install-toolchain.sh
swiftenv install $TOOLCHAIN_DOWNLOAD
make perf-tester
node ci/perf-tester
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
export SWIFTENV_ROOT="$HOME/.swiftenv"
export PATH="$SWIFTENV_ROOT/bin:$PATH"
eval "$(swiftenv init -)"
./scripts/install-toolchain.sh
swiftenv install $TOOLCHAIN_DOWNLOAD
make bootstrap
make test
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ MAKEFILE_DIR := $(dir $(lastword $(MAKEFILE_LIST)))

.PHONY: bootstrap
bootstrap:
./scripts/install-toolchain.sh
npm install

.PHONY: build
Expand Down
41 changes: 41 additions & 0 deletions scripts/install-toolchain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
set -eu

scripts_dir="$(cd "$(dirname $0)" && pwd)"

swift_version="$(cat $scripts_dir/../.swift-version)"
swift_tag="swift-$swift_version"

if [ -z "$(which swiftenv)" ]; then
echo "swiftenv not installed, please install it before this script."
exit 1
fi

if [ ! -z "$(swiftenv versions | grep $swift_version)" ]; then
echo "$swift_version is already installed."
exit 0
fi

case $(uname -s) in
Darwin)
toolchain_download="$swift_tag-osx.tar.gz"
;;
Linux)
if [ $(grep RELEASE /etc/lsb-release) == "DISTRIB_RELEASE=18.04" ]; then
toolchain_download="$swift_tag-ubuntu18.04.tar.gz"
elif [ $(grep RELEASE /etc/lsb-release) == "DISTRIB_RELEASE=20.04" ]; then
toolchain_download="$swift_tag-ubuntu20.04.tar.gz"
else
echo "Unknown Ubuntu version"
exit 1
fi
;;
*)
echo "Unrecognised platform $(uname -s)"
exit 1
;;
esac

toolchain_download_url="https://github.com/swiftwasm/swift/releases/download/$swift_tag/$toolchain_download"

swiftenv install "$toolchain_download_url"

0 comments on commit 61a6b65

Please sign in to comment.