Skip to content

Commit

Permalink
wip2
Browse files Browse the repository at this point in the history
  • Loading branch information
FichteFoll committed Jan 12, 2025
1 parent f91d129 commit 3047b7f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- build: latest # This is the default
# packages: master # If you depend on a default syntax definition
- build: stable # Fetches the binary for the latest stable build
# packages: v4189 # Latest stable tag at the time of writing.
# packages: binary # Use respective tag for the selected binary build.
- build: 3210 # Latest known ST3 build with a test binary
# packages: v3189 # Latest ST3 tag on the Packages repo
steps:
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
| Name | Default | Description |
| :----------------------- | :-------------- | :---------- |
| **build** | `"latest"` | ST build that should be installed as an integer. `"latest"` is for the dev channel, `"stable"` for the stable channel. Not all builds are available. |
| **default\_packages** | `false` | Install the [default packages][] and which version (accepts any git ref, e.g. `"master"`). |
| **default\_packages** | `"false"` | Install the [default packages][] and which version. Accepts any git ref, e.g. `"master"`, or `"binary"` for the tag of the respective binary. Note that the corresponding tag may not always exist. |
| **default\_tests** | `false` | Whether to keep the tests of the default packages. |
| **additional\_packages** | `""` | Comma-separated list of paths to additionally checked out packages to install (e.g.: `LESS,third-party/Sass`). Uses the folders' base names as the package names to install as. |
| **additional\_tests** | `false` | Whether to keep the tests of the additional packages. |
Expand Down
54 changes: 35 additions & 19 deletions syntax-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,32 @@ folder="$RUNNER_WORKSPACE/syntax_tests"
packages="$folder/Data/Packages"
mkdir -p "$folder"

resolve_build() {
local stable_check_url="https://www.sublimetext.com/updates/4/stable_update_check"
local dev_check_url="https://www.sublimetext.com/updates/4/dev_update_check"
local build="$INPUT_BUILD"

if [[ $INPUT_BUILD == stable ]]; then
curl -q "$stable_check_url" | jq '.latest_version' | read -r build
echo >&2 "Latest stable build: $build"
elif [[ $INPUT_BUILD == latest ]];
curl -q "$dev_check_url" | jq '.latest_version' | read -r build
echo >&2 "Latest dev build: $build"
fi
echo "$build"
}

get_url() {
local latest_url="https://download.sublimetext.com/latest/dev/linux/x64/syntax_tests"
# Note: The syntax_tests binary for the latest build may not necessarily exist.
# Fetching from https://download.sublimetext.com/latest/dev/linux/x64/syntax_tests
# would be more reliable
# but makes using the same build for the default Packages tag harder.
local build="$1"
local template_3000="https://download.sublimetext.com/st3_syntax_tests_build_%s_x64.tar.bz2"
local template_4000="https://download.sublimetext.com/st_syntax_tests_build_%s_x64.tar.bz2"
local template_4079="https://download.sublimetext.com/st_syntax_tests_build_%s_x64.tar.xz"
local build="$INPUT_BUILD"

if [[ $build == stable ]]; then
echo "test: $(get_latest_stable_build)"
get_latest_stable_build | read -r build
echo "Latest stable build: $build"
fi

case $build in
latest) echo "$latest_url";;
3*) printf "$template_3000\n" "$build";;
4*) if (( build < 4079 )); then
printf "$template_4000\n" "$build";
Expand All @@ -32,10 +43,6 @@ get_url() {
esac
}

get_latest_stable_build() {
curl -q "https://www.sublimetext.com/updates/4/stable_update_check" | jq '.latest_version'
}

fetch_binary() {
read -r url
local tmpdir
Expand All @@ -50,13 +57,21 @@ fetch_binary() {
}

fetch_default_packages() {
local binary_build="$1"
local ref="$INPUT_DEFAULT_PACKAGES"
if [[ $INPUT_DEFAULT_PACKAGES == false ]]; then
echo '::debug::Skipping default packages'
return
fi
echo "::group::Fetching default packages (ref: $INPUT_DEFAULT_PACKAGES, tests: $INPUT_DEFAULT_TESTS)"
if [[ $INPUT_DEFAULT_PACKAGES == binary ]]; then
echo "::debug::Using tag of binary version: $binary_build"
# Note: Tag may not always exist yet as they seem to be created manually.
ref="v$binary_build"
fi

echo "::group::Fetching default packages (ref: $ref, tests: $INPUT_DEFAULT_TESTS)"
pushd "$(mktemp -d)"
wget --content-disposition "https://github.com/sublimehq/Packages/archive/$INPUT_DEFAULT_PACKAGES.tar.gz"
wget --content-disposition "https://github.com/sublimehq/Packages/archive/$ref.tar.gz"
tar xf Packages-*.tar.gz
if [[ $INPUT_DEFAULT_TESTS != true ]]; then
find Packages-*/ -type f -name 'syntax_test*' -exec rm -v '{}' \;
Expand Down Expand Up @@ -112,13 +127,14 @@ SYNTAX
done
}

# TODO cache $folder/syntax_test based on $INPUT_BUILD != latest
# TODO cache $folder/syntax_test if not latest or stable
resolve_build | read -r build
echo "::group::Fetching binary (build $INPUT_BUILD)"
get_url | fetch_binary
get_url "$build" | fetch_binary
echo '::endgroup::'

# TODO cache $packages based on $INPUT_DEFAULT_PACKAGES not in (master, st3) (or resolve ref to hash)
fetch_default_packages
# TODO cache $packages based on $INPUT_DEFAULT_PACKAGES not in (master, st3, binary) (or resolve ref to hash)
fetch_default_packages "$build"

link_package

Expand Down

0 comments on commit 3047b7f

Please sign in to comment.