From 29c53e20f7ad6eefedda7b66dd8929f8cf791b5e Mon Sep 17 00:00:00 2001 From: William Killerud Date: Sun, 3 Nov 2024 09:46:04 +0100 Subject: [PATCH 01/14] Set up automated tests and static analysis on CI --- .github/workflows/ci.yml | 106 ++ .gitignore | 2 + extension/.npmrc | 1 + extension/README.md | 4 +- extension/package-lock.json | 1529 ++++++++++++++++- extension/package.json | 11 +- extension/src/server.ts | 62 +- .../document-links/document-links.test.js | 77 + .../document-links/fixtures/circular.scss | 1 + .../@my-scope/my-components/index.js | 1 + .../@my-scope/my-components/package.json | 15 + .../my-components/styles/colors.scss | 3 + .../@my-scope/my-components/styles/index.scss | 1 + .../node_modules/my-components/index.js | 1 + .../node_modules/my-components/package.json | 15 + .../my-components/styles/colors.scss | 3 + .../my-components/styles/index.scss | 1 + .../document-links/fixtures/scoped.scss | 5 + .../document-links/fixtures/styles.scss | 6 + .../test/electron/document-links/index.js | 25 + extension/test/electron/mocha.js | 45 + extension/test/electron/run.js | 73 + extension/test/electron/util.js | 72 + pkgs/sass_language_server/README.md | 2 +- pkgs/sass_language_server/pubspec.yaml | 2 +- .../test/workspace_test.dart | 9 + pkgs/sass_language_services/pubspec.yaml | 2 +- 27 files changed, 1999 insertions(+), 75 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 extension/.npmrc create mode 100644 extension/test/electron/document-links/document-links.test.js create mode 100644 extension/test/electron/document-links/fixtures/circular.scss create mode 100644 extension/test/electron/document-links/fixtures/node_modules/@my-scope/my-components/index.js create mode 100644 extension/test/electron/document-links/fixtures/node_modules/@my-scope/my-components/package.json create mode 100644 extension/test/electron/document-links/fixtures/node_modules/@my-scope/my-components/styles/colors.scss create mode 100644 extension/test/electron/document-links/fixtures/node_modules/@my-scope/my-components/styles/index.scss create mode 100644 extension/test/electron/document-links/fixtures/node_modules/my-components/index.js create mode 100644 extension/test/electron/document-links/fixtures/node_modules/my-components/package.json create mode 100644 extension/test/electron/document-links/fixtures/node_modules/my-components/styles/colors.scss create mode 100644 extension/test/electron/document-links/fixtures/node_modules/my-components/styles/index.scss create mode 100644 extension/test/electron/document-links/fixtures/scoped.scss create mode 100644 extension/test/electron/document-links/fixtures/styles.scss create mode 100644 extension/test/electron/document-links/index.js create mode 100644 extension/test/electron/mocha.js create mode 100644 extension/test/electron/run.js create mode 100644 extension/test/electron/util.js create mode 100644 pkgs/sass_language_server/test/workspace_test.dart diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fac714b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,106 @@ +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 }}" + 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: + - if: ${{ matrix.os == 'windows-latest' }} + run: git config --global core.autocrlf false + - 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 + 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: + - if: ${{ matrix.os == 'windows-latest' }} + run: git config --global core.autocrlf false + + - 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: Update npm for attestation feature + run: npm install -g npm@latest + + - name: Install dependencies + run: npm clean-install + working-directory: extension + + - name: Verify the integrity of provenance attestations and registry signatures for installed dependencies + run: npm audit signatures + working-directory: extension + + - name: Build extension + run: npm run build + 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 diff --git a/.gitignore b/.gitignore index 6e2a5c3..e481259 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/extension/.npmrc b/extension/.npmrc new file mode 100644 index 0000000..cffe8cd --- /dev/null +++ b/extension/.npmrc @@ -0,0 +1 @@ +save-exact=true diff --git a/extension/README.md b/extension/README.md index 2617d7c..6f75a7a 100644 --- a/extension/README.md +++ b/extension/README.md @@ -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. +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.