Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up automated tests and static analysis on CI #21

Merged
merged 14 commits into from
Nov 3, 2024
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
90 changes: 90 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: CI

on:
push:
branches: [main]
tags: ["**"]
pull_request:

env:
DEFAULT_NODE_VERSION: 20

jobs:
dart_tests:
name: "Dart tests | Dart ${{ matrix.dart_channel }} | ${{ matrix.os }} | ${{ matrix.pkg }}"
runs-on: "${{ matrix.os }}"

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
dart_channel: [stable]
pkg: [sass_language_services, sass_language_server]

steps:
- uses: actions/checkout@v4

- uses: dart-lang/setup-dart@v1
with: { sdk: "${{ matrix.dart_channel }}" }

- run: dart pub get

- name: Test ${{ matrix.pkg }}
run: dart run test
working-directory: pkgs/${{ matrix.pkg }}

static_analysis:
name: "Static analysis | ${{ matrix.pkg }}"
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
pkg: [sass_language_services, sass_language_server]

steps:
- uses: actions/checkout@v4

- uses: dart-lang/setup-dart@v1

- run: dart pub get

- name: Analyze ${{ matrix.pkg }}
run: dart analyze --fatal-warnings --fatal-infos
working-directory: pkgs/${{ matrix.pkg }}

code_tests:
name: "VS Code tests | ${{ matrix.os }}"
runs-on: "${{ matrix.os }}"

strategy:
fail-fast: false

matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
dart_channel: [stable]

steps:
- uses: actions/checkout@v4

- uses: dart-lang/setup-dart@v1
with: { sdk: "${{ matrix.dart_channel }}" }

- run: dart pub get

- uses: actions/setup-node@v4
with: { node-version: "${{ env.DEFAULT_NODE_VERSION }}" }

- name: Install dependencies
run: npm clean-install
working-directory: extension

- name: Run extension tests in simulated X environment
run: xvfb-run -a npm run test
if: runner.os == 'Linux'
working-directory: extension

- name: Run extension tests
run: npm run test
if: runner.os != 'Linux'
working-directory: extension
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
sass-language-server

# Don't commit the following in the extensions folder
.vscode-test
dist
node_modules
!extension/test/**/node_modules
*.vsix
20 changes: 20 additions & 0 deletions docs/contributing/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@ Assuming you installed [Dart for Visual Studio Code](https://marketplace.visuals

Writing a test is often faster when debugging an issue with a specific language feature, and helps improve test coverage.

## Debug VS Code tests

To debug, add this launch configuration to `.vscode/launch.json`
and change the path to match the test suite you're debugging.
Place breakpoints in the test code and choose the Debug extensions
test profile in the Run and Debug view in VS Code.

```json
{
"name": "Debug extension tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/extension",
"--extensionTestsPath=${workspaceFolder}/extension/test/electron/document-links/index"
]
}
```

## Testing in isolation

VS Code ships with some built-in support for SCSS and CSS. To test this language server in isolation you can disable the built-in extension.
Expand Down
1 change: 1 addition & 0 deletions extension/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
4 changes: 2 additions & 2 deletions extension/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Sass for Visual Studio Code

This extension requires you install [`sass-language-server`](https://github.com/wkillerud/dart-sass-language-server/tree/main/pkgs/sass_language_server). The extension will not work without it. <!-- Go for VS Code has a check for missing tools and an install helper, for inspiration. -->
This extension requires you install [`sass-language-server`](https://github.com/sass/dart-sass-language-server/tree/main/pkgs/sass_language_server). The extension will not work without it. <!-- Go for VS Code has a check for missing tools and an install helper, for inspiration. -->

<!-- Not quite there yet
## Recommended settings
Expand All @@ -14,4 +14,4 @@ We recommend you turn off the built-in CSS/SCSS/Less language extension.

## Changelog

Visit the [release section on GitHub](https://github.com/wkillerud/dart-sass-language-server/releases) to see what has changed.
Visit the [release section on GitHub](https://github.com/sass/dart-sass-language-server/releases) to see what has changed.
Loading