From 1cc7ec984b466f0747776983ab420196e5020c6a Mon Sep 17 00:00:00 2001 From: Anton Ovechkin Date: Wed, 15 Jan 2025 09:22:09 +0100 Subject: [PATCH] Backport #60 (#62) --- .github/actions/changeset-status/action.yml | 26 ++-- .github/workflows/checks.yml | 38 +++--- .vscode/settings.json | 1 + package.json | 3 +- pkg/observability/package.json | 1 + ...ension-routing.js => extension-routing.ts} | 0 tsconfig.json | 42 ------ yarn.lock | 123 ++++++++++-------- 8 files changed, 111 insertions(+), 123 deletions(-) rename pkg/observability/routing/{extension-routing.js => extension-routing.ts} (100%) delete mode 100644 tsconfig.json diff --git a/.github/actions/changeset-status/action.yml b/.github/actions/changeset-status/action.yml index e920dad4..2920e5c4 100644 --- a/.github/actions/changeset-status/action.yml +++ b/.github/actions/changeset-status/action.yml @@ -37,16 +37,22 @@ runs: fi echo "✅ Temporary file created at: $OUTPUT" - # Run the changeset status command with relative path output - yarn changeset status ${{ inputs.args }} --output $(realpath --relative-to . "$OUTPUT") + RELATED_OUTPUT=$(realpath --relative-to . "$OUTPUT") - if [ ! -s "$OUTPUT" ]; then - echo "🚨 Error: Temporary file is empty after running 'yarn changeset status'" - exit 1 - fi + # Run the changeset status command with relative path output + # and catch an error if the command fails + { # try + CAUGHT_OUTPUT=$(yarn changeset status ${{ inputs.args }} --output $RELATED_OUTPUT 2>&1) + } || { # catch + # If the error is NOT caused by empty changesets, print the error and exit + if ! echo "$CAUGHT_OUTPUT" | grep -q "Some packages have been changed but no changesets were found"; then + echo "$CAUGHT_OUTPUT" >&2 + exit 1 + fi + } - # if the .releases length is greater than 0, then the changeset is ready to be released - if jq -e '.releases | length > 0' "$OUTPUT" > /dev/null; then + # if the output is not empty and the .releases length is greater than 0, then the changeset is ready to be released + if [ -s "$OUTPUT" ] && jq -e '.releases | length > 0' "$OUTPUT" > /dev/null; then NAME=$(jq -r '.releases[0].name' "$OUTPUT") TYPE=$(jq -r '.releases[0].type' "$OUTPUT") OLD_VERSION=$(jq -r '.releases[0].oldVersion' "$OUTPUT") @@ -56,6 +62,10 @@ runs: echo "type=$TYPE" >> $GITHUB_OUTPUT echo "old_version=$OLD_VERSION" >> $GITHUB_OUTPUT echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT + + # print the github output + echo "📦 Changeset found:" + cat $GITHUB_OUTPUT else echo "⏩ No changeset found" fi diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 0433acc3..45aba102 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -65,24 +65,11 @@ jobs: echo "✅ Detected '$VERSION_TYPE' bump." - - name: Detect File Changes - id: changed-files - uses: tj-actions/changed-files@v41 - with: - files_yaml: | - eslint_config: - - .eslintrc.js - - yarn.lock - eslint_target: - - '**/*.{ts,js,vue}' - - - name: Lint all files - if: ${{ github.event_name == 'push' || steps.changed-files.outputs.eslint_config_any_changed == 'true' }} - run: yarn lint . + - name: Run typecheck + run: yarn typecheck - - name: Lint changed files - if: ${{ steps.lint-all.outcome == 'skipped' && steps.changed-files.outputs.eslint_target_any_changed == 'true' }} - run: yarn lint ${{ steps.changed-files.outputs.eslint_target_all_changed_files }} --no-error-on-unmatched-pattern + - name: Run lint + run: yarn lint . - name: Build Observability Package run: yarn build-pkg observability @@ -108,6 +95,19 @@ jobs: id: changeset-status uses: ./.github/actions/changeset-status + - name: Check if Version Already Exists + if: steps.changeset-status.outputs.new_version + run: | + NAME="${{ steps.changeset-status.outputs.name }}" + NEW_VERSION="${{ steps.changeset-status.outputs.new_version }}" + + # Check that a tag for the new version does not already exist + if [[ ! -z $(git tag -l "$NAME@$NEW_VERSION") ]]; then + echo "🚨 The version '$NAME@$NEW_VERSION' already exists." + echo "🚨 Please ensure that the version bump and the base branch is correct." + exit 1 + fi + # creates a PR if there are changesets or assign the new tag if the PR is merged - name: Create Release Pull Request or Publish id: changesets @@ -144,7 +144,7 @@ jobs: - name: Upload Charts Artifact if: steps.prepare-artifact.conclusion == 'success' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: charts path: tmp @@ -174,7 +174,7 @@ jobs: version: v3.8.0 - name: Download Build Artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: charts diff --git a/.vscode/settings.json b/.vscode/settings.json index 89262356..fe2633f4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -39,4 +39,5 @@ "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.tabSize": 2 }, + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/package.json b/package.json index 53ec8d29..0c24ecfe 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "lint": "eslint --ext .ts,.js,.vue", "dev": "NODE_ENV=dev vue-cli-service serve", "build": "vue-cli-service build", + "typecheck": "yarn workspaces run typecheck", "clean": "./node_modules/@rancher/shell/scripts/clean", "build-pkg": "./node_modules/@rancher/shell/scripts/build-pkg.sh", "serve-pkgs": "./node_modules/@rancher/shell/scripts/serve-pkgs", @@ -31,6 +32,6 @@ "release-tag": "changeset tag && ./scripts/duplicate-release-tags.sh" }, "devDependencies": { - "@changesets/cli": "^2.27.9" + "@changesets/cli": "^2.27.11" } } diff --git a/pkg/observability/package.json b/pkg/observability/package.json index b4549def..50769229 100644 --- a/pkg/observability/package.json +++ b/pkg/observability/package.json @@ -14,6 +14,7 @@ }, "icon": "https://raw.githubusercontent.com/stackvista/rancher-extension-stackstate/main/pkg/observability/rancher-observability.svg", "scripts": { + "typecheck": "tsc --noEmit --skipLibCheck", "dev": "./node_modules/.bin/nuxt dev", "nuxt": "./node_modules/.bin/nuxt" }, diff --git a/pkg/observability/routing/extension-routing.js b/pkg/observability/routing/extension-routing.ts similarity index 100% rename from pkg/observability/routing/extension-routing.js rename to pkg/observability/routing/extension-routing.ts diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 53414eda..00000000 --- a/tsconfig.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2018", - "module": "ESNext", - "moduleResolution": "Node", - "lib": [ - "ESNext", - "ESNext.AsyncIterable", - "DOM" - ], - "esModuleInterop": true, - "allowJs": true, - "sourceMap": true, - "strict": true, - "noEmit": true, - "baseUrl": ".", - "paths": { - "~/*": [ - "./*" - ], - "@/*": [ - "./*" - ], - "@shell/*": [ - "./node_modules/@rancher/shell/*" - ] - }, - "typeRoots": [ - "./node_modules", - "./node_modules/@rancher/shell/types" - ], - "types": [ - "@types/node", - "cypress", - "rancher", - "shell" - ] - }, - "exclude": [ - "node_modules" - ] -} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index d535e1cc..dc670921 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2614,14 +2614,14 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@changesets/apply-release-plan@^7.0.5": - version "7.0.5" - resolved "https://registry.yarnpkg.com/@changesets/apply-release-plan/-/apply-release-plan-7.0.5.tgz#3323c97afc08abc15e5136488f9c7cf1a864832e" - integrity sha512-1cWCk+ZshEkSVEZrm2fSj1Gz8sYvxgUL4Q78+1ZZqeqfuevPTPk033/yUZ3df8BKMohkqqHfzj0HOOrG0KtXTw== +"@changesets/apply-release-plan@^7.0.7": + version "7.0.7" + resolved "https://registry.yarnpkg.com/@changesets/apply-release-plan/-/apply-release-plan-7.0.7.tgz#cabeaed77de07c6bd9878a9bc5ffd3ea7db7f7ff" + integrity sha512-qnPOcmmmnD0MfMg9DjU1/onORFyRpDXkMMl2IJg9mECY6RnxL3wN0TCCc92b2sXt1jt8DgjAUUsZYGUGTdYIXA== dependencies: - "@changesets/config" "^3.0.3" + "@changesets/config" "^3.0.5" "@changesets/get-version-range-type" "^0.4.0" - "@changesets/git" "^3.0.1" + "@changesets/git" "^3.0.2" "@changesets/should-skip-package" "^0.1.1" "@changesets/types" "^6.0.0" "@manypkg/get-packages" "^1.1.3" @@ -2633,10 +2633,10 @@ resolve-from "^5.0.0" semver "^7.5.3" -"@changesets/assemble-release-plan@^6.0.4": - version "6.0.4" - resolved "https://registry.yarnpkg.com/@changesets/assemble-release-plan/-/assemble-release-plan-6.0.4.tgz#153d5154bb9f4162215ca69ad1c6e0886f686ccb" - integrity sha512-nqICnvmrwWj4w2x0fOhVj2QEGdlUuwVAwESrUo5HLzWMI1rE5SWfsr9ln+rDqWB6RQ2ZyaMZHUcU7/IRaUJS+Q== +"@changesets/assemble-release-plan@^6.0.5": + version "6.0.5" + resolved "https://registry.yarnpkg.com/@changesets/assemble-release-plan/-/assemble-release-plan-6.0.5.tgz#d987b01c2d91c8b2f81eedd2df56ba355e4ce536" + integrity sha512-IgvBWLNKZd6k4t72MBTBK3nkygi0j3t3zdC1zrfusYo0KpdsvnDjrMM9vPnTCLCMlfNs55jRL4gIMybxa64FCQ== dependencies: "@changesets/errors" "^0.2.0" "@changesets/get-dependents-graph" "^2.1.2" @@ -2652,29 +2652,29 @@ dependencies: "@changesets/types" "^6.0.0" -"@changesets/cli@^2.27.9": - version "2.27.9" - resolved "https://registry.yarnpkg.com/@changesets/cli/-/cli-2.27.9.tgz#7b58a4c9eaf95d81fe0d1386705ecefe94a20062" - integrity sha512-q42a/ZbDnxPpCb5Wkm6tMVIxgeI9C/bexntzTeCFBrQEdpisQqk8kCHllYZMDjYtEc1ZzumbMJAG8H0Z4rdvjg== +"@changesets/cli@^2.27.11": + version "2.27.11" + resolved "https://registry.yarnpkg.com/@changesets/cli/-/cli-2.27.11.tgz#1d510044b350a7c78a8b55a0591637d7ad224469" + integrity sha512-1QislpE+nvJgSZZo9+Lj3Lno5pKBgN46dAV8IVxKJy9wX8AOrs9nn5pYVZuDpoxWJJCALmbfOsHkyxujgetQSg== dependencies: - "@changesets/apply-release-plan" "^7.0.5" - "@changesets/assemble-release-plan" "^6.0.4" + "@changesets/apply-release-plan" "^7.0.7" + "@changesets/assemble-release-plan" "^6.0.5" "@changesets/changelog-git" "^0.2.0" - "@changesets/config" "^3.0.3" + "@changesets/config" "^3.0.5" "@changesets/errors" "^0.2.0" "@changesets/get-dependents-graph" "^2.1.2" - "@changesets/get-release-plan" "^4.0.4" - "@changesets/git" "^3.0.1" + "@changesets/get-release-plan" "^4.0.6" + "@changesets/git" "^3.0.2" "@changesets/logger" "^0.1.1" "@changesets/pre" "^2.0.1" - "@changesets/read" "^0.6.1" + "@changesets/read" "^0.6.2" "@changesets/should-skip-package" "^0.1.1" "@changesets/types" "^6.0.0" "@changesets/write" "^0.3.2" "@manypkg/get-packages" "^1.1.3" ansi-colors "^4.1.3" ci-info "^3.7.0" - enquirer "^2.3.0" + enquirer "^2.4.1" external-editor "^3.1.0" fs-extra "^7.0.1" mri "^1.2.0" @@ -2683,13 +2683,13 @@ picocolors "^1.1.0" resolve-from "^5.0.0" semver "^7.5.3" - spawndamnit "^2.0.0" + spawndamnit "^3.0.1" term-size "^2.1.0" -"@changesets/config@^3.0.3": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@changesets/config/-/config-3.0.3.tgz#19196558882b25c8aaf04941d4ac7e151f5a1b36" - integrity sha512-vqgQZMyIcuIpw9nqFIpTSNyc/wgm/Lu1zKN5vECy74u95Qx/Wa9g27HdgO4NkVAaq+BGA8wUc/qvbvVNs93n6A== +"@changesets/config@^3.0.5": + version "3.0.5" + resolved "https://registry.yarnpkg.com/@changesets/config/-/config-3.0.5.tgz#cb59e9f338a4b35d3266af8a32799cb940d54ee0" + integrity sha512-QyXLSSd10GquX7hY0Mt4yQFMEeqnO5z/XLpbIr4PAkNNoQNKwDyiSrx4yd749WddusH1v3OSiA0NRAYmH/APpQ== dependencies: "@changesets/errors" "^0.2.0" "@changesets/get-dependents-graph" "^2.1.2" @@ -2697,7 +2697,7 @@ "@changesets/types" "^6.0.0" "@manypkg/get-packages" "^1.1.3" fs-extra "^7.0.1" - micromatch "^4.0.2" + micromatch "^4.0.8" "@changesets/errors@^0.2.0": version "0.2.0" @@ -2716,15 +2716,15 @@ picocolors "^1.1.0" semver "^7.5.3" -"@changesets/get-release-plan@^4.0.4": - version "4.0.4" - resolved "https://registry.yarnpkg.com/@changesets/get-release-plan/-/get-release-plan-4.0.4.tgz#e7ef0d84d9079c69febb64f8018a18ac4b77ac90" - integrity sha512-SicG/S67JmPTrdcc9Vpu0wSQt7IiuN0dc8iR5VScnnTVPfIaLvKmEGRvIaF0kcn8u5ZqLbormZNTO77bCEvyWw== +"@changesets/get-release-plan@^4.0.6": + version "4.0.6" + resolved "https://registry.yarnpkg.com/@changesets/get-release-plan/-/get-release-plan-4.0.6.tgz#40d70c2524be51a70b7e1a778826854bb6c8562a" + integrity sha512-FHRwBkY7Eili04Y5YMOZb0ezQzKikTka4wL753vfUA5COSebt7KThqiuCN9BewE4/qFGgF/5t3AuzXx1/UAY4w== dependencies: - "@changesets/assemble-release-plan" "^6.0.4" - "@changesets/config" "^3.0.3" + "@changesets/assemble-release-plan" "^6.0.5" + "@changesets/config" "^3.0.5" "@changesets/pre" "^2.0.1" - "@changesets/read" "^0.6.1" + "@changesets/read" "^0.6.2" "@changesets/types" "^6.0.0" "@manypkg/get-packages" "^1.1.3" @@ -2733,16 +2733,16 @@ resolved "https://registry.yarnpkg.com/@changesets/get-version-range-type/-/get-version-range-type-0.4.0.tgz#429a90410eefef4368502c41c63413e291740bf5" integrity sha512-hwawtob9DryoGTpixy1D3ZXbGgJu1Rhr+ySH2PvTLHvkZuQ7sRT4oQwMh0hbqZH1weAooedEjRsbrWcGLCeyVQ== -"@changesets/git@^3.0.1": - version "3.0.1" - resolved "https://registry.yarnpkg.com/@changesets/git/-/git-3.0.1.tgz#4499a07d35d8e783cd56f8295fb7d4d70282701b" - integrity sha512-pdgHcYBLCPcLd82aRcuO0kxCDbw/yISlOtkmwmE8Odo1L6hSiZrBOsRl84eYG7DRCab/iHnOkWqExqc4wxk2LQ== +"@changesets/git@^3.0.2": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@changesets/git/-/git-3.0.2.tgz#669c700049dc3b8ba53f46de45f5c4b1e6ddea3b" + integrity sha512-r1/Kju9Y8OxRRdvna+nxpQIsMsRQn9dhhAZt94FLDeu0Hij2hnOozW8iqnHBgvu+KdnJppCveQwK4odwfw/aWQ== dependencies: "@changesets/errors" "^0.2.0" "@manypkg/get-packages" "^1.1.3" is-subdir "^1.1.1" - micromatch "^4.0.2" - spawndamnit "^2.0.0" + micromatch "^4.0.8" + spawndamnit "^3.0.1" "@changesets/logger@^0.1.1": version "0.1.1" @@ -2769,12 +2769,12 @@ "@manypkg/get-packages" "^1.1.3" fs-extra "^7.0.1" -"@changesets/read@^0.6.1": - version "0.6.1" - resolved "https://registry.yarnpkg.com/@changesets/read/-/read-0.6.1.tgz#32c91d97e602861717696c49a09c23eb492810f6" - integrity sha512-jYMbyXQk3nwP25nRzQQGa1nKLY0KfoOV7VLgwucI0bUO8t8ZLCr6LZmgjXsiKuRDc+5A6doKPr9w2d+FEJ55zQ== +"@changesets/read@^0.6.2": + version "0.6.2" + resolved "https://registry.yarnpkg.com/@changesets/read/-/read-0.6.2.tgz#816cf75dd22a70e75ac279474e44be52fb3fb91b" + integrity sha512-wjfQpJvryY3zD61p8jR87mJdyx2FIhEcdXhKUqkja87toMrP/3jtg/Yg29upN+N4Ckf525/uvV7a4tzBlpk6gg== dependencies: - "@changesets/git" "^3.0.1" + "@changesets/git" "^3.0.2" "@changesets/logger" "^0.1.1" "@changesets/parse" "^0.4.0" "@changesets/types" "^6.0.0" @@ -6949,7 +6949,7 @@ cross-env@6.0.3: dependencies: cross-spawn "^7.0.0" -cross-spawn@^5.0.1, cross-spawn@^5.1.0: +cross-spawn@^5.0.1: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" integrity sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A== @@ -6978,6 +6978,15 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: shebang-command "^2.0.0" which "^2.0.1" +cross-spawn@^7.0.5: + version "7.0.6" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f" + integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + crypto-browserify@^3.11.0: version "3.12.0" resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" @@ -8496,7 +8505,7 @@ enhanced-resolve@^4.0.0, enhanced-resolve@^4.1.1, enhanced-resolve@^4.5.0: memory-fs "^0.5.0" tapable "^1.0.0" -enquirer@^2.3.0, enquirer@^2.3.5, enquirer@^2.3.6: +enquirer@^2.3.5, enquirer@^2.3.6, enquirer@^2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.4.1.tgz#93334b3fbd74fc7097b224ab4a8fb7e40bf4ae56" integrity sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ== @@ -12722,6 +12731,14 @@ micromatch@^4.0.0, micromatch@^4.0.2, micromatch@^4.0.4: braces "^3.0.3" picomatch "^2.3.1" +micromatch@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202" + integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA== + dependencies: + braces "^3.0.3" + picomatch "^2.3.1" + miller-rabin@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" @@ -16095,13 +16112,13 @@ spawn-wrap@^2.0.0: signal-exit "^3.0.2" which "^2.0.1" -spawndamnit@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/spawndamnit/-/spawndamnit-2.0.0.tgz#9f762ac5c3476abb994b42ad592b5ad22bb4b0ad" - integrity sha512-j4JKEcncSjFlqIwU5L/rp2N5SIPsdxaRsIv678+TZxZ0SRDJTm8JrxJMjE/XuiEZNEir3S8l0Fa3Ke339WI4qA== +spawndamnit@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/spawndamnit/-/spawndamnit-3.0.1.tgz#44410235d3dc4e21f8e4f740ae3266e4486c2aed" + integrity sha512-MmnduQUuHCoFckZoWnXsTg7JaiLBJrKFj9UI2MbRPGaJeVpsLcVBu6P/IGZovziM/YBsellCmsprgNA+w0CzVg== dependencies: - cross-spawn "^5.1.0" - signal-exit "^3.0.2" + cross-spawn "^7.0.5" + signal-exit "^4.0.1" spdx-correct@^3.0.0: version "3.2.0"