Skip to content

Commit 308be6f

Browse files
committed
Merge branch 'main' into AXON-1383-rovo-dev-is-disabled
2 parents 658d7b1 + b14d7af commit 308be6f

File tree

89 files changed

+826
-118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+826
-118
lines changed

.github/workflows/build.yaml

Lines changed: 137 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Build
22
permissions:
33
contents: read
44
packages: read
5+
actions: write
56

67
on:
78
pull_request:
@@ -14,18 +15,55 @@ concurrency:
1415
cancel-in-progress: true
1516

1617
jobs:
17-
lint:
18+
setup-dependencies:
1819
runs-on: ubuntu-latest
1920
steps:
2021
- uses: actions/checkout@v4
22+
2123
- uses: actions/setup-node@v4
2224
with:
2325
node-version: 20
24-
cache: 'npm'
26+
27+
- name: Cache npm dependencies
28+
uses: actions/cache@v4
29+
with:
30+
path: |
31+
~/.npm
32+
node_modules
33+
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
34+
restore-keys: |
35+
npm-${{ runner.os }}-
2536
2637
- name: Install dependencies
27-
run: |
28-
npm ci --no-audit
38+
run: npm ci
39+
40+
- name: Compress node_modules
41+
run: tar -czf node_modules.tar.gz node_modules
42+
43+
- name: Upload node_modules for reuse
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: node-modules
47+
path: node_modules.tar.gz
48+
retention-days: 1
49+
50+
lint:
51+
needs: [setup-dependencies]
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- uses: actions/setup-node@v4
57+
with:
58+
node-version: 20
59+
60+
- name: Download node_modules
61+
uses: actions/download-artifact@v4
62+
with:
63+
name: node-modules
64+
65+
- name: Extract node_modules
66+
run: tar -xzf node_modules.tar.gz
2967

3068
- name: Run vulnerability audit
3169
# "There is no Vulnerability in Media Viewer after 48.5.4. since it was fixed by patching, but npm audit still reports it.",
@@ -35,22 +73,66 @@ jobs:
3573
- name: Run linter
3674
run: npm run lint
3775

38-
ci-matrix:
39-
needs: [lint]
76+
test-unit:
77+
needs: [setup-dependencies]
78+
runs-on: ubuntu-latest
79+
steps:
80+
- uses: actions/checkout@v4
81+
82+
- uses: actions/setup-node@v4
83+
with:
84+
node-version: 20
85+
86+
- name: Download node_modules
87+
uses: actions/download-artifact@v4
88+
with:
89+
name: node-modules
90+
91+
- name: Extract node_modules
92+
run: tar -xzf node_modules.tar.gz
93+
94+
- name: Run unit tests
95+
run: npm test
96+
97+
build-extension:
98+
needs: [setup-dependencies]
99+
runs-on: ubuntu-latest
100+
steps:
101+
- uses: actions/checkout@v4
102+
103+
- uses: actions/setup-node@v4
104+
with:
105+
node-version: 20
106+
107+
- name: Download node_modules
108+
uses: actions/download-artifact@v4
109+
with:
110+
name: node-modules
111+
112+
- name: Extract node_modules
113+
run: tar -xzf node_modules.tar.gz
114+
115+
- name: Package the extension
116+
run: npm run extension:package
117+
118+
- name: Upload extension package
119+
uses: actions/upload-artifact@v4
120+
with:
121+
name: extension-package
122+
path: atlascode-*.vsix
123+
retention-days: 1
124+
125+
test-e2e:
126+
needs: [build-extension]
40127
runs-on: ubuntu-latest
41128
strategy:
42-
fail-fast: true
129+
fail-fast: false
43130
matrix:
44-
include:
45-
- kind: unit
46-
- kind: e2e
47-
target: jira-cloud
48-
- kind: e2e
49-
target: jira-dc
50-
- kind: e2e
51-
target: bitbucket-cloud
52-
- kind: e2e
53-
target: bitbucket-dc
131+
target:
132+
- jira-cloud
133+
- jira-dc
134+
- bitbucket-cloud
135+
- bitbucket-dc
54136

55137
env:
56138
ATLASCODE_FX3_API_KEY: ${{ secrets.ATLASCODE_FX3_API_KEY }}
@@ -60,40 +142,39 @@ jobs:
60142

61143
steps:
62144
- uses: actions/checkout@v4
145+
63146
- uses: actions/setup-node@v4
64147
with:
65148
node-version: 20
66-
cache: 'npm'
67-
68-
- name: Install dependencies
69-
run: npm ci --no-audit
149+
150+
- name: Download node_modules
151+
uses: actions/download-artifact@v4
152+
with:
153+
name: node-modules
70154

71-
- name: Run unit tests
72-
if: matrix.kind == 'unit'
73-
run: npm run test
155+
- name: Extract node_modules
156+
run: tar -xzf node_modules.tar.gz
74157

75-
- name: Build and package the extension
76-
if: matrix.kind == 'e2e'
77-
run: npm run extension:package
158+
- name: Download extension package
159+
uses: actions/download-artifact@v4
160+
with:
161+
name: extension-package
78162

79163
- name: Generate SSL certs for E2E test
80-
if: matrix.kind == 'e2e'
81164
run: npm run test:e2e:sslcerts
82165

83166
- name: Fetch E2E image
84-
if: matrix.kind == 'e2e'
85167
run: |
86168
docker pull ghcr.io/atlassian/atlascode-e2e:latest
87169
docker tag ghcr.io/atlassian/atlascode-e2e:latest atlascode-e2e
88170
89171
- name: Run E2E (${{ matrix.target }})
90-
if: matrix.kind == 'e2e'
91172
run: npm run test:e2e:docker
92173
env:
93174
TARGET: ${{ matrix.target }}
94175

95176
- name: Upload E2E artifacts (${{ matrix.target }})
96-
if: matrix.kind == 'e2e' && failure()
177+
if: failure()
97178
uses: actions/upload-artifact@v4
98179
with:
99180
name: e2e-test-results-${{ matrix.target }}
@@ -102,14 +183,35 @@ jobs:
102183
if-no-files-found: ignore
103184

104185
finalize:
105-
needs: [ci-matrix]
186+
needs: [setup-dependencies, lint, test-unit, build-extension, test-e2e]
106187
runs-on: ubuntu-latest
107188
if: always()
108189
steps:
190+
- name: Delete node_modules artifact
191+
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
192+
uses: geekyeggo/delete-artifact@v5
193+
with:
194+
name: node-modules
195+
failOnError: false
196+
197+
- name: Delete extension package artifact
198+
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
199+
uses: geekyeggo/delete-artifact@v5
200+
with:
201+
name: extension-package
202+
failOnError: false
203+
109204
- name: Check if all jobs succeeded
110205
run: |
111-
if [[ "${{ needs.ci-matrix.result }}" != "success" ]]; then
112-
echo "One of the ci-matrix jobs failed"
206+
results='${{ toJSON(needs.*.result) }}'
207+
if echo "$results" | jq -e 'any(. != "success")' > /dev/null; then
208+
echo "One or more jobs failed:"
209+
echo " setup-dependencies: ${{ needs.setup-dependencies.result }}"
210+
echo " lint: ${{ needs.lint.result }}"
211+
echo " test-unit: ${{ needs.test-unit.result }}"
212+
echo " build-extension: ${{ needs.build-extension.result }}"
213+
echo " test-e2e: ${{ needs.test-e2e.result }}"
214+
echo "Artifacts are retained for 1 day to allow rerunning failed jobs"
113215
exit 1
114216
fi
115-
echo "All steps completed successfully"
217+
echo "All steps completed successfully"

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
],
4747
"main": "./build/extension/extension",
4848
"rovoDev": {
49-
"version": "0.12.14"
49+
"version": "0.12.16"
5050
},
5151
"scripts": {
5252
"vscode:uninstall": "node ./build/extension/uninstall.js",
@@ -517,6 +517,11 @@
517517
"command": "atlascode.debug.quickLogout",
518518
"title": "[DEBUG] Atlassian: Quick logout",
519519
"enablement": "atlascode:debugMode"
520+
},
521+
{
522+
"command": "atlascode.addRecommendedExtension",
523+
"title": "Add as Recommended Extension",
524+
"category": "Atlassian"
520525
}
521526
],
522527
"viewsContainers": {

src/analytics.test.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ describe('analytics', () => {
264264
expect(event.trackEvent.attributes.additionalParams).toEqual(additionalParams);
265265
});
266266

267-
it('should sanitize stack traces in errorEvent', async () => {
267+
it('should sanitize stack traces in errorEvent (/Users)', async () => {
268268
const errorMessage = 'Test error message';
269269
const error = new Error('Test error');
270270
error.stack = 'Error: Test error\n at TestFunction (/Users/realuser/test.js:10:15)';
@@ -276,6 +276,30 @@ describe('analytics', () => {
276276
expect(event.trackEvent.attributes.stack).not.toContain('/Users/realuser/');
277277
});
278278

279+
it('should sanitize stack traces in errorEvent (/home)', async () => {
280+
const errorMessage = 'Test error message';
281+
const error = new Error('Test error');
282+
error.stack = 'Error: Test error\n at TestFunction (/home/realuser/test.js:10:15)';
283+
284+
const event = await analytics.errorEvent(undefined, errorMessage, error);
285+
286+
// Check if the username was sanitized
287+
expect(event.trackEvent.attributes.stack).toContain('/home/<user>/');
288+
expect(event.trackEvent.attributes.stack).not.toContain('/home/realuser/');
289+
});
290+
291+
it('should sanitize stack traces in errorEvent (c:\\Users)', async () => {
292+
const errorMessage = 'Test error message';
293+
const error = new Error('Test error');
294+
error.stack = 'Error: Test error\n at TestFunction (c:\\Users\\realuser\\test.js:10:15)';
295+
296+
const event = await analytics.errorEvent(undefined, errorMessage, error);
297+
298+
// Check if the username was sanitized
299+
expect(event.trackEvent.attributes.stack).toContain('c:\\Users\\<user>\\');
300+
expect(event.trackEvent.attributes.stack).not.toContain('c:\\Users\\realuser\\');
301+
});
302+
279303
it('should create uiErrorEvent with UI error information', async () => {
280304
const errorInfo: UIErrorInfo = {
281305
view: 'test-view',

src/analytics.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ function sanitazeErrorMessage(message?: string): string | undefined {
145145
function sanitizeStackTrace(stack?: string): string | undefined {
146146
if (stack) {
147147
stack = stack.replace(/\/Users\/[^/]+\//gi, '/Users/<user>/'); // *nix Users folder
148+
stack = stack.replace(/\/home\/[^/]+\//gi, '/home/<user>/'); // *nix home folder
148149
stack = stack.replace(/\\Users\\[^\\]+\\/gi, '\\Users\\<user>\\'); // windows Users folder
149150
}
150151
return stack || undefined;
@@ -521,6 +522,12 @@ export async function pmfClosed(): Promise<TrackEvent> {
521522
return trackEvent('closed', 'atlascodePmf');
522523
}
523524

525+
export async function addRecommendedExtensionTriggeredEvent(source: string): Promise<TrackEvent> {
526+
return trackEvent('triggered', 'addRecommendedExtension', {
527+
attributes: { source: source },
528+
});
529+
}
530+
524531
export type DeepLinkEventErrorType = 'Success' | 'NotFound' | 'Exception';
525532

526533
export async function deepLinkEvent(

src/commands.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from './analytics';
1111
import { BasicAuthInfo, DetailedSiteInfo, ProductBitbucket, ProductJira } from './atlclients/authInfo';
1212
import { showBitbucketDebugInfo } from './bitbucket/bbDebug';
13+
import { addAtlascodeAsRecommendedExtension } from './commands/addRecommendedExtension';
1314
import { rerunPipeline } from './commands/bitbucket/rerunPipeline';
1415
import { runPipeline } from './commands/bitbucket/runPipeline';
1516
import { assignIssue } from './commands/jira/assignIssue';
@@ -237,6 +238,7 @@ export function registerCommands(vscodeContext: ExtensionContext) {
237238
});
238239
}
239240
}),
241+
commands.registerCommand(Commands.AddRecommendedExtension, addAtlascodeAsRecommendedExtension),
240242
);
241243
} else {
242244
vscodeContext.subscriptions.push(
@@ -449,6 +451,7 @@ export function registerCommands(vscodeContext: ExtensionContext) {
449451
});
450452
}
451453
}),
454+
commands.registerCommand(Commands.AddRecommendedExtension, addAtlascodeAsRecommendedExtension),
452455
);
453456
}
454457
}

0 commit comments

Comments
 (0)