cucumber / language-service

Cucumber Language Service
MIT License
12 stars 21 forks source link

Fix CI failure due to bumped dependencies in `macos-latest` GitHub runner #175

Closed kieran-ryan closed 4 months ago

kieran-ryan commented 4 months ago

🤔 What's changed?

Bumped node-gyp to 10.0.1.

Provided an explicit error message for installation failure of tree-sitter language bindings; prior to attempting their compilation.

> @cucumber/language-service@1.4.1 prepare
> husky install && node scripts/build.js && cp node_modules/web-tree-sitter/tree-sitter.wasm dist

husky - Git hooks installed
Module node_modules/tree-sitter-java does not exist. This is likely due to an installation and/or build failure of the module. Please check the logs.

⚡️ What's your motivation?

Fixes #174 - which prevents the pipeline from passing and presents a blocker to release.

Fix Python 3.12 incompatibility

Following macOS 12 (20231029) release of the macos-latest GitHub runner, the Python distribution changed to 3.12 - this is incompatible with the version of node-gyp used to compile the tree-sitter language bindings. Specifically, our pinned version uses the distutils module which is removed from the standard library 3.12 - which has been discussed on other issues (cucumber/gherkin#40). Our pipelines have failed since this release.

The tree-sitter language binding dependencies were previously made optional to support Windows runners (#58) - suppressing the failure as the logs are less verbose. More information on the failure can be revealed by increasing the log verbosity (-ddd) and by making the dependency required.

As such, the issue is resolved by either pinning Python to 3.9 or updating node-gyp to >= v10 - which is compatible with 3.12. The latter has been chosen, as we will need to bump the version in future in any case.

Improve developer experience with enhanced error message

By first checking if the tree-sitter language binding module exists before attempting to compile them, it makes it clearer what caused the failure. We do not perform this check at present. This can make failures unclear as we trigger the compilation asynchronously so the module that fails can vary based on which process returns the failure first. With this PR, we will not attempt compilation of a missing module - and will get faster CI feedback.

Developers will see the following:

Module node_modules/tree-sitter-java does not exist. This is likely due to an installation and/or build failure of the module. Please check the logs.

Instead of:

Compiling node_modules/tree-sitter-java
Compiling node_modules/tree-sitter-typescript/tsx
Compiling node_modules/tree-sitter-c-sharp
Compiling node_modules/tree-sitter-php
Compiling node_modules/tree-sitter-ruby
Compiling node_modules/tree-sitter-python
Compiling node_modules/tree-sitter-rust
Failed to build wasm for node_modules/tree-sitter-c-sharp: Command failed: node_modules/.bin/tree-sitter build-wasm node_modules/tree-sitter-c-sharp
Failed to read grammar file "/Users/runner/work/language-service/language-service/node_modules/tree-sitter-c-sharp/src/grammar.json"

🏷️ What kind of change is this?

📋 Checklist:

mpkorstanje commented 4 months ago

LGTM, and do feel free to create a branch in this repository instead of your own. It will make collaboration with others easier.

kieran-ryan commented 4 months ago

LGTM, and do feel free to create a branch in this repository instead of your own. It will make collaboration with others easier.

Cheers - noted going forward 👍