From d8092fd8a08af7e7f2899aac8df9f0afd0fc048f Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Wed, 9 Oct 2024 14:11:29 +0200 Subject: [PATCH 01/22] ci: added sonar action and separated e2e action from the rest --- .github/workflows/lint.yml | 21 ---------- .github/workflows/nodejs.yml | 79 ++++++++++++++++++++++++++++++++++-- 2 files changed, 76 insertions(+), 24 deletions(-) delete mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 76b465a..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: ESLint - -on: - pull_request: - -jobs: - eslint: - name: Run eslint scanning - runs-on: ubuntu-latest - permissions: - contents: read - security-events: write - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install dependencies - run: npm ci - - - name: Run ESLint - run: npm run lint diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 07f155c..c72c014 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -31,12 +31,17 @@ jobs: - name: Check Docker Version run: docker --version - - name: Check Node.js version - run: node -v - - name: Check npm versions run: npm -v + - name: Cache node_modules + uses: actions/cache@v4 + with: + path: node_modules + key: node_modules-${{ matrix.os }}-node-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }} + restore-keys: | + node_modules-${{ matrix.os }}-node-${{ matrix.node-version }} + - name: Run clean install run: npm ci @@ -45,6 +50,31 @@ jobs: - run: npm test if: runner.os != 'Linux' + e2e-tests: + needs: build + strategy: + matrix: + # No windows runner, because in this extension, we have a lot of tests that need docker in the WSL. + # Sadly, the setup-wsl (https://github.com/Vampire/setup-wsl) and the current windows runners only support WSL 1. + # Therefore, we can not install and start a docker container in the WSL. + + # Currently, no macOS runner, because during the setup of docker, this runner hangs: https://github.com/douglascamata/setup-docker-macos-action/issues/37 + node-version: [18.x, 20.x, 22.x] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Set up JDK for Liquibase CLI + uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: temurin + - name: run e2e tests run: xvfb-run -a npm run test:e2e -- --storage ./out/test-resources/${{ matrix.os }}/${{ matrix.node-version }} if: runner.os == 'Linux' @@ -61,3 +91,46 @@ jobs: path: ./out/test-resources/**/screenshots/** retention-days: 5 if-no-files-found: ignore + + sonar: + name: Run eslint and sonar scanning + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22.x + + - name: Restore cached node_modules + uses: actions/cache@v4 + with: + path: node_modules + key: node_modules-ubuntu-latest-node-22.x-${{ hashFiles('package-lock.json') }} + restore-keys: | + node_modules-ubuntu-latest-node-22.x + - name: Run ESLint + run: npm run lint -- --format json --output-file eslint-results.json || true + + - name: Install Mocha reporters + run: npm install -d mocha-multi-reporters mocha-junit-reporter mocha-sonarqube-reporter + - name: create mocha config + run: | + echo '{ + "reporterEnabled": "spec, mocha-junit-reporter, mocha-sonarqube-reporter" + }' > config.json + - name: Run tests with coverage + run: xvfb-run -a npm test -- --coverage --coverage-output ./coverage --coverage-reporter lcovonly --reporter mocha-multi-reporters --reporter-options configFile=config.json + + - name: Analyze with SonarCloud + uses: SonarSource/sonarcloud-github-action@master + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: -Dsonar.projectKey=aditosoftware_vscode-liquibase + -Dsonar.organization=aditosoftware + -Dsonar.eslint.reportPaths=eslint-results.json + -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info From 380cfedee33ede13f5f45ff54c5f4aafb0b5c539 Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Wed, 9 Oct 2024 14:15:52 +0200 Subject: [PATCH 02/22] test: added more retries --- .vscode-test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode-test.mjs b/.vscode-test.mjs index 2a87d61..2b70d12 100644 --- a/.vscode-test.mjs +++ b/.vscode-test.mjs @@ -7,7 +7,7 @@ export default defineConfig({ launchArgs: ["--disable-extensions", "--profile-temp"], mocha: { ui: "tdd", - retries: 3, + retries: 5, }, coverage: { // coverage exclusion currently does not work: https://github.com/microsoft/vscode-test-cli/issues/40 From 3307033811eba0c6852b3d97d5c310ff3c31e4fc Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Wed, 9 Oct 2024 14:29:34 +0200 Subject: [PATCH 03/22] ci: passing coverage from build step --- .github/workflows/nodejs.yml | 43 +++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index c72c014..035a843 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -75,9 +75,36 @@ jobs: java-version: 21 distribution: temurin + - name: Restore cached node_modules + uses: actions/cache@v4 + with: + path: node_modules + key: node_modules-${{ matrix.os }}-node-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }} + restore-keys: | + node_modules-${{ matrix.os }}-node-${{ matrix.node-version }} + - name: run e2e tests run: xvfb-run -a npm run test:e2e -- --storage ./out/test-resources/${{ matrix.os }}/${{ matrix.node-version }} - if: runner.os == 'Linux' + if: runner.os == 'Linux' && matrix.node-version != '22.x' + + - name: Install Mocha reporters + run: npm install -d mocha-multi-reporters mocha-junit-reporter mocha-sonarqube-reporter + if: matrix.os == 'ubuntu-latest' && matrix.node-version == '22.x' + - name: create mocha config + run: | + echo '{ + "reporterEnabled": "spec, mocha-junit-reporter, mocha-sonarqube-reporter" + }' > config.json + if: matrix.os == 'ubuntu-latest' && matrix.node-version == '22.x' + - name: Run tests with coverage + run: xvfb-run -a npm test -- --coverage --coverage-output ./coverage --coverage-reporter lcovonly --reporter mocha-multi-reporters --reporter-options configFile=config.json + if: matrix.os == 'ubuntu-latest' && matrix.node-version == '22.x' + + - name: Upload coverage as artifact + uses: actions/upload-artifact@v4 + with: + name: coverage + path: coverage/lcov.info - name: npm e2e tests run: npm run test:e2e -- --storage ./out/test-resources/${{ matrix.os }}/${{ matrix.node-version }} @@ -115,15 +142,11 @@ jobs: - name: Run ESLint run: npm run lint -- --format json --output-file eslint-results.json || true - - name: Install Mocha reporters - run: npm install -d mocha-multi-reporters mocha-junit-reporter mocha-sonarqube-reporter - - name: create mocha config - run: | - echo '{ - "reporterEnabled": "spec, mocha-junit-reporter, mocha-sonarqube-reporter" - }' > config.json - - name: Run tests with coverage - run: xvfb-run -a npm test -- --coverage --coverage-output ./coverage --coverage-reporter lcovonly --reporter mocha-multi-reporters --reporter-options configFile=config.json + - name: Download node_modules artifact + uses: actions/download-artifact@v4 + with: + name: coverage + path: coverage/lcov.info - name: Analyze with SonarCloud uses: SonarSource/sonarcloud-github-action@master From f30ca12c1f209579d76c3ddc129b70eb0e8573c7 Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Wed, 9 Oct 2024 14:37:46 +0200 Subject: [PATCH 04/22] ci: moved artifact for coverage to correct job --- .github/workflows/nodejs.yml | 45 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 035a843..8a273fa 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -45,10 +45,30 @@ jobs: - name: Run clean install run: npm ci + - name: Install Mocha reporters + run: npm install -d mocha-multi-reporters mocha-junit-reporter mocha-sonarqube-reporter + if: matrix.os == 'ubuntu-latest' && matrix.node-version == '22.x' + - name: create mocha config + run: | + echo '{ + "reporterEnabled": "spec, mocha-junit-reporter, mocha-sonarqube-reporter" + }' > config.json + if: matrix.os == 'ubuntu-latest' && matrix.node-version == '22.x' + - run: xvfb-run -a npm test - if: runner.os == 'Linux' + if: runner.os == 'ubuntu-latest' && matrix.node-version != '22.x' - run: npm test - if: runner.os != 'Linux' + if: runner.os != 'ubuntu-latest' + - name: Run tests with coverage + run: xvfb-run -a npm test -- --coverage --coverage-output ./coverage --coverage-reporter lcovonly --reporter mocha-multi-reporters --reporter-options configFile=config.json + if: matrix.os == 'ubuntu-latest' && matrix.node-version == '22.x' + + - name: Upload coverage as artifact + uses: actions/upload-artifact@v4 + if: matrix.os == 'ubuntu-latest' && matrix.node-version == '22.x' + with: + name: coverage + path: coverage/lcov.info e2e-tests: needs: build @@ -85,26 +105,7 @@ jobs: - name: run e2e tests run: xvfb-run -a npm run test:e2e -- --storage ./out/test-resources/${{ matrix.os }}/${{ matrix.node-version }} - if: runner.os == 'Linux' && matrix.node-version != '22.x' - - - name: Install Mocha reporters - run: npm install -d mocha-multi-reporters mocha-junit-reporter mocha-sonarqube-reporter - if: matrix.os == 'ubuntu-latest' && matrix.node-version == '22.x' - - name: create mocha config - run: | - echo '{ - "reporterEnabled": "spec, mocha-junit-reporter, mocha-sonarqube-reporter" - }' > config.json - if: matrix.os == 'ubuntu-latest' && matrix.node-version == '22.x' - - name: Run tests with coverage - run: xvfb-run -a npm test -- --coverage --coverage-output ./coverage --coverage-reporter lcovonly --reporter mocha-multi-reporters --reporter-options configFile=config.json - if: matrix.os == 'ubuntu-latest' && matrix.node-version == '22.x' - - - name: Upload coverage as artifact - uses: actions/upload-artifact@v4 - with: - name: coverage - path: coverage/lcov.info + if: runner.os == 'Linux' - name: npm e2e tests run: npm run test:e2e -- --storage ./out/test-resources/${{ matrix.os }}/${{ matrix.node-version }} From ffccfdc5eb08827980eda7be2ddf290b4034b302 Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Wed, 9 Oct 2024 14:42:44 +0200 Subject: [PATCH 05/22] ci: changed if from ubuntu to Linux --- .github/workflows/nodejs.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 8a273fa..6ac8473 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -47,25 +47,25 @@ jobs: - name: Install Mocha reporters run: npm install -d mocha-multi-reporters mocha-junit-reporter mocha-sonarqube-reporter - if: matrix.os == 'ubuntu-latest' && matrix.node-version == '22.x' + if: matrix.os == 'Linux' && matrix.node-version == '22.x' - name: create mocha config run: | echo '{ "reporterEnabled": "spec, mocha-junit-reporter, mocha-sonarqube-reporter" }' > config.json - if: matrix.os == 'ubuntu-latest' && matrix.node-version == '22.x' + if: matrix.os == 'Linux' && matrix.node-version == '22.x' - run: xvfb-run -a npm test - if: runner.os == 'ubuntu-latest' && matrix.node-version != '22.x' + if: runner.os == 'Linux' && matrix.node-version != '22.x' - run: npm test if: runner.os != 'ubuntu-latest' - name: Run tests with coverage run: xvfb-run -a npm test -- --coverage --coverage-output ./coverage --coverage-reporter lcovonly --reporter mocha-multi-reporters --reporter-options configFile=config.json - if: matrix.os == 'ubuntu-latest' && matrix.node-version == '22.x' + if: matrix.os == 'Linux' && matrix.node-version == '22.x' - name: Upload coverage as artifact uses: actions/upload-artifact@v4 - if: matrix.os == 'ubuntu-latest' && matrix.node-version == '22.x' + if: matrix.os == 'Linux' && matrix.node-version == '22.x' with: name: coverage path: coverage/lcov.info From b6c78a2b512e7dec5aaa8856e59af2f52d6b99ad Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Wed, 9 Oct 2024 14:50:33 +0200 Subject: [PATCH 06/22] ci: corrected ifs --- .github/workflows/nodejs.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 6ac8473..edf5664 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -47,13 +47,13 @@ jobs: - name: Install Mocha reporters run: npm install -d mocha-multi-reporters mocha-junit-reporter mocha-sonarqube-reporter - if: matrix.os == 'Linux' && matrix.node-version == '22.x' + if: runner.os == 'Linux' && matrix.node-version == '22.x' - name: create mocha config run: | echo '{ "reporterEnabled": "spec, mocha-junit-reporter, mocha-sonarqube-reporter" }' > config.json - if: matrix.os == 'Linux' && matrix.node-version == '22.x' + if: runner.os == 'Linux' && matrix.node-version == '22.x' - run: xvfb-run -a npm test if: runner.os == 'Linux' && matrix.node-version != '22.x' @@ -61,11 +61,11 @@ jobs: if: runner.os != 'ubuntu-latest' - name: Run tests with coverage run: xvfb-run -a npm test -- --coverage --coverage-output ./coverage --coverage-reporter lcovonly --reporter mocha-multi-reporters --reporter-options configFile=config.json - if: matrix.os == 'Linux' && matrix.node-version == '22.x' + if: runner.os == 'Linux' && matrix.node-version == '22.x' - name: Upload coverage as artifact uses: actions/upload-artifact@v4 - if: matrix.os == 'Linux' && matrix.node-version == '22.x' + if: runner.os == 'Linux' && matrix.node-version == '22.x' with: name: coverage path: coverage/lcov.info From 9f3bde66dc0b83458d02519b562068a09e493bcd Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Wed, 9 Oct 2024 14:59:21 +0200 Subject: [PATCH 07/22] ci: corrected every runner os --- .github/workflows/nodejs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index edf5664..a69dfd9 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -58,7 +58,7 @@ jobs: - run: xvfb-run -a npm test if: runner.os == 'Linux' && matrix.node-version != '22.x' - run: npm test - if: runner.os != 'ubuntu-latest' + if: runner.os != 'Linux' - name: Run tests with coverage run: xvfb-run -a npm test -- --coverage --coverage-output ./coverage --coverage-reporter lcovonly --reporter mocha-multi-reporters --reporter-options configFile=config.json if: runner.os == 'Linux' && matrix.node-version == '22.x' From afebd76fc390345854a0a1706e2b058bac4d5916 Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Thu, 10 Oct 2024 06:07:47 +0200 Subject: [PATCH 08/22] ci: added webviews build output to actions --- .github/workflows/nodejs.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index a69dfd9..f296177 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -38,6 +38,8 @@ jobs: uses: actions/cache@v4 with: path: node_modules + src/webview-ui/build + src/webview-ui/node-modules key: node_modules-${{ matrix.os }}-node-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }} restore-keys: | node_modules-${{ matrix.os }}-node-${{ matrix.node-version }} @@ -99,6 +101,8 @@ jobs: uses: actions/cache@v4 with: path: node_modules + src/webview-ui/build + src/webview-ui/node-modules key: node_modules-${{ matrix.os }}-node-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }} restore-keys: | node_modules-${{ matrix.os }}-node-${{ matrix.node-version }} @@ -137,6 +141,8 @@ jobs: uses: actions/cache@v4 with: path: node_modules + src/webview-ui/build + src/webview-ui/node-modules key: node_modules-ubuntu-latest-node-22.x-${{ hashFiles('package-lock.json') }} restore-keys: | node_modules-ubuntu-latest-node-22.x @@ -149,6 +155,9 @@ jobs: name: coverage path: coverage/lcov.info + - name: exists coverage + run: ls -R coverage + - name: Analyze with SonarCloud uses: SonarSource/sonarcloud-github-action@master env: From df1467a3f837eca6d60d34c20b1d8ed5d0596873 Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Thu, 10 Oct 2024 06:14:31 +0200 Subject: [PATCH 09/22] ci: correcting cache, trying to add tests to sonar --- .github/workflows/nodejs.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index f296177..8db179f 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -38,8 +38,8 @@ jobs: uses: actions/cache@v4 with: path: node_modules - src/webview-ui/build - src/webview-ui/node-modules + webview-ui/build + webview-ui/node-modules key: node_modules-${{ matrix.os }}-node-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }} restore-keys: | node_modules-${{ matrix.os }}-node-${{ matrix.node-version }} @@ -100,9 +100,10 @@ jobs: - name: Restore cached node_modules uses: actions/cache@v4 with: - path: node_modules - src/webview-ui/build - src/webview-ui/node-modules + path: | + node_modules + webview-ui/build + webview-ui/node-modules key: node_modules-${{ matrix.os }}-node-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }} restore-keys: | node_modules-${{ matrix.os }}-node-${{ matrix.node-version }} @@ -141,8 +142,8 @@ jobs: uses: actions/cache@v4 with: path: node_modules - src/webview-ui/build - src/webview-ui/node-modules + webview-ui/build + webview-ui/node-modules key: node_modules-ubuntu-latest-node-22.x-${{ hashFiles('package-lock.json') }} restore-keys: | node_modules-ubuntu-latest-node-22.x @@ -167,3 +168,4 @@ jobs: -Dsonar.organization=aditosoftware -Dsonar.eslint.reportPaths=eslint-results.json -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info + -Dsonar.tests=src/test,out/test From e301ccaa283150ad1eaedb25024a9392dd30a4e8 Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Thu, 10 Oct 2024 06:21:10 +0200 Subject: [PATCH 10/22] ci: correcting cache parts --- .github/workflows/nodejs.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 8db179f..0ac592f 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -37,7 +37,8 @@ jobs: - name: Cache node_modules uses: actions/cache@v4 with: - path: node_modules + path: | + node_modules webview-ui/build webview-ui/node-modules key: node_modules-${{ matrix.os }}-node-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }} @@ -141,7 +142,8 @@ jobs: - name: Restore cached node_modules uses: actions/cache@v4 with: - path: node_modules + path: | + node_modules webview-ui/build webview-ui/node-modules key: node_modules-ubuntu-latest-node-22.x-${{ hashFiles('package-lock.json') }} @@ -168,4 +170,4 @@ jobs: -Dsonar.organization=aditosoftware -Dsonar.eslint.reportPaths=eslint-results.json -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info - -Dsonar.tests=src/test,out/test + -Dsonar.tests=src/test From 7b964df1b29fd7f2a1447b6345aca9df9e3d8196 Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Thu, 10 Oct 2024 07:28:51 +0200 Subject: [PATCH 11/22] docs: added badges --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e157aac..93e22bb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=aditosoftware_vscode-liquibase&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=aditosoftware_vscode-liquibase) +[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=aditosoftware_vscode-liquibase&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=aditosoftware_vscode-liquibase) +[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=aditosoftware_vscode-liquibase&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=aditosoftware_vscode-liquibase) + # Liquibase A Visual Studio Code extension that supports executing [Liquibase commands](https://docs.liquibase.com/commands/command-list.html) without needing to use the command line. From 0a70d8fa28aa7a1d77ade471664f2f37387aaedf Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Thu, 10 Oct 2024 07:29:21 +0200 Subject: [PATCH 12/22] refactor: corrected sonar warnings --- .github/workflows/nodejs.yml | 1 - src/cache/CacheHandler.ts | 4 +- src/cache/CacheRemover.ts | 8 +-- src/configuration/data/DatabaseConnection.ts | 6 +- .../data/LiquibaseConfigurationData.ts | 2 +- src/configuration/handleChangelogSelection.ts | 2 +- src/executeJar.ts | 6 +- src/handleChangelogFileInput.ts | 22 +------ src/handleContexts.ts | 14 ++-- src/handleLiquibaseSettings.ts | 2 +- src/liquibaseCommandsUtilities.ts | 2 +- src/panels/LiquibaseConfigurationPanel.ts | 31 ++++----- src/prerequisites.ts | 2 +- src/settings/removeConfiguration.ts | 2 +- src/test/e2e/commands/update.test.ts | 23 +++---- src/test/suite/DockerTestUtils.ts | 4 +- .../settings/configurationCommands.test.ts | 14 ++-- .../suite/handleChangelogFileInput.test.ts | 41 ------------ .../suite/utilities/vscodeUtilities.test.ts | 2 +- webview-ui/src/App.tsx | 15 ++--- .../src/components/AdditionalElements.tsx | 2 +- .../src/components/DatabaseConfiguration.tsx | 2 +- webview-ui/src/utilities/vscodeApiWrapper.ts | 64 +++++++++---------- 23 files changed, 96 insertions(+), 175 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 0ac592f..01ac9f5 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -170,4 +170,3 @@ jobs: -Dsonar.organization=aditosoftware -Dsonar.eslint.reportPaths=eslint-results.json -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info - -Dsonar.tests=src/test diff --git a/src/cache/CacheHandler.ts b/src/cache/CacheHandler.ts index f488625..5f32d7f 100644 --- a/src/cache/CacheHandler.ts +++ b/src/cache/CacheHandler.ts @@ -268,7 +268,7 @@ export class CacheHandler { readContexts(connectionLocation: string, changelogLocation: string): ContextSelection { const existingChangelog = this.getChangelog(connectionLocation, changelogLocation).existingChangelog; - if (existingChangelog && existingChangelog.contexts) { + if (existingChangelog?.contexts) { // sort any loaded contexts existingChangelog.contexts.loadedContexts?.sort((a, b) => a.localeCompare(b)); @@ -287,7 +287,7 @@ export class CacheHandler { readChangelogs(connectionLocation: string): string[] { const cache = this.readCache(); - if (cache[connectionLocation] && cache[connectionLocation].changelogs) { + if (cache[connectionLocation]?.changelogs) { return cache[connectionLocation].changelogs .toSorted((a, b) => b.lastUsed - a.lastUsed) .map((pChangelog) => pChangelog.path); diff --git a/src/cache/CacheRemover.ts b/src/cache/CacheRemover.ts index af1d6d6..07eb38e 100644 --- a/src/cache/CacheRemover.ts +++ b/src/cache/CacheRemover.ts @@ -84,7 +84,7 @@ export class CacheRemover { const toRemove = result.inputValues.get(CacheRemover.removeOption); - if (toRemove && toRemove[0]) { + if (toRemove?.[0]) { this.handleRemoval(toRemove[0], result); } } @@ -170,9 +170,9 @@ export class CacheRemover { // Build the details let detail = ""; - if (toRemove && toRemove[0]) { + if (toRemove?.[0]) { // add information about the remove option - detail = CacheRemover.removeOptions.get(toRemove[0]) || ""; + detail = CacheRemover.removeOptions.get(toRemove[0]) ?? ""; } if (propertyFiles) { @@ -193,7 +193,7 @@ export class CacheRemover { private shouldShowPropertyFileSelection(currentResults: DialogValues): boolean { const toRemove = currentResults.inputValues.get(CacheRemover.removeOption); - if (toRemove && toRemove[0]) { + if (toRemove?.[0]) { return toRemove[0] !== RemoveCacheOptions.WHOLE_CACHE; } else { return false; diff --git a/src/configuration/data/DatabaseConnection.ts b/src/configuration/data/DatabaseConnection.ts index 0b12d41..9158f18 100644 --- a/src/configuration/data/DatabaseConnection.ts +++ b/src/configuration/data/DatabaseConnection.ts @@ -74,7 +74,7 @@ export class DatabaseConnection { if (driver) { // and extract the url parts return driver.extractUrlParts(this.url); - } else if (customDriver && customDriver[this.databaseType]) { + } else if (customDriver?.[this.databaseType]) { return new CustomDriver(customDriver[this.databaseType]).extractUrlParts(this.url); } @@ -89,7 +89,7 @@ export class DatabaseConnection { */ getValue(pName: keyof DatabaseConnection): string | undefined { if (typeof this[pName] === "string") { - return this[pName] as string; + return this[pName]; } } @@ -100,7 +100,7 @@ export class DatabaseConnection { * @param pValue - the value that should be set * @returns the updated element */ - setValue(pName: keyof DatabaseConnection, pValue: string): DatabaseConnection { + setValue(pName: keyof DatabaseConnection, pValue: string): this { if (typeof this[pName] === "string") { (this[pName] as string) = pValue; } diff --git a/src/configuration/data/LiquibaseConfigurationData.ts b/src/configuration/data/LiquibaseConfigurationData.ts index 0072287..513901b 100644 --- a/src/configuration/data/LiquibaseConfigurationData.ts +++ b/src/configuration/data/LiquibaseConfigurationData.ts @@ -188,7 +188,7 @@ export class LiquibaseConfigurationData { } // and write the reference properties - if (this.referenceDatabaseConnection && this.referenceDatabaseConnection.hasData()) { + if (this.referenceDatabaseConnection?.hasData()) { this.referenceDatabaseConnection.writeDataForConnection(properties, true, pDisguisePassword); } diff --git a/src/configuration/handleChangelogSelection.ts b/src/configuration/handleChangelogSelection.ts index a98cb6e..39fc0ac 100644 --- a/src/configuration/handleChangelogSelection.ts +++ b/src/configuration/handleChangelogSelection.ts @@ -21,7 +21,7 @@ export async function chooseFileForChangelog(data: LiquibaseConfigurationData): }, }); - if (result && result[0]) { + if (result?.[0]) { const chosenFile = result[0].fsPath; // find out relative path diff --git a/src/executeJar.ts b/src/executeJar.ts index 59bf487..a58418f 100644 --- a/src/executeJar.ts +++ b/src/executeJar.ts @@ -135,7 +135,7 @@ export function executeJarAsync( } }); - childProcess.on("error", (error) => { + childProcess.on("error", (error: Error) => { Logger.getLogger().error({ message: "Child process encountered an error", error }); reject(error); }); @@ -233,11 +233,11 @@ export async function loadContextsFromChangelogFile( error: { stack: result.stderr }, notifyUser: true, }); - reject(`Error ${result.status}, ${result.error?.message}\n ${result.stderr}`); + reject(new Error(`Error ${result.status}, ${result.error?.message}\n ${result.stderr}`)); } } catch (error) { Logger.getLogger().error({ message: "Error loading contexts", error, notifyUser: true }); - reject(error); + reject(error as Error); } }); } diff --git a/src/handleChangelogFileInput.ts b/src/handleChangelogFileInput.ts index 4a0c101..bc462a6 100644 --- a/src/handleChangelogFileInput.ts +++ b/src/handleChangelogFileInput.ts @@ -105,7 +105,7 @@ export class HandleChangelogFileInput { */ private static getChangelogFileFromProperties(dialogValues: DialogValues): string | undefined { const propertyFile = dialogValues.inputValues.get(PROPERTY_FILE); - if (propertyFile && propertyFile[0]) { + if (propertyFile?.[0]) { const changelog = readChangelog(propertyFile[0]); if (changelog) { // if there is a changelog in in property-file, return it, so we can show it in the dialog @@ -114,24 +114,6 @@ export class HandleChangelogFileInput { } } - /** - * Checks if the changelog needs to be put into by an extra open dialog. - * - * @param dialogValues - the current dialog values - * @returns `true` if an OpenDialog is needed for selecting the changelog - */ - private static isChangelogFromOpenDialogNeeded(dialogValues: DialogValues): boolean { - if (this.isExtraQueryForChangelogNeeded(dialogValues)) { - const changelogPreSelection = dialogValues.inputValues.get(this.CHANGELOG_QUICK_PICK_NAME); - if (changelogPreSelection && changelogPreSelection[0]) { - // check, if the correct option was selected - return changelogPreSelection[0] === CHOOSE_CHANGELOG_OPTION; - } - } - - return false; - } - /** * Sets the changelog file from the current dialog correctly as uri (exactly as context menu). * This will mimic the behavior from a context menu, which is correct in this case. @@ -145,7 +127,7 @@ export class HandleChangelogFileInput { let changelogPath: string | undefined; - if (fileSelection && fileSelection[0]) { + if (fileSelection?.[0]) { if (fileSelection[0] === CHOOSE_CHANGELOG_OPTION) { // we are not having a correct values selected, but instead a dialog progression value // => we do not need to save anything diff --git a/src/handleContexts.ts b/src/handleContexts.ts index c69c09e..32490e5 100644 --- a/src/handleContexts.ts +++ b/src/handleContexts.ts @@ -74,11 +74,7 @@ export function generateContextInputs(): PickPanelConfig[] { export function generateItemsForContextPreDialog(contextCacheInfo?: ContextCacheInformation): vscode.QuickPickItem[] { const items: vscode.QuickPickItem[] = []; - if ( - contextCacheInfo && - contextCacheInfo.contexts.loadedContexts && - contextCacheInfo.contexts.loadedContexts.length !== 0 - ) { + if (contextCacheInfo?.contexts.loadedContexts && contextCacheInfo?.contexts.loadedContexts.length !== 0) { const cachedContexts = contextCacheInfo.contexts.loadedContexts.join(", "); items.push({ label: ContextOptions.USE_RECENTLY_LOADED, @@ -132,10 +128,8 @@ export function saveSelectedContexts(dialogValues: DialogValues, contextCacheInf */ function generateCmdArgsForPreContextSelection(dialogValues: DialogValues): string[] | undefined { const selected = dialogValues.inputValues.get(contextPreDialog); - if (selected && selected[0]) { - if (selected[0] === ContextOptions.NO_CONTEXT) { - return [`--contexts=${NO_CONTEXT_USED}`]; - } + if (selected?.[0] === ContextOptions.NO_CONTEXT) { + return [`--contexts=${NO_CONTEXT_USED}`]; } } @@ -189,7 +183,7 @@ export function loadCacheForPropertyFile(currentResults: DialogValues): ContextC function showContextSelection(dialogValues: DialogValues): boolean { const result = dialogValues.inputValues.get(contextPreDialog); - if (result && result[0]) { + if (result?.[0]) { return result[0] !== ContextOptions.NO_CONTEXT; } diff --git a/src/handleLiquibaseSettings.ts b/src/handleLiquibaseSettings.ts index 2758e3f..a5fd660 100644 --- a/src/handleLiquibaseSettings.ts +++ b/src/handleLiquibaseSettings.ts @@ -87,7 +87,7 @@ export function getDefaultDatabaseForConfiguration(): string { NO_PRE_CONFIGURED_DRIVER ); - return defaultDatabaseForConfiguration ? defaultDatabaseForConfiguration : NO_PRE_CONFIGURED_DRIVER; + return defaultDatabaseForConfiguration || NO_PRE_CONFIGURED_DRIVER; } /** diff --git a/src/liquibaseCommandsUtilities.ts b/src/liquibaseCommandsUtilities.ts index e37a91e..bac6ca7 100644 --- a/src/liquibaseCommandsUtilities.ts +++ b/src/liquibaseCommandsUtilities.ts @@ -109,7 +109,7 @@ export async function openIndexHtmlAfterCommandExecution(dialogValues: DialogVal export async function changeAndEmptyOutputDirectory(dialogValues: DialogValues): Promise { const folder = dialogValues.inputValues.get(folderSelectionName)?.[0]; - if (folder && folder.includes(os.tmpdir())) { + if (folder?.includes(os.tmpdir())) { const propertyFile = dialogValues.inputValues.get(PROPERTY_FILE)?.[0]; let configurationName = "db-doc"; diff --git a/src/panels/LiquibaseConfigurationPanel.ts b/src/panels/LiquibaseConfigurationPanel.ts index bd72038..c6d4724 100644 --- a/src/panels/LiquibaseConfigurationPanel.ts +++ b/src/panels/LiquibaseConfigurationPanel.ts @@ -21,9 +21,9 @@ import path from "path"; * - Setting message listeners so data can be passed between the webview and extension */ export class LiquibaseConfigurationPanel { - public static currentPanel: LiquibaseConfigurationPanel | undefined; + private static currentPanel: LiquibaseConfigurationPanel | undefined; private readonly _panel: WebviewPanel; - private _disposables: Disposable[] = []; + private readonly _disposables: Disposable[] = []; /** * The LiquibaseConfigurationPanel class private constructor (called only from the render method). @@ -84,16 +84,15 @@ export class LiquibaseConfigurationPanel { // In all cases, transfer a message with the current data this.transferMessage( MessageType.INIT, - data - ? data - : LiquibaseConfigurationData.createDefaultData( - { - defaultDatabaseForConfiguration: getDefaultDatabaseForConfiguration(), - liquibaseDirectoryInProject: getLiquibaseFolder(), - customDrivers: getCustomDrivers(), - }, - ConfigurationStatus.NEW - ) + data || + LiquibaseConfigurationData.createDefaultData( + { + defaultDatabaseForConfiguration: getDefaultDatabaseForConfiguration(), + liquibaseDirectoryInProject: getLiquibaseFolder(), + customDrivers: getCustomDrivers(), + }, + ConfigurationStatus.NEW + ) ); } @@ -212,12 +211,10 @@ export class LiquibaseConfigurationPanel { default: throw new Error(`Handling for command ${messageType} not found.`); } + } else if (messageData.messageType === MessageType.LOG_MESSAGE) { + Logger.getLogger().log(data); } else { - if (messageData.messageType === MessageType.LOG_MESSAGE) { - Logger.getLogger().log(data); - } else { - throw new Error(`Handling for command ${messageType} not found.`); - } + throw new Error(`Handling for command ${messageType} not found.`); } }, undefined, diff --git a/src/prerequisites.ts b/src/prerequisites.ts index 83a80ca..b7b12a7 100644 --- a/src/prerequisites.ts +++ b/src/prerequisites.ts @@ -76,7 +76,7 @@ async function downloadLiquibaseFiles(pathToResources: string, downloadUrls: str return new Promise((resolve, reject) => { Promise.all(downloadUrls.map((url) => download(url, path.join(pathToResources)))) .then(() => resolve()) - .catch((error) => { + .catch((error: Error) => { Logger.getLogger().error({ message: "downloadLiquibaseFiles threw an error", error }); reject(error); }); diff --git a/src/settings/removeConfiguration.ts b/src/settings/removeConfiguration.ts index 13ea2d6..d82f456 100644 --- a/src/settings/removeConfiguration.ts +++ b/src/settings/removeConfiguration.ts @@ -149,7 +149,7 @@ export function generateDetailMessageForDeleteConfiguration(dialogValues: Dialog whatDeleted .get(deletionMode) ?.map((pElement) => "- " + pElement) - .join("\n") || ""; + .join("\n") ?? ""; } return `This will remove the configuration from the following:\n${deletedDetail}`; diff --git a/src/test/e2e/commands/update.test.ts b/src/test/e2e/commands/update.test.ts index c36d658..80f6a30 100644 --- a/src/test/e2e/commands/update.test.ts +++ b/src/test/e2e/commands/update.test.ts @@ -42,25 +42,20 @@ suite("Update", function () { "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'person'" ); - if (option === ContextOptions.NO_CONTEXT) { + if ( + option !== ContextOptions.NO_CONTEXT && + (key === "all available contexts" || key === "the first available context") + ) { + assert.ok( + databaseInformation?.length >= 1, + `Table 'person' DOES NOT exist, while it should: ${databaseInformation}` + ); + } else { assert.strictEqual( databaseInformation.length, 0, `Table 'person' DOES exist, while it shouldn't: ${databaseInformation}` ); - } else { - if (key === "all available contexts" || key === "the first available context") { - assert.ok( - databaseInformation?.length >= 1, - `Table 'person' DOES NOT exist, while it should: ${databaseInformation}` - ); - } else { - assert.strictEqual( - databaseInformation.length, - 0, - `Table 'person' DOES exist, while it shouldn't: ${databaseInformation}` - ); - } } }); }); diff --git a/src/test/suite/DockerTestUtils.ts b/src/test/suite/DockerTestUtils.ts index 3d0ba69..a29c039 100644 --- a/src/test/suite/DockerTestUtils.ts +++ b/src/test/suite/DockerTestUtils.ts @@ -1,4 +1,4 @@ -import { exec } from "child_process"; +import { exec, ExecException } from "child_process"; import { isWindows } from "../../utilities/osUtilities"; import mariadb from "mariadb"; @@ -186,7 +186,7 @@ export class DockerTestUtils { */ private static async executeCommand(command: string): Promise { return new Promise((resolve, reject) => { - exec(command, (error, stdout, stderr) => { + exec(command, (error: ExecException | null, stdout, stderr) => { if (error) { reject(error); return; diff --git a/src/test/suite/configuration/settings/configurationCommands.test.ts b/src/test/suite/configuration/settings/configurationCommands.test.ts index 2535dde..82dbaff 100644 --- a/src/test/suite/configuration/settings/configurationCommands.test.ts +++ b/src/test/suite/configuration/settings/configurationCommands.test.ts @@ -99,12 +99,12 @@ suite("configurationCommands", () => { Sinon.stub(handleLiquibaseFolder, "getLiquibaseConfigurationPath").resolves("myFolder"); Sinon.stub(ConnectionType, "suggestCreationOfConfiguration").resolves(); - assert.ok(!LiquibaseConfigurationPanel.currentPanel, "no current panel created"); + assert.ok(!LiquibaseConfigurationPanel["currentPanel"], "no current panel created"); configurationCommand .editExistingLiquibaseConfiguration(undefined, extensionContext) .then(() => { - const currentPanel = LiquibaseConfigurationPanel.currentPanel; + const currentPanel = LiquibaseConfigurationPanel["currentPanel"]; assert.ok(!currentPanel, "panel is not created"); done(); @@ -112,7 +112,7 @@ suite("configurationCommands", () => { .catch(done) .finally(() => { // dispose manually after the tests - LiquibaseConfigurationPanel.currentPanel?.dispose(); + LiquibaseConfigurationPanel["currentPanel"]?.dispose(); }); }); }); @@ -448,12 +448,12 @@ function assertEditExistingLiquibaseConfiguration( ): void { Sinon.stub(handleLiquibaseFolder, "getLiquibaseFolder").returns("myFolder"); - assert.ok(!LiquibaseConfigurationPanel.currentPanel, "no current panel created"); + assert.ok(!LiquibaseConfigurationPanel["currentPanel"], "no current panel created"); configurationCommand .editExistingLiquibaseConfiguration(uri, extensionContext) .then(() => { - const currentPanel = LiquibaseConfigurationPanel.currentPanel; + const currentPanel = LiquibaseConfigurationPanel["currentPanel"]; assert.ok(currentPanel, "panel was created"); const webviewPanel = currentPanel["_panel"]; assert.ok(webviewPanel.visible, "panel is visible"); @@ -462,7 +462,7 @@ function assertEditExistingLiquibaseConfiguration( if (uri) { LiquibaseConfigurationPanel.render(uri); - assert.ok(LiquibaseConfigurationPanel.currentPanel?.["_panel"], "panel is still visible"); + assert.ok(LiquibaseConfigurationPanel["currentPanel"]?.["_panel"], "panel is still visible"); } done(); @@ -470,7 +470,7 @@ function assertEditExistingLiquibaseConfiguration( .catch(done) .finally(() => { // dispose manually after the tests - LiquibaseConfigurationPanel.currentPanel?.dispose(); + LiquibaseConfigurationPanel["currentPanel"]?.dispose(); }); } diff --git a/src/test/suite/handleChangelogFileInput.test.ts b/src/test/suite/handleChangelogFileInput.test.ts index 41b1055..e7ef94c 100644 --- a/src/test/suite/handleChangelogFileInput.test.ts +++ b/src/test/suite/handleChangelogFileInput.test.ts @@ -118,47 +118,6 @@ suite("handleChangelogInput", () => { }); }); - /** - * Tests the method `isChangelogFromOpenDialogNeeded`. - */ - suite("isChangelogFromOpenDialogNeeded", () => { - /** - * Tests that no changelog is needed when uri is present - */ - test("should not need changelog when uri is present", () => { - const dialogValues = new DialogValues(); - dialogValues.uri = vscode.Uri.file(""); - - assert.strictEqual(HandleChangelogFileInput["isChangelogFromOpenDialogNeeded"](dialogValues), false); - }); - - [ - { - description: "the changelog should be selected", - content: CHOOSE_CHANGELOG_OPTION, - expected: true, - }, - { - description: "no changelog should be selected", - content: "foo", - expected: false, - }, - ].forEach((pArgument) => { - /** - * Tests that the desired result will be returned, when the changelog selection was or was not selected - */ - test(`should return ${pArgument.expected} when ${pArgument.description}`, () => { - const dialogValues = new DialogValues(); - dialogValues.addValue(HandleChangelogFileInput.CHANGELOG_QUICK_PICK_NAME, pArgument.content); - - assert.strictEqual( - HandleChangelogFileInput["isChangelogFromOpenDialogNeeded"](dialogValues), - pArgument.expected - ); - }); - }); - }); - /** * Tests the method `setExtraChangelogCorrectly`. */ diff --git a/src/test/suite/utilities/vscodeUtilities.test.ts b/src/test/suite/utilities/vscodeUtilities.test.ts index e467f39..2fa3fb5 100644 --- a/src/test/suite/utilities/vscodeUtilities.test.ts +++ b/src/test/suite/utilities/vscodeUtilities.test.ts @@ -114,7 +114,7 @@ suite("vscodeUtilities", () => { const errorMessage = Sinon.spy(vscode.window, "showErrorMessage"); const openExternalStub = Sinon.stub(vscode.env, "openExternal"); - openExternalStub.returns(Promise.reject(false)); + openExternalStub.returns(Promise.reject(new Error())); openLiquibaseDocumentation("foo"); diff --git a/webview-ui/src/App.tsx b/webview-ui/src/App.tsx index 0610a5b..204bb0b 100644 --- a/webview-ui/src/App.tsx +++ b/webview-ui/src/App.tsx @@ -179,8 +179,7 @@ function App(): React.JSX.Element { onClick={handleChooseChangelog} id="changelogSelection" style={{ flexShrink: 0 }}> - Choose changelog - + Choose changelog @@ -202,8 +201,7 @@ function App(): React.JSX.Element { disabled={referenceConnection} onClick={() => handleAddRemoveReferenceConnection(true)} appearance="secondary"> - Add reference connection - + Add reference connection handleAddRemoveReferenceConnection(false)} appearance="secondary"> - - Remove reference connection + Remove reference connection @@ -250,8 +247,7 @@ function App(): React.JSX.Element { - Save configuration - + Save configuration - Test configuration - + Test configuration diff --git a/webview-ui/src/components/AdditionalElements.tsx b/webview-ui/src/components/AdditionalElements.tsx index 4f44286..699fb0d 100644 --- a/webview-ui/src/components/AdditionalElements.tsx +++ b/webview-ui/src/components/AdditionalElements.tsx @@ -35,7 +35,7 @@ const valueIndicator = "value"; * @param pProperties - the properties that are needed for the additional elements * @returns the created component */ -export function AdditionalElements(pProperties: AdditionalElementProps): React.JSX.Element { +export function AdditionalElements(pProperties: Readonly): React.JSX.Element { const [additionalElementValues, setAdditionalElementValues] = useState>(new Map()); const [key, setKey] = useState(""); diff --git a/webview-ui/src/components/DatabaseConfiguration.tsx b/webview-ui/src/components/DatabaseConfiguration.tsx index df6f36b..2f72113 100644 --- a/webview-ui/src/components/DatabaseConfiguration.tsx +++ b/webview-ui/src/components/DatabaseConfiguration.tsx @@ -59,7 +59,7 @@ interface NewUrlValues extends UrlParts { * @param pProperties - the properties for creating the element * @returns the created element */ -export function DatabaseConfiguration(pProperties: DatabaseConfigurationProps): React.JSX.Element { +export function DatabaseConfiguration(pProperties: Readonly): React.JSX.Element { const [serverAddress, setServerAddress] = useState("localhost"); const [port, setPort] = useState(-1); const [databaseName, setDatabaseName] = useState("data"); diff --git a/webview-ui/src/utilities/vscodeApiWrapper.ts b/webview-ui/src/utilities/vscodeApiWrapper.ts index 4552a24..a1442ee 100644 --- a/webview-ui/src/utilities/vscodeApiWrapper.ts +++ b/webview-ui/src/utilities/vscodeApiWrapper.ts @@ -57,39 +57,39 @@ class VSCodeAPIWrapper { }); } - /** - * Get the persistent state stored for this webview. - * - * @remarks When running webview source code inside a web browser, getState will retrieve state - * from local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). - * @returns The current state or `undefined` if no state has been set. - */ - public getState(): unknown | undefined { - if (this.vsCodeApi) { - return this.vsCodeApi.getState(); - } else { - const state = localStorage.getItem("vscodeState"); - return state ? JSON.parse(state) : undefined; - } - } + // /** + // * Get the persistent state stored for this webview. + // * + // * @remarks When running webview source code inside a web browser, getState will retrieve state + // * from local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). + // * @returns The current state or `undefined` if no state has been set. + // */ + // public getState(): unknown | undefined { + // if (this.vsCodeApi) { + // return this.vsCodeApi.getState(); + // } else { + // const state = localStorage.getItem("vscodeState"); + // return state ? JSON.parse(state) : undefined; + // } + // } - /** - * Set the persistent state stored for this webview. - * - * @remarks When running webview source code inside a web browser, setState will set the given - * state using local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). - * @param newState - New persisted state. This must be a JSON serializable object. Can be retrieved - * using {@link getState}. - * @returns The new state. - */ - public setState(newState: T): T { - if (this.vsCodeApi) { - return this.vsCodeApi.setState(newState); - } else { - localStorage.setItem("vscodeState", JSON.stringify(newState)); - return newState; - } - } + // /** + // * Set the persistent state stored for this webview. + // * + // * @remarks When running webview source code inside a web browser, setState will set the given + // * state using local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). + // * @param newState - New persisted state. This must be a JSON serializable object. Can be retrieved + // * using {@link getState}. + // * @returns The new state. + // */ + // public setState(newState: T): T { + // if (this.vsCodeApi) { + // return this.vsCodeApi.setState(newState); + // } else { + // localStorage.setItem("vscodeState", JSON.stringify(newState)); + // return newState; + // } + // } } // Exports class singleton to prevent multiple invocations of acquireVsCodeApi. From df7a339c31f41bc756b3e6a96240c73fb010f669 Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Thu, 10 Oct 2024 07:31:44 +0200 Subject: [PATCH 13/22] refacotor: corrected type --- src/configuration/data/DatabaseConnection.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/configuration/data/DatabaseConnection.ts b/src/configuration/data/DatabaseConnection.ts index 9158f18..81d1448 100644 --- a/src/configuration/data/DatabaseConnection.ts +++ b/src/configuration/data/DatabaseConnection.ts @@ -89,7 +89,7 @@ export class DatabaseConnection { */ getValue(pName: keyof DatabaseConnection): string | undefined { if (typeof this[pName] === "string") { - return this[pName]; + return this[pName] as string; } } From a621f0e171550f92aa2d6d799a264c09eb6b52dc Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Thu, 10 Oct 2024 08:03:20 +0200 Subject: [PATCH 14/22] ci: trying to get coverage results --- .github/workflows/nodejs.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 01ac9f5..1c6f51d 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -71,7 +71,9 @@ jobs: if: runner.os == 'Linux' && matrix.node-version == '22.x' with: name: coverage - path: coverage/lcov.info + path: | + coverage/lcov.info + xunit.xml e2e-tests: needs: build @@ -156,7 +158,12 @@ jobs: uses: actions/download-artifact@v4 with: name: coverage - path: coverage/lcov.info + path: | + coverage/lcov.info + xunit.xml + + - name: check xunit + run: cat xunit.xml - name: exists coverage run: ls -R coverage @@ -170,3 +177,5 @@ jobs: -Dsonar.organization=aditosoftware -Dsonar.eslint.reportPaths=eslint-results.json -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info + -Dsonar.tests=src/test/suite + -Dsonar.junit.reportPaths=xunit.xml From fe1349da6d2e48893f2fe241731de8ef1c3ac2e5 Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Thu, 10 Oct 2024 08:09:48 +0200 Subject: [PATCH 15/22] test: updated max retries for docker commands --- src/test/suite/DockerTestUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/suite/DockerTestUtils.ts b/src/test/suite/DockerTestUtils.ts index a29c039..153dfd7 100644 --- a/src/test/suite/DockerTestUtils.ts +++ b/src/test/suite/DockerTestUtils.ts @@ -164,7 +164,7 @@ export class DockerTestUtils { * @returns the result of the command */ private static async repeatCommand(command: string): Promise { - const maxRetries = 10; + const maxRetries = 20; for (let i = 1; i <= maxRetries; i++) { await new Promise((r) => setTimeout(r, 500)); try { From 0912ae95b31b4cf08f18f1d991607a938dc2aaf0 Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Thu, 10 Oct 2024 08:17:13 +0200 Subject: [PATCH 16/22] ci: updates timeout for docker start --- src/test/suite/DockerTestUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/suite/DockerTestUtils.ts b/src/test/suite/DockerTestUtils.ts index 153dfd7..8f1a352 100644 --- a/src/test/suite/DockerTestUtils.ts +++ b/src/test/suite/DockerTestUtils.ts @@ -166,7 +166,7 @@ export class DockerTestUtils { private static async repeatCommand(command: string): Promise { const maxRetries = 20; for (let i = 1; i <= maxRetries; i++) { - await new Promise((r) => setTimeout(r, 500)); + await new Promise((r) => setTimeout(r, 1000)); try { const result = await this.executeCommand(command); return result; From 7f73f2ae470e22eddd9982738febebd56e24bca1 Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Thu, 10 Oct 2024 08:29:14 +0200 Subject: [PATCH 17/22] ci: trying to use sonarqube reporter --- .github/workflows/nodejs.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 1c6f51d..24a9af8 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -49,12 +49,15 @@ jobs: run: npm ci - name: Install Mocha reporters - run: npm install -d mocha-multi-reporters mocha-junit-reporter mocha-sonarqube-reporter + run: npm install -d mocha-multi-reporters mocha-junit-reporter mocha-reporter-sonarqube if: runner.os == 'Linux' && matrix.node-version == '22.x' - name: create mocha config run: | echo '{ - "reporterEnabled": "spec, mocha-junit-reporter, mocha-sonarqube-reporter" + "reporterEnabled": "spec, mocha-junit-reporter, mocha-reporter-sonarqube" + "mochaReporterSonarqubeReporterOptions": { + "filename": "report.xml" + } }' > config.json if: runner.os == 'Linux' && matrix.node-version == '22.x' @@ -73,7 +76,7 @@ jobs: name: coverage path: | coverage/lcov.info - xunit.xml + report.xml e2e-tests: needs: build @@ -160,10 +163,10 @@ jobs: name: coverage path: | coverage/lcov.info - xunit.xml + report.xml - name: check xunit - run: cat xunit.xml + run: cat report.xml - name: exists coverage run: ls -R coverage From e50bc79466ff95f7cda567b2fc1efbf07eba4e8d Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Thu, 10 Oct 2024 08:34:20 +0200 Subject: [PATCH 18/22] ci: corrected config creation --- .github/workflows/nodejs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 24a9af8..a23714a 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -54,7 +54,7 @@ jobs: - name: create mocha config run: | echo '{ - "reporterEnabled": "spec, mocha-junit-reporter, mocha-reporter-sonarqube" + "reporterEnabled": "spec, mocha-junit-reporter, mocha-reporter-sonarqube", "mochaReporterSonarqubeReporterOptions": { "filename": "report.xml" } From 998153365b52830db8ff91c4d3f785ab5dfa69b3 Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Thu, 10 Oct 2024 08:56:27 +0200 Subject: [PATCH 19/22] ci: trying to use only mocha-reporter-sonarqube --- .github/workflows/nodejs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index a23714a..8d6d3f1 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -66,7 +66,7 @@ jobs: - run: npm test if: runner.os != 'Linux' - name: Run tests with coverage - run: xvfb-run -a npm test -- --coverage --coverage-output ./coverage --coverage-reporter lcovonly --reporter mocha-multi-reporters --reporter-options configFile=config.json + run: xvfb-run -a npm test -- --coverage --coverage-output ./coverage --coverage-reporter lcovonly --reporter mocha-reporter-sonarqube --reporter-options filename=report.xml if: runner.os == 'Linux' && matrix.node-version == '22.x' - name: Upload coverage as artifact From 8c0ca3cf563d6f514e4afb839b395a1e0c9fe75b Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Thu, 10 Oct 2024 09:00:34 +0200 Subject: [PATCH 20/22] ci: check if there are reports --- .github/workflows/nodejs.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 8d6d3f1..93a8747 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -69,6 +69,10 @@ jobs: run: xvfb-run -a npm test -- --coverage --coverage-output ./coverage --coverage-reporter lcovonly --reporter mocha-reporter-sonarqube --reporter-options filename=report.xml if: runner.os == 'Linux' && matrix.node-version == '22.x' + - name: check report + run: ls | grep .xml + if: runner.os == 'Linux' && matrix.node-version == '22.x' + - name: Upload coverage as artifact uses: actions/upload-artifact@v4 if: runner.os == 'Linux' && matrix.node-version == '22.x' From 5b93ab1bb47dbd7e95d3a7b2ce0a2fe5bd89c3b4 Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Thu, 10 Oct 2024 09:04:53 +0200 Subject: [PATCH 21/22] ci: removed coverage from action --- .github/workflows/nodejs.yml | 55 ++++-------------------------------- 1 file changed, 6 insertions(+), 49 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 93a8747..43a33ce 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -48,39 +48,13 @@ jobs: - name: Run clean install run: npm ci - - name: Install Mocha reporters - run: npm install -d mocha-multi-reporters mocha-junit-reporter mocha-reporter-sonarqube - if: runner.os == 'Linux' && matrix.node-version == '22.x' - - name: create mocha config - run: | - echo '{ - "reporterEnabled": "spec, mocha-junit-reporter, mocha-reporter-sonarqube", - "mochaReporterSonarqubeReporterOptions": { - "filename": "report.xml" - } - }' > config.json - if: runner.os == 'Linux' && matrix.node-version == '22.x' - - - run: xvfb-run -a npm test - if: runner.os == 'Linux' && matrix.node-version != '22.x' - - run: npm test - if: runner.os != 'Linux' - - name: Run tests with coverage - run: xvfb-run -a npm test -- --coverage --coverage-output ./coverage --coverage-reporter lcovonly --reporter mocha-reporter-sonarqube --reporter-options filename=report.xml - if: runner.os == 'Linux' && matrix.node-version == '22.x' - - - name: check report - run: ls | grep .xml - if: runner.os == 'Linux' && matrix.node-version == '22.x' - - name: Upload coverage as artifact - uses: actions/upload-artifact@v4 - if: runner.os == 'Linux' && matrix.node-version == '22.x' - with: - name: coverage - path: | - coverage/lcov.info - report.xml + - name: Run tests on Linux + run: xvfb-run -a npm test + if: runner.os == 'Linux' + - name: Run tests on macOS and Windows + run: npm test + if: runner.os != 'Linux' e2e-tests: needs: build @@ -161,20 +135,6 @@ jobs: - name: Run ESLint run: npm run lint -- --format json --output-file eslint-results.json || true - - name: Download node_modules artifact - uses: actions/download-artifact@v4 - with: - name: coverage - path: | - coverage/lcov.info - report.xml - - - name: check xunit - run: cat report.xml - - - name: exists coverage - run: ls -R coverage - - name: Analyze with SonarCloud uses: SonarSource/sonarcloud-github-action@master env: @@ -183,6 +143,3 @@ jobs: args: -Dsonar.projectKey=aditosoftware_vscode-liquibase -Dsonar.organization=aditosoftware -Dsonar.eslint.reportPaths=eslint-results.json - -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info - -Dsonar.tests=src/test/suite - -Dsonar.junit.reportPaths=xunit.xml From 11354343c098bf561088377e3e50e509dd2533d8 Mon Sep 17 00:00:00 2001 From: Ramona Hartinger Date: Thu, 10 Oct 2024 09:41:48 +0200 Subject: [PATCH 22/22] refactor: removed not needed code --- webview-ui/src/utilities/vscodeApiWrapper.ts | 34 -------------------- 1 file changed, 34 deletions(-) diff --git a/webview-ui/src/utilities/vscodeApiWrapper.ts b/webview-ui/src/utilities/vscodeApiWrapper.ts index a1442ee..6950665 100644 --- a/webview-ui/src/utilities/vscodeApiWrapper.ts +++ b/webview-ui/src/utilities/vscodeApiWrapper.ts @@ -56,40 +56,6 @@ class VSCodeAPIWrapper { } }); } - - // /** - // * Get the persistent state stored for this webview. - // * - // * @remarks When running webview source code inside a web browser, getState will retrieve state - // * from local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). - // * @returns The current state or `undefined` if no state has been set. - // */ - // public getState(): unknown | undefined { - // if (this.vsCodeApi) { - // return this.vsCodeApi.getState(); - // } else { - // const state = localStorage.getItem("vscodeState"); - // return state ? JSON.parse(state) : undefined; - // } - // } - - // /** - // * Set the persistent state stored for this webview. - // * - // * @remarks When running webview source code inside a web browser, setState will set the given - // * state using local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). - // * @param newState - New persisted state. This must be a JSON serializable object. Can be retrieved - // * using {@link getState}. - // * @returns The new state. - // */ - // public setState(newState: T): T { - // if (this.vsCodeApi) { - // return this.vsCodeApi.setState(newState); - // } else { - // localStorage.setItem("vscodeState", JSON.stringify(newState)); - // return newState; - // } - // } } // Exports class singleton to prevent multiple invocations of acquireVsCodeApi.