From fbae03e4bdc64fdfdf2666a66d2dad90babc55cd Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 29 Dec 2022 12:15:12 +0100 Subject: [PATCH 1/2] Add support to link and test additional packages This commit enables syntax-test-action to install additionally checked out packages. Example Workflow jobs: syntax_tests: name: Sublime Text ${{ matrix.build }} runs-on: ubuntu-latest timeout-minutes: 15 # default is 6 hours! strategy: matrix: include: - build: 4134 default_packages: v4134 - build: latest default_packages: master steps: - name: Checkout CoffeeScript uses: actions/checkout@v3 with: repository: sustained/CoffeeScript-Sublime-Plugin path: CoffeeScript clean: false - name: Checkout LESS uses: actions/checkout@v3 with: repository: danro/LESS-sublime path: LESS clean: false - name: Checkout Sass/Scss uses: actions/checkout@v3 with: repository: braver/SublimeSass path: Sass clean: false - name: Checkout Slim uses: actions/checkout@v3 with: path: Slim clean: false - name: Run Syntax Tests for Sublime Text ${{ matrix.build }} uses: deathaxe/syntax-test-action@master with: build: ${{ matrix.build }} default_packages: ${{ matrix.default_packages }} package_name: Slim package_root: Slim additional_packages: CoffeeScript,LESS,Sass additional_tests: false --- README.md | 95 ++++++++++++++++++++++++++++++++++++++++++++----- action.yml | 10 ++++++ syntax-tests.sh | 15 ++++++++ 3 files changed, 111 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 83e5d9d..26019bc 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ using the ST syntax test binary. ## Usage +### Minimal Example + ```yaml name: Syntax Tests @@ -25,6 +27,8 @@ on: jobs: syntax_tests: name: Syntax Tests (${{ matrix.build }}) + runs-on: ubuntu-latest + timeout-minutes: 15 # default is 6 hours! strategy: matrix: include: @@ -32,15 +36,85 @@ jobs: # packages: master # If you depend on a default syntax definition - build: 3210 # Latest known ST3 build with a test binary # packages: st3 - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: SublimeText/syntax-test-action@v2 with: build: ${{ matrix.build }} # default_packages: ${{ matrix.packages }} ``` +### Multiple Syntax Package Tests Example + +```yaml +name: Multi Package Syntax Tests + +on: + push: + paths: + - '**.sublime-syntax' + - '**/syntax_test*' + - '**.tmPreferences' + pull_request: + paths: + - '**.sublime-syntax' + - '**/syntax_test*' + - '**.tmPreferences' + +jobs: + syntax_tests: + name: Syntax Tests (${{ matrix.build }}) + runs-on: ubuntu-latest + timeout-minutes: 15 # default is 6 hours! + env: + package_name: My Package # install name as specified at packagecontrol.io + strategy: + matrix: + include: + - build: latest # This is the default + packages: master # default packages revision to use + less_ref: master # LESS package revision to use + sass_ref: master # SASS package revision to use + - build: 3210 # Latest known ST3 build with a test binary + packages: v3210 # default packages revision to use + less_ref: master # LESS package revision to use + sass_ref: master # SASS package revision to use + steps: + # Checkout primary package of this repository + # and all additionally required packages next to each other + # by specifying `path` for all. + # `path` should match the package's name from packagecontrol.io + # as this may be relevant for a package to work porperly. + - name: Checkout ${{ env.package_name }} (primary package) + uses: actions/checkout@v3 + with: + path: ${{ env.package_name }} + - name: Checkout LESS (dependency) + uses: actions/checkout@v3 + with: + repository: danro/LESS-sublime + ref: ${{ matrix.less_ref }} + path: LESS + - name: Checkout Sass/Scss (dependency) + uses: actions/checkout@v3 + with: + repository: braver/SublimeSass + ref: ${{ matrix.sass_ref }} + path: Sass + # Run syntax test for primary package + # after installing default and additional packages + - name: Run Syntax Tests for Sublime Text ${{ matrix.build }} + uses: SublimeText/syntax-test-action@v2 + with: + build: ${{ matrix.build }} + package_name: ${{ env.package_name }} + package_root: ${{ env.package_name }} + default_packages: ${{ matrix.packages }} + default_tests: false + additional_packages: LESS,Sass + additional_tests: false +``` + Note that you must use a separate job if you want to test multiple ST build or default packages versions. @@ -48,13 +122,15 @@ or default packages versions. ## 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. | -| **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** | `false` | Comma separated list of additionally checked out packages to install (e.g.: LESS,Sass). | +| **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/ @@ -62,6 +138,7 @@ or default packages versions. ## Changelog ### v2 + ### v2.1 (2021-06-07) - Treat `'latest'` as an ST4 build now that the upstream URL has been updated. diff --git a/action.yml b/action.yml index 9e0cce7..f107926 100644 --- a/action.yml +++ b/action.yml @@ -18,6 +18,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: false + additional_tests: + description: Whether to keep the tests of additional packages + required: false + default: false package_root: description: Path to the package root that is linked to the testing Packages folder required: false @@ -56,5 +64,7 @@ runs: 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 }} diff --git a/syntax-tests.sh b/syntax-tests.sh index 4c5f1e0..3688041 100755 --- a/syntax-tests.sh +++ b/syntax-tests.sh @@ -58,6 +58,20 @@ link_package() { ln -vs "$(realpath "$INPUT_PACKAGE_ROOT")" "$packages/$INPUT_PACKAGE_NAME" } +link_additional_packages() { + if [[ $INPUT_ADDITIONAL_PACKAGES != false ]]; then + IFS="," + for pkg in $INPUT_ADDITIONAL_PACKAGES; do + # link additional package into testing dir's Package folder + ln -vs "$(realpath "$pkg")" "$packages/$pkg" + # drop additional syntax tests + if [[ $INPUT_ADDITIONAL_TESTS != true ]]; then + find "$packages/$pkg"*/ -type f -name 'syntax_test*' -exec rm -v '{}' \; + fi + done + fi +} + # TODO cache $folder/syntax_test based on $INPUT_BUILD != latest echo "::group::Fetching binary (build $INPUT_BUILD)" get_url | fetch_binary @@ -75,6 +89,7 @@ fi echo 'Linking package' link_package +link_additional_packages # TODO There seems to be some add-matcher workflow command. # We could generate/adjust that to only catch files From ef3609820e6114e54d63046950facf5cfc0b5a6b Mon Sep 17 00:00:00 2001 From: deathaxe Date: Mon, 2 Jan 2023 17:56:35 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: FichteFoll --- README.md | 2 +- syntax-tests.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 26019bc..7af6d2e 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ or default packages versions. | **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** | `false` | Comma separated list of additionally checked out packages to install (e.g.: LESS,Sass). | +| **additional_packages** | `false` | Comma-separated list of paths to additionally checked out packages to install (e.g.: `LESS,third-party/Sass`). | | **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. | diff --git a/syntax-tests.sh b/syntax-tests.sh index 3688041..bc78a36 100755 --- a/syntax-tests.sh +++ b/syntax-tests.sh @@ -63,7 +63,7 @@ link_additional_packages() { IFS="," for pkg in $INPUT_ADDITIONAL_PACKAGES; do # link additional package into testing dir's Package folder - ln -vs "$(realpath "$pkg")" "$packages/$pkg" + ln -vs "$(realpath "$pkg")" "$packages/$(basename "$pkg")" # drop additional syntax tests if [[ $INPUT_ADDITIONAL_TESTS != true ]]; then find "$packages/$pkg"*/ -type f -name 'syntax_test*' -exec rm -v '{}' \;