From 202a5f2a7458e841c8055af487d071f94ce2e23b Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Sun, 12 Jan 2025 12:41:42 +0100 Subject: [PATCH 1/7] Move conditional logic to `fetch_default_packages` function That's what we do for the other functions as well. --- syntax-tests.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/syntax-tests.sh b/syntax-tests.sh index e930d4f..dc7f200 100755 --- a/syntax-tests.sh +++ b/syntax-tests.sh @@ -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 @@ -52,9 +57,11 @@ 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" } @@ -79,17 +86,10 @@ 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 # TODO There seems to be some add-matcher workflow command. From c9db242b146d28ba9b9f08935dd6afba330eb6d5 Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Sun, 12 Jan 2025 12:41:23 +0100 Subject: [PATCH 2/7] Strip leading space of output message --- syntax-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax-tests.sh b/syntax-tests.sh index dc7f200..d200ec9 100755 --- a/syntax-tests.sh +++ b/syntax-tests.sh @@ -106,6 +106,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 From 0cdab6e01ec6af83ed36b8f7fece69b4a5fe1956 Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Sun, 12 Jan 2025 12:43:22 +0100 Subject: [PATCH 3/7] Sort inputs and env vars --- action.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/action.yml b/action.yml index bd5844b..b3ed442 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -18,22 +26,14 @@ 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 - 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: {} @@ -62,10 +62,10 @@ 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_PACKAGE_NAME: ${{ inputs.package_name }} + INPUT_PACKAGE_ROOT: ${{ inputs.package_root }} From 3cbe1570f5567687b05fad3f670a13d63fc6583f Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Sun, 12 Jan 2025 12:45:24 +0100 Subject: [PATCH 4/7] Use early exit for `link_additional_packages` --- syntax-tests.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/syntax-tests.sh b/syntax-tests.sh index d200ec9..c12ad72 100755 --- a/syntax-tests.sh +++ b/syntax-tests.sh @@ -66,18 +66,19 @@ link_package() { } 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 } # TODO cache $folder/syntax_test based on $INPUT_BUILD != latest From 173194a88438293ca48015a898360905565566ed Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Sun, 12 Jan 2025 12:51:00 +0100 Subject: [PATCH 5/7] Escape inline underscore in table --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 1a9ee2a..1234a4f 100644 --- a/README.md +++ b/README.md @@ -151,15 +151,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. | -| **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. | [default packages]: https://github.com/sublimehq/Packages/ From e9b080bf85f2e547566d75c0f2dd11cc44d5ea88 Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Sun, 12 Jan 2025 12:57:17 +0100 Subject: [PATCH 6/7] Add `dummy_syntaxes` input to create dummy syntaxes --- .github/workflows/test.yml | 12 ++++++++++++ README.md | 28 ++++++--------------------- action.yml | 5 +++++ syntax-tests.sh | 22 +++++++++++++++++++++ test/dummy-syntax/Test.sublime-syntax | 9 +++++++++ test/dummy-syntax/syntax_test_test | 3 +++ 6 files changed, 57 insertions(+), 22 deletions(-) create mode 100644 test/dummy-syntax/Test.sublime-syntax create mode 100644 test/dummy-syntax/syntax_test_test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f91d384..e54c1b3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/README.md b/README.md index 1234a4f..6e79822 100644 --- a/README.md +++ b/README.md @@ -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 }} @@ -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** @@ -160,6 +143,7 @@ jobs: | **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/ diff --git a/action.yml b/action.yml index b3ed442..00250e6 100644 --- a/action.yml +++ b/action.yml @@ -26,6 +26,10 @@ inputs: description: Whether to keep the tests of the default packages required: false default: false + dummy_syntaxes: + description: Comma-separated list of base scopes to create empty syntaxes for + required: false + default: '' package_name: description: Name to install the package as required: false @@ -67,5 +71,6 @@ runs: INPUT_BUILD: ${{ inputs.build }} INPUT_DEFAULT_PACKAGES: ${{ inputs.default_packages }} INPUT_DEFAULT_TESTS: ${{ inputs.default_tests }} + INPUT_DUMMY_SYNTAXES: ${{ inputs.dummy_syntaxes }} INPUT_PACKAGE_NAME: ${{ inputs.package_name }} INPUT_PACKAGE_ROOT: ${{ inputs.package_root }} diff --git a/syntax-tests.sh b/syntax-tests.sh index c12ad72..1917c7d 100755 --- a/syntax-tests.sh +++ b/syntax-tests.sh @@ -81,6 +81,26 @@ link_additional_packages() { 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 echo "::group::Fetching binary (build $INPUT_BUILD)" get_url | fetch_binary @@ -93,6 +113,8 @@ 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, diff --git a/test/dummy-syntax/Test.sublime-syntax b/test/dummy-syntax/Test.sublime-syntax new file mode 100644 index 0000000..bbeb198 --- /dev/null +++ b/test/dummy-syntax/Test.sublime-syntax @@ -0,0 +1,9 @@ +%YAML 1.2 +--- +scope: text.test + +contexts: + main: + - match: '' + embed: scope:text.dummy + escape: $ diff --git a/test/dummy-syntax/syntax_test_test b/test/dummy-syntax/syntax_test_test new file mode 100644 index 0000000..fc13691 --- /dev/null +++ b/test/dummy-syntax/syntax_test_test @@ -0,0 +1,3 @@ +# SYNTAX TEST "Test.sublime-syntax" + +# <- text.test From 46109f881f90d9b6cae094cb82ce38ad64ca98d3 Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Sun, 12 Jan 2025 12:58:49 +0100 Subject: [PATCH 7/7] Tweak informative echos a bit --- syntax-tests.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntax-tests.sh b/syntax-tests.sh index 1917c7d..20eb37d 100755 --- a/syntax-tests.sh +++ b/syntax-tests.sh @@ -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 } @@ -72,7 +72,7 @@ link_additional_packages() { IFS="," for pkg in $INPUT_ADDITIONAL_PACKAGES; do # link additional package into testing dir's Package folder - echo "Linking third-party package from $pkg" + echo "Linking third-party package from '$pkg'" ln -vs "$(realpath "$pkg")" "$packages/$(basename "$pkg")" # drop additional syntax tests if [[ $INPUT_ADDITIONAL_TESTS != true ]]; then @@ -89,7 +89,7 @@ create_dummy_syntaxes() { 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" + echo "Creating dummy syntax for scope '$scope'" cat << SYNTAX > "$packages/_Dummy/$scope.sublime-syntax" %YAML 1.2 ---