Skip to content

Commit 9bc8bfe

Browse files
authored
Merge branch 'aws:master' into refactor-sam-sync-deploy-build
2 parents 7d68864 + 5450d47 commit 9bc8bfe

File tree

70 files changed

+1220
-947
lines changed

Some content is hidden

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

70 files changed

+1220
-947
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ module.exports = {
162162
'aws-toolkits/no-incorrect-once-usage': 'error',
163163
'aws-toolkits/no-string-exec-for-child-process': 'error',
164164
'aws-toolkits/no-console-log': 'error',
165-
165+
'aws-toolkits/no-json-stringify-in-log': 'error',
166166
'no-restricted-imports': [
167167
'error',
168168
{
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# github actions: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-nodejs
2+
# setup-node: https://github.com/actions/setup-node
3+
4+
name: Copy-Paste Detection
5+
6+
on:
7+
pull_request:
8+
branches: [master, feature/*, staging]
9+
10+
jobs:
11+
jscpd:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
node-version: [18.x]
16+
env:
17+
NODE_OPTIONS: '--max-old-space-size=8192'
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
29+
- name: Fetch fork upstream
30+
run: |
31+
git remote add forkUpstream https://github.com/${{ github.event.pull_request.head.repo.full_name }} # URL of the fork
32+
git fetch forkUpstream # Fetch fork
33+
34+
- name: Determine base and target branches for comparison.
35+
run: |
36+
echo "CURRENT_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
37+
echo "TARGET_BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
38+
- run: git diff --name-only origin/$TARGET_BRANCH forkUpstream/$CURRENT_BRANCH > diff_output.txt
39+
- run: |
40+
npm install -g jscpd
41+
42+
- run: jscpd --config "$GITHUB_WORKSPACE/.github/workflows/jscpd.json"
43+
44+
- if: always()
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: unfiltered-jscpd-report
48+
path: ./jscpd-report.json
49+
50+
- name: Filter jscpd report for changed files
51+
run: |
52+
if [ ! -f ./jscpd-report.json ]; then
53+
echo "jscpd-report.json not found"
54+
exit 1
55+
fi
56+
echo "Filtering jscpd report for changed files..."
57+
CHANGED_FILES=$(jq -R -s -c 'split("\n")[:-1]' diff_output.txt)
58+
echo "Changed files: $CHANGED_FILES"
59+
jq --argjson changed_files "$CHANGED_FILES" '
60+
.duplicates | map(select(
61+
(.firstFile?.name as $fname | $changed_files | any(. == $fname)) or
62+
(.secondFile?.name as $sname | $changed_files | any(. == $sname))
63+
))
64+
' ./jscpd-report.json > filtered-jscpd-report.json
65+
cat filtered-jscpd-report.json
66+
67+
- name: Check for duplicates
68+
run: |
69+
if [ $(wc -l < ./filtered-jscpd-report.json) -gt 1 ]; then
70+
echo "filtered_report_exists=true" >> $GITHUB_ENV
71+
else
72+
echo "filtered_report_exists=false" >> $GITHUB_ENV
73+
fi
74+
- name: upload filtered report (if applicable)
75+
if: env.filtered_report_exists == 'true'
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: filtered-jscpd-report
79+
path: ./filtered-jscpd-report.json
80+
81+
- name: Fail and log found duplicates.
82+
if: env.filtered_report_exists == 'true'
83+
run: |
84+
cat ./filtered-jscpd-report.json
85+
echo "Duplications found, failing the check."
86+
exit 1

.github/workflows/jscpd.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"pattern": "packages/**/*.ts",
3-
"ignore": ["**node_modules**", "**dist**"],
3+
"ignore": ["**node_modules**", "**dist**", "**/scripts/**"],
44
"gitignore": true,
5-
"threshold": 1.34,
6-
"minLines": 15
5+
"threshold": 3.0,
6+
"minLines": 3,
7+
"output": "./",
8+
"reporters": ["json"]
79
}

.github/workflows/node.js.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,6 @@ jobs:
5555
- run: npm run testCompile
5656
- run: npm run lint
5757

58-
jscpd:
59-
needs: lint-commits
60-
runs-on: ubuntu-latest
61-
strategy:
62-
matrix:
63-
node-version: [18.x]
64-
env:
65-
NODE_OPTIONS: '--max-old-space-size=8192'
66-
steps:
67-
- uses: actions/checkout@v4
68-
- name: Use Node.js ${{ matrix.node-version }}
69-
uses: actions/setup-node@v4
70-
with:
71-
node-version: ${{ matrix.node-version }}
72-
- run: npm install jscpd
73-
- name: Run jscpd
74-
run: npx jscpd --config "$GITHUB_WORKSPACE/.github/workflows/jscpd.json"
75-
7658
macos:
7759
needs: lint-commits
7860
name: test macOS

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,16 @@ To run tests against a specific folder in VSCode, do any one of:
216216
$Env:TEST_DIR = "../core/src/test/foo"; npm run test
217217
```
218218
219+
#### Run jscpd ("Copy-Paste Detection")
220+
221+
If the "Copy-Paste Detection" CI job fails, you will find it useful to check things locally. To
222+
check a specific file:
223+
224+
npx jscpd --config .github/workflows/jscpd.json --pattern packages/…/src/foo.ts
225+
226+
See the [jscpd cli documentation](https://github.com/kucherenko/jscpd/tree/master/apps/jscpd) for
227+
more options.
228+
219229
### Coverage report
220230
221231
You can find the coverage report at `./coverage/amazonq/lcov-report/index.html` and `./coverage/toolkit/lcov-report/index.html` after running the tests. Tests ran from the workspace launch config won't generate a coverage report automatically because it can break file watching.

package-lock.json

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"typescript": "^5.0.4",
6767
"webpack": "^5.95.0",
6868
"webpack-cli": "^5.1.4",
69-
"webpack-dev-server": "^4.15.1",
69+
"webpack-dev-server": "^4.15.2",
7070
"webpack-merge": "^5.10.0"
7171
},
7272
"dependencies": {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Improve `@workspace` index auto pause start strategy. "
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Security Scan: Auto-scan now supports JSX, TSX, Kotlin, Scala, and Shell files."
4+
}

packages/amazonq/src/extension.ts

Lines changed: 3 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,8 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import {
7-
AuthUtils,
8-
CredentialsStore,
9-
LoginManager,
10-
getTelemetryMetadataForConn,
11-
initializeAuth,
12-
isAnySsoConnection,
13-
} from 'aws-core-vscode/auth'
14-
import {
15-
AuthState,
16-
AuthUtil,
17-
activate as activateCodeWhisperer,
18-
shutdown as shutdownCodeWhisperer,
19-
} from 'aws-core-vscode/codewhisperer'
6+
import { AuthUtils, CredentialsStore, LoginManager, initializeAuth } from 'aws-core-vscode/auth'
7+
import { activate as activateCodeWhisperer, shutdown as shutdownCodeWhisperer } from 'aws-core-vscode/codewhisperer'
208
import { makeEndpointsProvider, registerGenericCommands } from 'aws-core-vscode'
219
import { CommonAuthWebview } from 'aws-core-vscode/login'
2210
import {
@@ -38,15 +26,13 @@ import {
3826
globals,
3927
initialize,
4028
initializeComputeRegion,
41-
isNetworkError,
4229
messages,
4330
placeholder,
4431
setContext,
4532
setupUninstallHandler,
4633
maybeShowMinVscodeWarning,
47-
isSageMaker,
4834
} from 'aws-core-vscode/shared'
49-
import { ExtStartUpSources, telemetry } from 'aws-core-vscode/telemetry'
35+
import { ExtStartUpSources } from 'aws-core-vscode/telemetry'
5036
import { VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
5137
import { join } from 'path'
5238
import * as semver from 'semver'
@@ -161,53 +147,6 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
161147
void focusAmazonQPanel.execute(placeholder, 'firstStartUp')
162148
}, 1000)
163149
}
164-
165-
await telemetry.auth_userState
166-
.run(async () => {
167-
telemetry.record({ passive: true })
168-
169-
const firstUse = AuthUtils.ExtensionUse.instance.isFirstUse()
170-
const wasUpdated = AuthUtils.ExtensionUse.instance.wasUpdated()
171-
172-
if (firstUse) {
173-
telemetry.record({ source: ExtStartUpSources.firstStartUp })
174-
} else if (wasUpdated) {
175-
telemetry.record({ source: ExtStartUpSources.update })
176-
} else {
177-
telemetry.record({ source: ExtStartUpSources.reload })
178-
}
179-
180-
let authState: AuthState = 'disconnected'
181-
try {
182-
// May call connection validate functions that try to refresh the token.
183-
// This could result in network errors.
184-
authState = (await AuthUtil.instance.getChatAuthState(false)).codewhispererChat
185-
} catch (err) {
186-
if (
187-
isNetworkError(err) &&
188-
AuthUtil.instance.conn &&
189-
AuthUtil.instance.auth.getConnectionState(AuthUtil.instance.conn) === 'valid'
190-
) {
191-
authState = 'connectedWithNetworkError'
192-
} else {
193-
throw err
194-
}
195-
}
196-
const currConn = AuthUtil.instance.conn
197-
if (currConn !== undefined && !(isAnySsoConnection(currConn) || isSageMaker())) {
198-
getLogger().error(`Current Amazon Q connection is not SSO, type is: %s`, currConn?.type)
199-
}
200-
201-
telemetry.record({
202-
authStatus:
203-
authState === 'connected' || authState === 'expired' || authState === 'connectedWithNetworkError'
204-
? authState
205-
: 'notConnected',
206-
authEnabledConnections: AuthUtils.getAuthFormIdsFromConnection(currConn).join(','),
207-
...(await getTelemetryMetadataForConn(currConn)),
208-
})
209-
})
210-
.catch((err) => getLogger().error('Error collecting telemetry for auth_userState: %s', err))
211150
}
212151

213152
export async function deactivateCommon() {

0 commit comments

Comments
 (0)