Skip to content
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
48 changes: 24 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ name: Tests
on: [push, pull_request]

jobs:
no_defpkg:
name: Without default packages
no_defpkg_stable:
name: Without default packages, latest stable
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
with:
build: 4189
build: stable
package_root: test/no_defpkg

# TODO indentation tests
# TODO reference & definition tests

defpkg:
defpkg_stable:
name: With default packages, latest stable
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
with:
build: 4189
default_packages: master
build: stable
default_packages: binary
package_root: test/defpkg

no_defpkg_old_build:
name: Without default packages, old build
name: Without default packages, build 4073
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -37,18 +37,8 @@ jobs:
build: 4073
package_root: test/no_defpkg

no_defpkg_old_runtime:
name: Without default packages, latest build, ubuntu-20.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: ./
with:
build: latest
package_root: test/no_defpkg

third-party:
name: Third-party
third-party_stable:
name: Third-party, latest stable
runs-on: ubuntu-latest
steps:
- name: Checkout repo (primary package)
Expand All @@ -61,24 +51,24 @@ jobs:
path: third-party/INI
- uses: ./
with:
build: 4189 # stable
build: stable
package_root: test/third-party
additional_packages: third-party/INI

dummy_syntax:
name: Dummy Syntax
dummy_syntax_stable:
name: Dummy Syntax, latest stable
runs-on: ubuntu-latest
steps:
- name: Checkout repo (primary package)
uses: actions/checkout@v4
- uses: ./
with:
build: 4189 # stable
build: stable
package_root: test/dummy-syntax
dummy_syntaxes: text.dummy

st3:
name: ST3 build
name: Without default packages, ST3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -88,6 +78,16 @@ jobs:
default_packages: v3189
package_root: test/st3

st3_no_defpkg_old_runtime:
name: Without default packages, ST3, ubuntu-20.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: ./
with:
build: 3210
package_root: test/no_defpkg

# This is expected to error and used to test the error wrapper
st3_error:
name: Error on purpose
Expand Down
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ jobs:
include:
- 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: 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
# packages: v3189 # Latest ST3 tag on the Packages repo
steps:
- uses: actions/checkout@v4
- uses: SublimeText/syntax-test-action@v2
Expand Down Expand Up @@ -134,15 +136,15 @@ jobs:

## Inputs

| Name | Default | Description |
| :----------------------- | :-------------- | :----------------------------------------------------------------------------------------- |
| **build** | `"latest"` | ST build that should be installed as an integer. Not all builds are available. |
| **default\_packages** | `false` | Install the [default packages][] and which version (accepts any git ref, e.g. `"master"`). |
| **default\_tests** | `false` | Whether to keep the tests of the default packages. |
| 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"`, 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. |
| **package\_root** | `"."` | Path to the package root that is linked to the testing Packages folder. |
| **package\_name** | Repository name | Name to install the package as. |
| **additional\_tests** | `false` | Whether to keep the tests of the additional packages. |
| **package\_root** | `"."` | Path to the package root that is linked to the testing Packages folder. |
| **package\_name** | Repository name | Name to install the package as. |
| **dummy\_syntaxes** | `""` | Comma-separated list of base scopes to create empty syntaxes for, e.g. `source.postcss,source.stylus`. |

[default packages]: https://github.com/sublimehq/Packages/
Expand All @@ -152,9 +154,16 @@ jobs:

### v2

### v2.4 (2025-01-12)

- Added `dummy_syntaxes` input that creates empty syntax files
to satisfy external `embed`s that would otherwise result in CI failures.
(@FichteFoll, #13, #20)

### v2.3 (2025-01-11)

- Fix dependencies for `ubuntu-24.04` runner. (@deathaxe, #17, #18)
- Fix dependencies for `ubuntu-24.04` runner.
(@deathaxe, #17, #18)

### v2.2 (2023-01-08)

Expand All @@ -165,16 +174,19 @@ jobs:
### v2.1 (2021-06-07)

- Treat `'latest'` as an ST4 build now that the upstream URL has been updated.
(@FichteFoll)
- Group dependency installation, if necessary.
(@FichteFoll)

### v2.0 (2020-08-28)

- Updated to new upstream download paths.
- Does not fetch dependencies anymore for 4077+.
- Changed from docker to composite action.
- Updated to new upstream download paths. (@FichteFoll)
- Does not fetch dependencies anymore for 4077+. (@FichteFoll, #2)
- Changed from docker to composite action. (@FichteFoll)

### v1 (2020-06-07)

Initial working version
supporting ST3 and ST4 builds
as well as fetching the default packages.
(@FichteFoll)
75 changes: 56 additions & 19 deletions syntax-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,39 @@ 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
build="$(curl -s "$stable_check_url" | jq '.latest_version')"
echo >&2 "Latest stable build: $build"
elif [[ $INPUT_BUILD == latest ]]; then
build="$(curl -s "$dev_check_url" | jq '.latest_version')"
echo >&2 "Latest dev build: $build"
fi
echo "$build"
}

get_url() {
latest_url="https://download.sublimetext.com/latest/dev/linux/x64/syntax_tests"
template_3000="https://download.sublimetext.com/st3_syntax_tests_build_%s_x64.tar.bz2"
template_4000="https://download.sublimetext.com/st_syntax_tests_build_%s_x64.tar.bz2"
template_4079="https://download.sublimetext.com/st_syntax_tests_build_%s_x64.tar.xz"

case $INPUT_BUILD in
latest) echo "$latest_url";;
3*) printf "$template_3000\n" "$INPUT_BUILD";;
4*) if (( INPUT_BUILD < 4079 )); then
printf "$template_4000\n" "$INPUT_BUILD";
# 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"

case $build in
3*) printf "$template_3000\n" "$build";;
4*) if (( build < 4079 )); then
printf "$template_4000\n" "$build";
else
printf "$template_4079\n" "$INPUT_BUILD";
printf "$template_4079\n" "$build";
fi;;
*) echo >&2 "Invalid build reference: $INPUT_BUILD"; exit 100;;
*) echo >&2 "Invalid build reference: $build"; exit 100;;
esac
}

Expand All @@ -39,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
tag_build="$(get_closest_tag "$binary_build")"
ref="v$tag_build"
echo "Using closest tag to binary version: $ref"
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 All @@ -60,6 +86,16 @@ fetch_default_packages() {
echo '::endgroup::'
}

get_closest_tag() {
local base="$1"
git ls-remote --tags https://github.com/sublimehq/Packages.git "refs/tags/v????" \
| cut -f2 \
| cut -d'v' -f2 \
| awk "{ if (\$1 <= $base) { print \$1 } }" \
| sort -r \
| head -n1
}

link_package() {
echo 'Linking package'
ln -vs "$(realpath "$INPUT_PACKAGE_ROOT")" "$packages/$INPUT_PACKAGE_NAME"
Expand Down Expand Up @@ -101,13 +137,14 @@ SYNTAX
done
}

# TODO cache $folder/syntax_test based on $INPUT_BUILD != latest
echo "::group::Fetching binary (build $INPUT_BUILD)"
get_url | fetch_binary
# TODO cache $folder/syntax_test if not latest or stable
build="$(resolve_build)"
echo "::group::Fetching binary (build $build)"
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
Loading