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

[DO NOT MERGE] Initial check-in for supporting telemetry in vscode #6123

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
7 changes: 7 additions & 0 deletions .chronus/changes/vscode-telemetry-2025-1-24-22-51-43.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- typespec-vscode
---

Support telemetry
88 changes: 46 additions & 42 deletions eng/tsp-core/pipelines/jobs/build-for-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ jobs:
parameters:
useDotNet: true

- script: pnpm run update-telemetry-key $(vscode.telemetryKey)
workingDirectory: $(Build.SourcesDirectory)/packages/typespec-vscode
displayName: Update vscode telemetry key

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timotheeguerin , I need to update the telemetry-key to the PROD one when publishing vscode extension. Do you know how I can add the PROD key into the $(vscode-telemetry-key) varaible? And how can I test whether the updated pipeline works without actually doing a publish? thanks.

Copy link
Member

@timotheeguerin timotheeguerin Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the key need to be private? our others don't as they can't be kept private anyway(and I assume this one neither)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it doesn't need to be private.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d say I would include them both right there then and just decide with a .env which one should be used.

Copy link
Contributor Author

@RodgeFu RodgeFu Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked with guys from AzureApiCenter vscode extension team. Although it's not sensitive and will be in the released package.json eventually, but they still store the key as secret var in pipeline instead of plain text in github (https://github.com/microsoft/vscode-azureapicenter/blob/dev/.github/workflows/cd.yml#L39-L44). I'm also more comfortable not to store PROD "key" as plain text in github and prefer to follow what they are doing.
I gave it a try and was able to add a secret to the "typespec -Publish" pipeline for the key successfully (https://dev.azure.com/azure-sdk/internal/_apps/hub/ms.vss-build-web.ci-designer-hub?pipelineId=3226&nonce=wqPmyYzOeUiSS5fefsbaeA%3D%3D&branch=main). Do you know how I can test the change without actually publish something? Do I have to comment the publish part, test and then uncomment...? thx

- template: /eng/tsp-core/pipelines/templates/build.yml

- script: pnpm run test:ci
displayName: Test

- template: /eng/tsp-core/pipelines/templates/upload-coverage.yml
# - template: /eng/tsp-core/pipelines/templates/upload-coverage.yml

- script: pnpm chronus pack --exclude standalone --pack-destination $(Build.ArtifactStagingDirectory)/npm-packages-stable
displayName: Pack packages
# - script: pnpm chronus pack --exclude standalone --pack-destination $(Build.ArtifactStagingDirectory)/npm-packages-stable
# displayName: Pack packages

- task: CopyFiles@2
displayName: "Copy VSCode extension .vsix to artifact directory"
Expand All @@ -27,45 +31,45 @@ jobs:
Contents: "*.vsix"
TargetFolder: "$(Build.ArtifactStagingDirectory)/vscode-extension"

- task: CopyFiles@2
displayName: "Copy VS extension .vsix to artifact directory"
inputs:
SourceFolder: "$(Build.SourcesDirectory)/packages/typespec-vs"
Contents: "*.vsix"
TargetFolder: "$(Build.ArtifactStagingDirectory)/vs-extension"

- task: AzureCLI@1
displayName: "Publish bundled packages to package storage"
inputs:
azureSubscription: "Azure SDK Engineering System"
scriptLocation: inlineScript
inlineScript: node ./eng/tsp-core/scripts/upload-bundler-packages.js

# Update version for next version publish
- script: node ./packages/internal-build-utils/cmd/cli.js bump-version-preview .
displayName: Bump version to prerelease targets

- script: npm run gen-manifest
displayName: Regen manifest for compiler
workingDirectory: ./packages/compiler

- script: pnpm chronus pack --exclude standalone --pack-destination $(Build.ArtifactStagingDirectory)/npm-packages-next
displayName: Pack next packages

# Publish Next playground
- task: AzureCLI@1
displayName: "Publish playground"
inputs:
azureSubscription: "Azure SDK Engineering System"
scriptLocation: inlineScript
inlineScript: |
az storage blob upload-batch ^
--auth-mode login ^
--destination $web ^
--account-name "cadlplayground" ^
--destination-path / ^
--source "./packages/playground-website/dist/web/" ^
--overwrite
# - task: CopyFiles@2
# displayName: "Copy VS extension .vsix to artifact directory"
# inputs:
# SourceFolder: "$(Build.SourcesDirectory)/packages/typespec-vs"
# Contents: "*.vsix"
# TargetFolder: "$(Build.ArtifactStagingDirectory)/vs-extension"

# - task: AzureCLI@1
# displayName: "Publish bundled packages to package storage"
# inputs:
# azureSubscription: "Azure SDK Engineering System"
# scriptLocation: inlineScript
# inlineScript: node ./eng/tsp-core/scripts/upload-bundler-packages.js

# # Update version for next version publish
# - script: node ./packages/internal-build-utils/cmd/cli.js bump-version-preview .
# displayName: Bump version to prerelease targets

# - script: npm run gen-manifest
# displayName: Regen manifest for compiler
# workingDirectory: ./packages/compiler

# - script: pnpm chronus pack --exclude standalone --pack-destination $(Build.ArtifactStagingDirectory)/npm-packages-next
# displayName: Pack next packages

# # Publish Next playground
# - task: AzureCLI@1
# displayName: "Publish playground"
# inputs:
# azureSubscription: "Azure SDK Engineering System"
# scriptLocation: inlineScript
# inlineScript: |
# az storage blob upload-batch ^
# --auth-mode login ^
# --destination $web ^
# --account-name "cadlplayground" ^
# --destination-path / ^
# --source "./packages/playground-website/dist/web/" ^
# --overwrite

templateContext:
outputs:
Expand Down
174 changes: 87 additions & 87 deletions eng/tsp-core/pipelines/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,90 +30,90 @@ extends:

jobs:
- template: /eng/tsp-core/pipelines/jobs/build-for-publish.yml@self
- template: /eng/tsp-core/pipelines/jobs/cli/build-tsp-cli-all.yml@self

- stage: publish_npm
displayName: Publish Npm Packages
dependsOn: build

pool:
name: $(LINUXPOOL)
image: $(LINUXVMIMAGE)
os: linux

jobs:
- template: /eng/tsp-core/pipelines/jobs/publish-npm.yml
parameters:
artifactName: npm-packages-stable
tag: latest
publishGithubRelease: true

- template: /eng/tsp-core/pipelines/jobs/publish-npm.yml
parameters:
artifactName: npm-packages-next
tag: next

- stage: publish_vscode
displayName: Publish VSCode extension
dependsOn: build
jobs:
- template: /eng/tsp-core/pipelines/jobs/publish-vscode.yml

- stage: publish_vs
displayName: Publish VS extension
dependsOn: build
jobs:
- template: /eng/tsp-core/pipelines/jobs/publish-vs.yml

- template: /eng/tsp-core/pipelines/stages/sign-publish-tsp-cli.yml@self

- stage: docker
displayName: Docker
dependsOn: []
jobs:
- job: docker
displayName: Build and publish
variables:
imageName: "azsdkengsys.azurecr.io/typespec"
pool:
name: $(LINUXPOOL)
image: $(LINUXVMIMAGE)
os: linux
steps:
- task: Docker@1
displayName: login
inputs:
azureSubscriptionEndpoint: "AzureSDKEngKeyVault Secrets"
azureContainerRegistry: azsdkengsys.azurecr.io
command: login

- script: |
docker build -f ./docker/Dockerfile \
-t $(imageName):latest \
-t $(imageName):alpine \
.
displayName: "Build"
- script: docker push $(imageName) --all-tags
displayName: "Push"

- stage: validate_manifest
displayName: Validate Manifest
dependsOn: build
jobs:
- job: validate_manifest
displayName: Validate Manifest
pool:
name: $(WINDOWSPOOL)
image: $(WINDOWSVMIMAGE)
os: windows
variables:
TYPESPEC_SKIP_DOCUSAURUS_BUILD: true # Disable docusaurus build
steps:
- template: /eng/tsp-core/pipelines/templates/install.yml
- template: /eng/tsp-core/pipelines/templates/build.yml

- script: pnpm run validate-scenarios --debug
displayName: Validate Scenarios

- script: pnpm run validate-mock-apis --debug
displayName: Validate mock apis
# - template: /eng/tsp-core/pipelines/jobs/cli/build-tsp-cli-all.yml@self

# - stage: publish_npm
# displayName: Publish Npm Packages
# dependsOn: build

# pool:
# name: $(LINUXPOOL)
# image: $(LINUXVMIMAGE)
# os: linux

# jobs:
# - template: /eng/tsp-core/pipelines/jobs/publish-npm.yml
# parameters:
# artifactName: npm-packages-stable
# tag: latest
# publishGithubRelease: true

# - template: /eng/tsp-core/pipelines/jobs/publish-npm.yml
# parameters:
# artifactName: npm-packages-next
# tag: next

# - stage: publish_vscode
# displayName: Publish VSCode extension
# dependsOn: build
# jobs:
# - template: /eng/tsp-core/pipelines/jobs/publish-vscode.yml

# - stage: publish_vs
# displayName: Publish VS extension
# dependsOn: build
# jobs:
# - template: /eng/tsp-core/pipelines/jobs/publish-vs.yml

# - template: /eng/tsp-core/pipelines/stages/sign-publish-tsp-cli.yml@self

# - stage: docker
# displayName: Docker
# dependsOn: []
# jobs:
# - job: docker
# displayName: Build and publish
# variables:
# imageName: "azsdkengsys.azurecr.io/typespec"
# pool:
# name: $(LINUXPOOL)
# image: $(LINUXVMIMAGE)
# os: linux
# steps:
# - task: Docker@1
# displayName: login
# inputs:
# azureSubscriptionEndpoint: "AzureSDKEngKeyVault Secrets"
# azureContainerRegistry: azsdkengsys.azurecr.io
# command: login

# - script: |
# docker build -f ./docker/Dockerfile \
# -t $(imageName):latest \
# -t $(imageName):alpine \
# .
# displayName: "Build"
# - script: docker push $(imageName) --all-tags
# displayName: "Push"

# - stage: validate_manifest
# displayName: Validate Manifest
# dependsOn: build
# jobs:
# - job: validate_manifest
# displayName: Validate Manifest
# pool:
# name: $(WINDOWSPOOL)
# image: $(WINDOWSVMIMAGE)
# os: windows
# variables:
# TYPESPEC_SKIP_DOCUSAURUS_BUILD: true # Disable docusaurus build
# steps:
# - template: /eng/tsp-core/pipelines/templates/install.yml
# - template: /eng/tsp-core/pipelines/templates/build.yml

# - script: pnpm run validate-scenarios --debug
# displayName: Validate Scenarios

# - script: pnpm run validate-mock-apis --debug
# displayName: Validate mock apis
68 changes: 63 additions & 5 deletions packages/typespec-vscode/ThirdPartyNotices.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,69 @@ original copyright notices and the licenses under which Microsoft received such
components are set forth below. Microsoft reserves all rights not expressly
granted herein, whether by implication, estoppel or otherwise.

1. balanced-match version 1.0.2 (https://github.com/juliangruber/balanced-match)
2. brace-expansion version 2.0.1 (https://github.com/juliangruber/brace-expansion)
3. minimatch version 5.1.6 (https://github.com/isaacs/minimatch)
4. semver version 7.6.3 (https://github.com/npm/node-semver)
5. yaml version 2.7.0 (github:eemeli/yaml)
1. @nevware21/ts-async version 0.5.4 (https://github.com/nevware21/ts-async)
2. @nevware21/ts-utils version 0.11.6 (https://github.com/nevware21/ts-utils)
3. balanced-match version 1.0.2 (https://github.com/juliangruber/balanced-match)
4. brace-expansion version 2.0.1 (https://github.com/juliangruber/brace-expansion)
5. minimatch version 5.1.6 (https://github.com/isaacs/minimatch)
6. semver version 7.6.3 (https://github.com/npm/node-semver)
7. yaml version 2.7.0 (github:eemeli/yaml)


%% @nevware21/ts-async NOTICES AND INFORMATION BEGIN HERE
=====================================================
MIT License

Copyright (c) 2022 NevWare21 Solutions LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

=====================================================");
END OF @nevware21/ts-async NOTICES AND INFORMATION


%% @nevware21/ts-utils NOTICES AND INFORMATION BEGIN HERE
=====================================================
MIT License

Copyright (c) 2022 NevWare21 Solutions LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

=====================================================");
END OF @nevware21/ts-utils NOTICES AND INFORMATION


%% balanced-match NOTICES AND INFORMATION BEGIN HERE
Expand Down
Loading
Loading