From 7c7aa4c14b5f90fae4b05efd707b724496c5b398 Mon Sep 17 00:00:00 2001 From: sockmaster27 <61235930+sockmaster27@users.noreply.github.com> Date: Sun, 17 Mar 2024 16:31:38 +0100 Subject: [PATCH] chore: also run tests for minimum supported version --- .github/workflows/node.js.yml | 40 ++++++++++++++++++++++++++++++----- .vscode-test.js | 8 +++++++ 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 1e6dab2..5edf921 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -10,16 +10,44 @@ on: branches: [ master ] jobs: - build: + configure: + runs-on: ubuntu-latest + outputs: + minimum-version: ${{ steps.minver.outputs.version }} + steps: + - uses: actions/checkout@v4 + - name: Read package.json + id: package + # Reads the contents of `pacakge.json` into `steps.package.outputs.content` + run: | + content=`cat ./package.json` + content="${content//'%'/'%25'}" + content="${content//$'\n'/'%0A'}" + content="${content//$'\r'/'%0D'}" + echo "::set-output name=content::$content" + - name: Extract minimum version + id: minver + # Reads the contents of the `engines.vscode` field into `steps.minver.outputs.version` with the leading ^ removed. + run: | + version=${{ fromJson(steps.package.outputs.content).engines.vscode }} + version=${version#^} + echo "::set-output name=version::$version" + check: runs-on: ubuntu-latest + needs: configure strategy: matrix: - node-version: [18.x, 20.x] + vscode-version: + - ${{ needs.configure.outputs.minimum-version }} + - stable + node-version: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + - 18.x + - 20.x - steps: + steps: - uses: actions/checkout@v4 - uses: actions/setup-java@v4 with: @@ -31,7 +59,9 @@ jobs: node-version: ${{ matrix.node-version }} - name: Install dependencies run: npm ci - - name: Run tests + - name: Run tests on VS Code ${{ matrix.vscode-version }} run: xvfb-run -a npm test + env: + VSCODE_VERSION: ${{ matrix.vscode-version }} - name: Package extension - run: npx @vscode/vsce package + run: npx --yes @vscode/vsce package diff --git a/.vscode-test.js b/.vscode-test.js index efc3ea6..feaf3da 100644 --- a/.vscode-test.js +++ b/.vscode-test.js @@ -1,6 +1,14 @@ const { defineConfig } = require('@vscode/test-cli') +/** + * The desired version of VS Code can be optionally passed as an environment variable, for example: + * - `stable` + * - `1.80.0` + */ +let version = process.env.VSCODE_VERSION + module.exports = defineConfig({ + version, files: ['test/out/**/*.test.js'], workspaceFolder: 'test/testWorkspace',