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
12 changes: 12 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ jobs:
package_root: test/third-party
additional_packages: third-party/INI

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

st3:
name: ST3 build
runs-on: ubuntu-latest
Expand Down
46 changes: 15 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,28 +101,6 @@ jobs:
repository: SublimeText/Sass
ref: ${{ matrix.sass_ref }}
path: Sass
# External syntax definitions, which are embedded without being tested
# in detail, can be provided as empty dummies to just ensure their main
# scope is available.
- name: Create Dummy package (dependency)
run: |
scopes=(
source.livescript
source.postcss
source.sss
source.stylus
)
mkdir -vp "Dummy"
for scope in ${scopes[@]}; do
cat << SYNTAX > "Dummy/$scope.sublime-syntax"
%YAML 1.2
---
scope: $scope

contexts:
main: []
SYNTAX
done
# Run syntax test for primary package
# after installing default and additional packages
- name: Run Syntax Tests for Sublime Text ${{ matrix.build }}
Expand All @@ -135,6 +113,11 @@ jobs:
default_tests: false # default
additional_packages: Dummy,Less,Sass
additional_tests: false # default
# External syntax definitions,
# which are embedded without being tested in detail,
# can be created as empty dummies
# to just ensure their main scope is available.
dummy_syntaxes: source.livescript,source.postcss,source.sss,source.stylus
```

> **Note**
Expand All @@ -151,15 +134,16 @@ 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. |
| **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. |
| 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. |
| **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. |
| **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 Down
29 changes: 17 additions & 12 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ branding:
color: orange

inputs:
additional_packages:
description: Comma separated list of additional package roots that are linked to the testing Packages folder
required: false
default: ''
additional_tests:
description: Whether to keep the tests of additional packages
required: false
default: false
build:
description: Build that should be installed. Not all builds are available
required: false
Expand All @@ -18,22 +26,18 @@ inputs:
description: Whether to keep the tests of the default packages
required: false
default: false
additional_packages:
description: Comma separated list of additional package roots that are linked to the testing Packages folder
dummy_syntaxes:
description: Comma-separated list of base scopes to create empty syntaxes for
required: false
default: ''
additional_tests:
description: Whether to keep the tests of additional packages
package_name:
description: Name to install the package as
required: false
default: false
default: ${{ github.event.repository.name }} # github.repository has full name
package_root:
description: Path to the package root that is linked to the testing Packages folder
required: false
default: .
package_name:
description: Name to install the package as
required: false
default: ${{ github.event.repository.name }} # github.repository has full name

outputs: {}

Expand Down Expand Up @@ -62,10 +66,11 @@ runs:
shell: bash
env:
# composite actions don't expose input variables by default for some reason (unlike docker actions)
INPUT_ADDITIONAL_PACKAGES: ${{ inputs.additional_packages }}
INPUT_ADDITIONAL_TESTS: ${{ inputs.additional_tests }}
INPUT_BUILD: ${{ inputs.build }}
INPUT_DEFAULT_PACKAGES: ${{ inputs.default_packages }}
INPUT_DEFAULT_TESTS: ${{ inputs.default_tests }}
INPUT_ADDITIONAL_PACKAGES: ${{ inputs.additional_packages }}
INPUT_ADDITIONAL_TESTS: ${{ inputs.additional_tests }}
INPUT_PACKAGE_ROOT: ${{ inputs.package_root }}
INPUT_DUMMY_SYNTAXES: ${{ inputs.dummy_syntaxes }}
INPUT_PACKAGE_NAME: ${{ inputs.package_name }}
INPUT_PACKAGE_ROOT: ${{ inputs.package_root }}
67 changes: 45 additions & 22 deletions syntax-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ get_url() {
else
printf "$template_4079\n" "$INPUT_BUILD";
fi;;
*) echo >&2 "Invalid build reference"; exit 100;;
*) echo >&2 "Invalid build reference: $INPUT_BUILD"; exit 100;;
esac
}

Expand All @@ -39,6 +39,11 @@ fetch_binary() {
}

fetch_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)"
pushd "$(mktemp -d)"
wget --content-disposition "https://github.com/sublimehq/Packages/archive/$INPUT_DEFAULT_PACKAGES.tar.gz"
tar xf Packages-*.tar.gz
Expand All @@ -52,25 +57,48 @@ fetch_default_packages() {
-not -name '.github' \
-exec mv -vt "$packages/" '{}' +
popd
echo '::endgroup::'
}

link_package() {
echo 'Linking package'
ln -vs "$(realpath "$INPUT_PACKAGE_ROOT")" "$packages/$INPUT_PACKAGE_NAME"
}

link_additional_packages() {
if [[ -n $INPUT_ADDITIONAL_PACKAGES ]]; then
IFS=","
for pkg in $INPUT_ADDITIONAL_PACKAGES; do
# link additional package into testing dir's Package folder
echo "Linking third-party package from $pkg"
ln -vs "$(realpath "$pkg")" "$packages/$(basename "$pkg")"
# drop additional syntax tests
if [[ $INPUT_ADDITIONAL_TESTS != true ]]; then
find "$(realpath "$pkg")" -type f -name 'syntax_test*' -exec rm -v '{}' \;
fi
done
if [[ -z $INPUT_ADDITIONAL_PACKAGES ]]; then
return
fi
IFS=","
for pkg in $INPUT_ADDITIONAL_PACKAGES; do
# link additional package into testing dir's Package folder
echo "Linking third-party package from '$pkg'"
ln -vs "$(realpath "$pkg")" "$packages/$(basename "$pkg")"
# drop additional syntax tests
if [[ $INPUT_ADDITIONAL_TESTS != true ]]; then
find "$(realpath "$pkg")" -type f -name 'syntax_test*' -exec rm -v '{}' \;
fi
done
}

create_dummy_syntaxes() {
if [[ -z $INPUT_DUMMY_SYNTAXES ]]; then
return
fi
IFS=","
mkdir "$packages/_Dummy"
for scope in $INPUT_DUMMY_SYNTAXES; do
# link additional package into testing dir's Package folder
echo "Creating dummy syntax for scope '$scope'"
cat << SYNTAX > "$packages/_Dummy/$scope.sublime-syntax"
%YAML 1.2
---
scope: $scope

contexts:
main: []
SYNTAX
done
}

# TODO cache $folder/syntax_test based on $INPUT_BUILD != latest
Expand All @@ -79,19 +107,14 @@ get_url | fetch_binary
echo '::endgroup::'

# TODO cache $packages based on $INPUT_DEFAULT_PACKAGES not in (master, st3) (or resolve ref to hash)
if [[ $INPUT_DEFAULT_PACKAGES != false ]]; then
echo "::group::Fetching default packages (ref: $INPUT_DEFAULT_PACKAGES, tests: $INPUT_DEFAULT_TESTS)"
fetch_default_packages
echo '::endgroup::'
else
echo '::debug::Skipping default packages'
fi
fetch_default_packages


echo 'Linking package'
link_package

link_additional_packages

create_dummy_syntaxes

# TODO There seems to be some add-matcher workflow command.
# We could generate/adjust that to only catch files
# in the installed package,
Expand All @@ -106,6 +129,6 @@ echo 'Running binary'
IFS=$':' read -r path row col message <<< "$line"
file="${path/$packages\/$INPUT_PACKAGE_NAME/$INPUT_PACKAGE_ROOT}"
# https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
echo "::error file=$file,line=$row,col=$col::$message"
echo "::error file=$file,line=$row,col=$col::${message# }"
fi
done
9 changes: 9 additions & 0 deletions test/dummy-syntax/Test.sublime-syntax
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
%YAML 1.2
---
scope: text.test

contexts:
main:
- match: ''
embed: scope:text.dummy
escape: $
3 changes: 3 additions & 0 deletions test/dummy-syntax/syntax_test_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SYNTAX TEST "Test.sublime-syntax"

# <- text.test
Loading