Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/azure-pipelines/product-copilot.yml
13379 views
1
jobs:
2
- job: Copilot
3
displayName: Copilot
4
timeoutInMinutes: 60
5
variables:
6
- name: skipComponentGovernanceDetection
7
value: true
8
- name: Codeql.SkipTaskAutoInjection
9
value: true
10
templateContext:
11
outputParentDirectory: $(Build.ArtifactStagingDirectory)
12
outputs:
13
- output: pipelineArtifact
14
targetPath: $(Build.ArtifactStagingDirectory)/copilot-vsix
15
artifactName: copilot_vsix
16
displayName: Publish Copilot VSIX
17
sbomEnabled: false
18
steps:
19
- checkout: self
20
lfs: true
21
fetchDepth: 1
22
fetchTags: false
23
displayName: Checkout microsoft/vscode
24
25
- template: copilot/setup-steps.yml
26
- template: copilot/test-steps.yml
27
parameters:
28
runIntegrationTests: false
29
- template: copilot/build-steps.yml
30
- template: copilot/l10n-steps.yml
31
32
- task: notice@0
33
inputs:
34
outputfile: $(Build.SourcesDirectory)/extensions/copilot/ThirdPartyNotices.txt
35
outputformat: text
36
continueOnError: true
37
retryCountOnTaskFailure: 5
38
displayName: Generate NOTICE file
39
40
- script: |
41
set -e
42
node << 'EOF'
43
const pkg = require("./package.json");
44
const EVENT_PREFIX = pkg.publisher + "." + pkg.name;
45
const cp = require("child_process");
46
const output = cp.spawnSync("npx", ["@vscode/telemetry-extractor", "--eventPrefix", EVENT_PREFIX, "-s", ".", "-o", ".", "-f", "telemetry"], { env: process.env, cwd: process.cwd(), shell: true });
47
if (output.error) {
48
console.log("stderr", (output.stderr || "").toString());
49
console.log("stdout", (output.stdout || "").toString());
50
throw output.error;
51
}
52
EOF
53
workingDirectory: $(Build.SourcesDirectory)/extensions/copilot
54
displayName: Extract telemetry
55
env:
56
npm_config_yes: "true"
57
58
- script: |
59
set -e
60
if [ ! -f node_modules/jsonc-parser/package.json ]; then
61
npm install --location=global jsonc-parser
62
export NODE_PATH=$(npm root --location=global)
63
fi
64
find . -name "*.json" -type f -print0 | while IFS= read -r -d '' file; do
65
if [[ $file == *"node_modules"* ]]; then
66
continue
67
fi
68
echo "Minifying $file"
69
node -e "console.log(JSON.stringify(require('jsonc-parser').parse(require('fs').readFileSync('$file', 'utf8')), null, 0));" > "$file.min"
70
if [ ! -s "$file.min" ]; then
71
echo "Minification failed for $file"
72
rm "$file.min"
73
continue
74
fi
75
rm "$file"
76
mv "$file.min" "$file"
77
done
78
workingDirectory: $(Build.SourcesDirectory)/extensions/copilot
79
displayName: Minify JSON files
80
81
- script: |
82
set -e
83
npx vsce package -o copilot-chat.vsix --allow-package-secrets sendgrid
84
mkdir -p $(Build.ArtifactStagingDirectory)/copilot-vsix
85
cp copilot-chat.vsix $(Build.ArtifactStagingDirectory)/copilot-vsix/
86
workingDirectory: $(Build.SourcesDirectory)/extensions/copilot
87
displayName: Package Copilot VSIX
88
89
- task: AzureCLI@2
90
displayName: Upload source maps to CDN
91
inputs:
92
azureSubscription: vscode-cdn
93
scriptType: bash
94
addSpnToEnvironment: true
95
scriptLocation: inlineScript
96
inlineScript: |
97
set -e
98
99
WORKING_DIR="$(Build.SourcesDirectory)/extensions/copilot"
100
SOURCE_MAP_DIR="$WORKING_DIR/dist-sourcemaps"
101
STORAGE_ACCOUNT="vscodeweb"
102
103
if [ ! -d "$SOURCE_MAP_DIR" ]; then
104
echo "Source maps directory not found: $SOURCE_MAP_DIR"
105
echo "Skipping upload."
106
exit 0
107
fi
108
109
PUBLISHER=$(node -p "require('$WORKING_DIR/package.json').publisher")
110
NAME=$(node -p "require('$WORKING_DIR/package.json').name")
111
VERSION=$(node -p "require('$WORKING_DIR/package.json').version")
112
EXTENSION_ID=$(echo "${PUBLISHER}.${NAME}" | tr '[:upper:]' '[:lower:]')
113
114
echo "Extension: $EXTENSION_ID"
115
echo "Version: $VERSION"
116
117
MAP_FILES=$(find "$SOURCE_MAP_DIR" -name "*.map" -type f)
118
FILE_COUNT=$(echo "$MAP_FILES" | grep -c . || true)
119
120
if [ "$FILE_COUNT" -eq 0 ]; then
121
echo "No source map files found in $SOURCE_MAP_DIR"
122
exit 0
123
fi
124
125
echo "Found $FILE_COUNT source map files"
126
127
BLOB_URL="https://${STORAGE_ACCOUNT}.blob.core.windows.net"
128
PREFIX="sourcemaps/${EXTENSION_ID}/${VERSION}"
129
130
echo "Uploading to: $BLOB_URL/\$web/$PREFIX/"
131
132
UPLOADED=0
133
for FILE in $MAP_FILES; do
134
FILENAME=$(basename "$FILE")
135
BLOB_NAME="$PREFIX/$FILENAME"
136
137
az storage blob upload \
138
--account-name "$STORAGE_ACCOUNT" \
139
--container-name '$web' \
140
--name "$BLOB_NAME" \
141
--file "$FILE" \
142
--content-type "application/json" \
143
--content-cache-control "max-age=31536000, public" \
144
--auth-mode login \
145
--overwrite \
146
--only-show-errors
147
148
UPLOADED=$((UPLOADED + 1))
149
done
150
151
echo "Successfully uploaded $UPLOADED source maps"
152
153
# Upload commit-to-version mapping so the deminify service
154
# can resolve the patched extension version from a VS Code commit hash.
155
COMMIT_HASH="$(Build.SourceVersion)"
156
MAPPING_BLOB="sourcemaps/${EXTENSION_ID}/commits/${COMMIT_HASH}.json"
157
echo "{\"version\":\"${VERSION}\",\"extensionId\":\"${EXTENSION_ID}\"}" > /tmp/commit-version.json
158
159
echo "Uploading commit mapping: $COMMIT_HASH -> $VERSION"
160
az storage blob upload \
161
--account-name "$STORAGE_ACCOUNT" \
162
--container-name '$web' \
163
--name "$MAPPING_BLOB" \
164
--file "/tmp/commit-version.json" \
165
--content-type "application/json" \
166
--content-cache-control "no-cache, no-store, must-revalidate" \
167
--auth-mode login \
168
--overwrite \
169
--only-show-errors
170
171
echo "Commit mapping uploaded: $MAPPING_BLOB"
172
173