Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GToolkit - Add as Supported Platform #589

Merged
merged 6 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
- Moose64-10
- Moose64-9.0
- Moose64-8.0
- GToolkit64-release
timeout-minutes: [ 15 ]
exclude: # exclude 32bit builds on macOS
- os: macos-latest
Expand Down
49 changes: 25 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,30 @@ they can take up a lot of space on your drive.*

## <a name="images"/>List of Supported Images

| [Squeak][squeak] | [Pharo][pharo] | [GemStone][gemstone] | [Moose][moose] |
| ---------------- | ---------------- | -------------------- | --------------- |
| `Squeak64-trunk` | `Pharo64-alpha` | `GemStone64-3.5.x` | `Moose64-trunk` |
| `Squeak64-6.0` | `Pharo64-stable` | `GemStone64-3.4.x` | `Moose64-10` |
| `Squeak64-5.3` | `Pharo64-11` | `GemStone64-3.3.x` | `Moose64-9.0` |
| `Squeak64-5.2` | `Pharo64-10` | `GemStone64-3.2.x` | `Moose64-8.0` |
| `Squeak64-5.1` | `Pharo64-9.0` | `GemStone64-3.1.0.x` | `Moose64-7.0` |
| `Squeak32-trunk` | `Pharo64-8.0` | `Gemstone64-2.4.x` | `Moose32-trunk` |
| `Squeak32-6.0` | `Pharo64-7.0` | | `Moose32-6.1` |
| `Squeak32-5.3` | `Pharo64-6.1` | | `Moose32-6.0` |
| `Squeak32-5.2` | `Pharo32-6.0` | | |
| `Squeak32-5.1` | `Pharo32-alpha` | | |
| `Squeak32-5.0` | `Pharo32-stable` | | |
| `Squeak32-4.6` | `Pharo32-11` | | |
| `Squeak32-4.5` | `Pharo32-10` | | |
| | `Pharo32-9.0` | | |
| | `Pharo32-8.0` | | |
| | `Pharo32-7.0` | | |
| | `Pharo32-6.1` | | |
| | `Pharo32-6.0` | | |
| | `Pharo32-5.0` | | |
| | `Pharo32-4.0` | | |
| | `Pharo32-3.0` | | |
| | | | |
| [Squeak][squeak] | [Pharo][pharo] | [GemStone][gemstone] | [Moose][moose] | [GToolkit][gtoolkit] |
| ---------------- | ---------------- | -------------------- | --------------- | -------------------- |
| `Squeak64-trunk` | `Pharo64-alpha` | `GemStone64-3.5.x` | `Moose64-trunk` | `GToolkit64-release` |
| `Squeak64-6.0` | `Pharo64-stable` | `GemStone64-3.4.x` | `Moose64-10` | |
| `Squeak64-5.3` | `Pharo64-11` | `GemStone64-3.3.x` | `Moose64-9.0` | |
| `Squeak64-5.2` | `Pharo64-10` | `GemStone64-3.2.x` | `Moose64-8.0` | |
| `Squeak64-5.1` | `Pharo64-9.0` | `GemStone64-3.1.0.x` | `Moose64-7.0` | |
| `Squeak32-trunk` | `Pharo64-8.0` | `Gemstone64-2.4.x` | `Moose32-trunk` | |
| `Squeak32-6.0` | `Pharo64-7.0` | | `Moose32-6.1` | |
| `Squeak32-5.3` | `Pharo64-6.1` | | `Moose32-6.0` | |
| `Squeak32-5.2` | `Pharo32-6.0` | | | |
| `Squeak32-5.1` | `Pharo32-alpha` | | | |
| `Squeak32-5.0` | `Pharo32-stable` | | | |
| `Squeak32-4.6` | `Pharo32-11` | | | |
| `Squeak32-4.5` | `Pharo32-10` | | | |
| | `Pharo32-9.0` | | | |
| | `Pharo32-8.0` | | | |
| | `Pharo32-7.0` | | | |
| | `Pharo32-6.1` | | | |
| | `Pharo32-6.0` | | | |
| | `Pharo32-5.0` | | | |
| | `Pharo32-4.0` | | | |
| | `Pharo32-3.0` | | | |
| | | | | |


## Templates
Expand Down Expand Up @@ -739,6 +739,7 @@ list. Please add [`[ci skip]`][ci_skip] to your commit message.*
[gitlab_ci_cd]: https://about.gitlab.com/features/gitlab-ci-cd/
[gofer]: http://www.lukas-renggli.ch/blog/gofer
[gs]: https://github.com/hpi-swa/smalltalkCI/issues/28
[gtoolkit]: https://gtoolkit.com
[issues]: https://github.com/hpi-swa/smalltalkCI/issues
[mc_baseline]: https://github.com/dalehenrich/metacello-work/blob/master/docs/GettingStartedWithGitHub.md#create-baseline
[mc_configuration]: https://github.com/dalehenrich/metacello-work/blob/master/docs/GettingStartedWithGitHub.md#create-configuration
Expand Down
227 changes: 227 additions & 0 deletions gtoolkit/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
################################################################################
# This file provides GToolkit support for smalltalkCI. It is used in the context
# of a smalltalkCI build and it is not meant to be executed by itself.
################################################################################

gtoolkit::latest_release_version() {

# Get release JSON from GH API (via https://fabianlee.org/2021/02/16/bash-determining-latest-github-release-tag-and-version/)
local url=https://api.github.com/repos/feenkcom/gtoolkit/releases/latest
local json=$(curl -sL $url)

# Find the tag name line in the JSON
local versionLine=$(echo "$json" | grep tag_name)

# Scrape the value (adapted from https://stackoverflow.com/a/19394523)
local version=$(echo "$versionLine" | awk -F ': ' '/tag_name/ {gsub("\",?","");print $2}')

echo "$version"
}

gtoolkit::architecture() {
local gt_architecture

case "$(hardware_platform)" in
"arm64")
gt_architecture="aarch64"
;;
"x86_64")
gt_architecture="x86_64"
;;
esac

echo "$gt_architecture"
}

gtoolkit::archive_basename() {
local gt_architecture=$(gtoolkit::architecture)
local gt_platform
local gt_release=$(gtoolkit::latest_release_version)

if is_linux_build; then
gt_platform="Linux"
elif is_windows_build; then
if [[ "$gt_architecture" == "aarch64" ]]; then
print_error_and_exit "unsupported build platform '$(uname -s)'."
fi
gt_platform="Windows"
elif is_mac_build; then
gt_platform="MacOS"
else
print_error_and_exit "unsupported build platform '$(uname -s)'."
fi

echo "GlamorousToolkit-${gt_platform}-${gt_architecture}-${gt_release}"
}

gtoolkit::archive_url() {
local gt_release=$(gtoolkit::latest_release_version)
local url_base="https://github.com/feenkcom/gtoolkit/releases/download"

echo "${url_base}/${gt_release}/$(gtoolkit::archive_basename).zip"
}

gtoolkit::vm_path() {
local result

if is_linux_build; then
result="bin/GlamorousToolkit-cli"
elif is_windows_build; then
result="bin/GlamorousToolkit-cli.exe"
elif is_mac_build; then
result="GlamorousToolkit.app/Contents/MacOS/GlamorousToolkit-cli"
else
print_error_and_exit "unsupported build platform '$(uname -s)'."
fi

echo "${result}"
}

################################################################################
# Download and move vm if necessary.
# Globals:
# SMALLTALK_CI_VM
################################################################################

gtoolkit::prepare_vm() {
local vm_path="$(gtoolkit::vm_path)"

# Skip in case vm is already set up
if is_file "${SMALLTALK_CI_VM}"; then
return 0
fi

export SMALLTALK_CI_VM="${SMALLTALK_CI_BUILD}/${vm_path}"

chmod +x "${SMALLTALK_CI_VM}"

if ! is_file "${SMALLTALK_CI_VM}"; then
print_error_and_exit "Unable to set vm up at '${SMALLTALK_CI_VM}'."
fi
}

################################################################################
# Download GT (image and VM) if necessary and copy it to build folder.
# Globals:
# SMALLTALK_CI_BUILD
# SMALLTALK_CI_CACHE
# Arguments:
# smalltalk_name
################################################################################

gtoolkit::prepare_gt() {
local smalltalk_name=$1 #Ignore currently because we are only supporting `release`
fniephaus marked this conversation as resolved.
Show resolved Hide resolved
local gtoolkit_image_url="$(gtoolkit::archive_url)"
local download_name="$(gtoolkit::archive_basename)"
local target="${SMALLTALK_CI_CACHE}/${download_name}.zip"

if ! is_file "${target}"; then
fold_start download_image "Downloading ${smalltalk_name} image..."
download_file "${gtoolkit_image_url}" "${target}"
fold_end download_image
fi

print_info "Extracting GT..."
extract_file "${target}" "${SMALLTALK_CI_BUILD}"
echo "${download_name}" > "${SMALLTALK_CI_BUILD}"/version

print_info "Preparing GToolkit image..."
if ! is_file "${SMALLTALK_CI_IMAGE}"; then
mv "${SMALLTALK_CI_BUILD}"/*.image "${SMALLTALK_CI_IMAGE}"
mv "${SMALLTALK_CI_BUILD}"/*.changes "${SMALLTALK_CI_CHANGES}"
fi

if ! vm_is_user_provided; then
gtoolkit::prepare_vm
fi

if ! is_file "${SMALLTALK_CI_IMAGE}"; then
print_error_and_exit "Failed to prepare image at '${SMALLTALK_CI_IMAGE}'."
fi
}


################################################################################
# Run a Smalltalk script.
# NB. copy/pasted from Pharo
################################################################################
gtoolkit::run_script() {
local script=$1
local vm_flags=""
local resolved_vm="${config_vm:-${SMALLTALK_CI_VM}}"
local resolved_image="$(resolve_path "${config_image:-${SMALLTALK_CI_IMAGE}}")"

if ! is_travis_build && ! is_headless; then
vm_flags="--no-quit"
fi

run_script "${resolved_vm}" "${resolved_image}" eval ${vm_flags} "${script}"
}

################################################################################
# Load project into GToolkit image.
# NB. copy/pasted from Pharo
################################################################################
gtoolkit::load_project() {
gtoolkit::run_script "
| smalltalkCI |
$(conditional_debug_halt)
[ | metacello |
metacello := Metacello new
baseline: 'SmalltalkCI';
repository: 'filetree://$(resolve_path "${SMALLTALK_CI_HOME}/repository")';
onUpgrade: [ :ex | ex useIncoming ].
(Metacello canUnderstand: #onConflictUseIncoming)
ifTrue: [ metacello onConflictUseIncoming ]
ifFalse: [ metacello onConflict: [ :ex | ex useIncoming ] ].
metacello load ]
on: Warning
do: [ :w | w resume ].
smalltalkCI := Smalltalk at: #SmalltalkCI.
smalltalkCI load: '$(resolve_path "${config_ston}")'.
(smalltalkCI isHeadless or: [ smalltalkCI promptToProceed ])
ifTrue: [ smalltalkCI saveAndQuitImage ]
"
}

################################################################################
# Run tests for project.
# NB. copy/pasted from Pharo
################################################################################
gtoolkit::test_project() {
gtoolkit::run_script "
| smalltalkCI |
$(conditional_debug_halt)
smalltalkCI := Smalltalk
at: #SmalltalkCI
ifAbsent: [
[ | metacello |
metacello := Metacello new
baseline: 'SmalltalkCI';
repository: 'filetree://$(resolve_path "${SMALLTALK_CI_HOME}/repository")';
onUpgrade: [ :ex | ex useIncoming ].
(Metacello canUnderstand: #onConflictUseIncoming)
ifTrue: [ metacello onConflictUseIncoming ]
ifFalse: [ metacello onConflict: [ :ex | ex useIncoming ] ].
metacello load ]
on: Warning
do: [ :w | w resume ].
Smalltalk at: #SmalltalkCI ].
smalltalkCI test: '$(resolve_path "${config_ston}")'
"
}

################################################################################
# Main entry point for GToolkit builds.
################################################################################
run_build() {
if ! image_is_user_provided; then
gtoolkit::prepare_gt "${config_smalltalk}"
fi

if ston_includes_loading; then
gtoolkit::load_project
check_and_consume_build_status_file
fi
gtoolkit::test_project
}
12 changes: 12 additions & 0 deletions helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ is_msys2_build() {
[[ $(uname -s) = "MSYS_NT-"* ]]
}

is_mac_build() {
[[ $(uname -s) = "Darwin" ]]
}

is_windows_build() {
is_cygwin_build ] || is_mingw64_build || is_msys2_build
}

hardware_platform() {
echo "$(uname -m)"
}

is_sudo_enabled() {
$(sudo -n true > /dev/null 2>&1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ testPromptToProceed
requests like confirm: . As promptToProceed only really makes sense in an interactive context,
always test with the MorphicUIManager"
|oldUIManager|

"Skip this test on GToolkit"
(Smalltalk hasClassNamed: 'GtImageSetup') ifTrue: [ ^ self ].

oldUIManager := UIManager default.
UIManager default: MorphicUIManager new.

Expand Down
7 changes: 6 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ select_smalltalk() {
GemStone64-3.5.0 GemStone64-3.4.3 GemStone64-3.3.9
GemStone64-3.3.2 GemStone64-3.3.0 GemStone64-3.2.12
GemStone64-3.1.0.6
GToolkit64-release
Moose64-trunk Moose64-10 Moose64-9.0 Moose64-8.0 Moose64-7.0
Moose32-trunk Moose32-8.0 Moose32-7.0 Moose32-6.1 Moose32-6.0"

Expand All @@ -247,7 +248,7 @@ select_smalltalk() {
set -o posix # fixes SIGINT during select
select selection in $images; do
case "${selection}" in
Squeak*|Pharo*|GemStone*|Moose*)
Squeak*|Pharo*|GemStone*|GToolkit*|Moose*)
config_smalltalk="${selection}"
break
;;
Expand Down Expand Up @@ -501,6 +502,10 @@ run() {
print_info "Starting GemStone build..."
source "${SMALLTALK_CI_HOME}/gemstone/run.sh"
;;
GToolkit*)
print_info "Starting GToolkit build..."
source "${SMALLTALK_CI_HOME}/gtoolkit/run.sh"
;;
*)
print_error_and_exit "Unknown Smalltalk image '${config_smalltalk}'."
;;
Expand Down