From 2310304320e75ea2b7749a93b24ce8b2442ab27c Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Sun, 12 Jan 2025 14:40:11 +0100 Subject: [PATCH 1/4] Don't align table ends This leads to fewer lines changed when updating descriptions. --- README.md | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6e79822..579f62e 100644 --- a/README.md +++ b/README.md @@ -134,15 +134,15 @@ jobs: ## Inputs -| Name | Default | Description | -| :----------------------- | :-------------- | :----------------------------------------------------------------------------------------- | -| **build** | `"latest"` | ST build that should be installed as an integer. Not all builds are available. | +| 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. | +| **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/ @@ -152,9 +152,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) @@ -165,16 +172,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) From 024ea94d1be0027ba5c36d4285f3ba0e8325bfb4 Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Sun, 12 Jan 2025 14:47:52 +0100 Subject: [PATCH 2/4] Fetch latest "stable" build from update check endpoint Also support new "binary" value for packages ref to automatically use the same build tag as for the binary. --- .github/workflows/test.yml | 26 +++++++-------- README.md | 8 +++-- syntax-tests.sh | 65 +++++++++++++++++++++++++++----------- 3 files changed, 64 insertions(+), 35 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e54c1b3..b05c485 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -47,8 +47,8 @@ jobs: 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) @@ -61,19 +61,19 @@ 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 diff --git a/README.md b/README.md index 579f62e..ae44081 100644 --- a/README.md +++ b/README.md @@ -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 @@ -136,8 +138,8 @@ jobs: | 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"`). | +| **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. | diff --git a/syntax-tests.sh b/syntax-tests.sh index 20eb37d..4ae6f22 100755 --- a/syntax-tests.sh +++ b/syntax-tests.sh @@ -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 } @@ -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 + 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 '{}' \; @@ -101,13 +127,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 From 3abf82aada5768c9b3f0dc4d52ce5635ac44e915 Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Sun, 12 Jan 2025 16:29:37 +0100 Subject: [PATCH 3/4] Get closest tag for `default_packages=binary` --- syntax-tests.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/syntax-tests.sh b/syntax-tests.sh index 4ae6f22..c543b9f 100755 --- a/syntax-tests.sh +++ b/syntax-tests.sh @@ -64,9 +64,9 @@ fetch_default_packages() { return fi 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" + 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)" @@ -86,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" From 10e768609e0c211689c3df6eb7d52e376e9138f7 Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Sun, 12 Jan 2025 16:32:28 +0100 Subject: [PATCH 4/4] Run test with old runtime on ST3 build --- .github/workflows/test.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b05c485..a3d73a2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,16 +37,6 @@ 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_stable: name: Third-party, latest stable runs-on: ubuntu-latest @@ -78,7 +68,7 @@ jobs: dummy_syntaxes: text.dummy st3: - name: ST3 build + name: Without default packages, ST3 runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -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