Skip to content

Commit afe08e9

Browse files
committed
merge
2 parents f6ee8ce + 09510a3 commit afe08e9

File tree

347 files changed

+42375
-13727
lines changed

Some content is hidden

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

347 files changed

+42375
-13727
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ 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',
166+
'aws-toolkits/no-printf-mismatch': 'error',
166167
'no-restricted-imports': [
167168
'error',
168169
{
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"pattern": "packages/**/*.ts",
3+
"ignore": ["**node_modules**", "**dist**", "**/scripts/**"],
4+
"gitignore": true,
5+
"threshold": 3.0,
6+
"minLines": 3,
7+
"output": "./",
8+
"reporters": ["json"]
9+
}

.github/workflows/notification.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
if: github.event_name == 'pull_request_target'
3838
with:
3939
node-version: '20'
40-
- name: Check for tests
40+
- name: Comment about contribution guidelines
4141
uses: actions/github-script@v7
4242
if: github.event_name == 'pull_request_target'
4343
with:

.github/workflows/notify.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
const { hasPath, dedupComment } = require('./utils')
77

88
const testFilesMessage =
9-
'This pull request modifies code in src/ but no tests were added/updated. Confirm whether tests should be added or ensure the PR description explains why tests are not required.'
9+
'- This pull request modifies code in `src/*` but no tests were added/updated.\n - Confirm whether tests should be added or ensure the PR description explains why tests are not required.\n'
1010

11-
const changelogMessage = `This pull request implements a feature or fix, so it must include a changelog entry. See [CONTRIBUTING.md#changelog](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#changelog) for instructions.`
11+
const changelogMessage =
12+
'- This pull request implements a `feat` or `fix`, so it must include a changelog entry (unless the fix is for an *unreleased* feature). Review the [changelog guidelines](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#changelog).\n - Note: beta or "experiment" features that have active users *should* announce fixes in the changelog.\n - If this is not a feature or fix, use an appropriate type from the [title guidelines](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#pull-request-title). For example, telemetry-only changes should use the `telemetry` type.\n'
1213

1314
/**
1415
* Remind partner teams that tests are required. We don't need to remind them if:
@@ -44,12 +45,16 @@ module.exports = async ({ github, context }) => {
4445
issue_number: pullRequestId,
4546
})
4647

48+
let msg = ''
4749
if (shouldAddTestFileMessage) {
48-
await dedupComment({ github, comments, owner, repo, pullRequestId, message: testFilesMessage })
50+
msg += testFilesMessage
4951
}
50-
5152
if (shouldAddChangelogMessage) {
52-
await dedupComment({ github, comments, owner, repo, pullRequestId, message: changelogMessage })
53+
msg += changelogMessage
54+
}
55+
56+
if (shouldAddTestFileMessage || shouldAddChangelogMessage) {
57+
await dedupComment({ github, comments, owner, repo, pullRequestId, message: msg })
5358
}
5459
}
5560

@@ -69,7 +74,12 @@ function requiresChangelogMessage(filenames, title) {
6974
* Require the test files message if there are changes to source files but aren't any
7075
* changes to the test files
7176
*/
72-
function requiresTestFilesMessage(filenames) {
77+
function requiresTestFilesMessage(filenames, title) {
78+
if (/^\s*[mM]erge/.test(title)) {
79+
console.log('"Merge" pull request')
80+
return
81+
}
82+
7383
// Check if src directory changed
7484
if (!hasPath(filenames, 'src/')) {
7585
console.log('Did not find src files in the code changes')

CONTRIBUTING.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ To run a single test in VSCode, do any one of:
188188
189189
- Unix/macOS/POSIX shell:
190190
```
191-
TEST_FILE=src/test/foo.test.ts npm run test
191+
TEST_FILE=../core/src/test/foo.test.ts npm run test
192192
```
193193
- Powershell:
194194
```
195-
$Env:TEST_FILE = "src/test/foo.test.ts"; npm run test
195+
$Env:TEST_FILE = "../core/src/test/foo.test.ts"; npm run test
196196
```
197197
198198
- To run all tests in a particular subdirectory, you can edit
@@ -209,13 +209,23 @@ To run tests against a specific folder in VSCode, do any one of:
209209
- Run in your terminal
210210
- Unix/macOS/POSIX shell:
211211
```
212-
TEST_DIR=src/test/foo npm run test
212+
TEST_DIR=../core/src/test/foo npm run test
213213
```
214214
- Powershell:
215215
```
216-
$Env:TEST_DIR = "src/test/foo"; npm run test
216+
$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.

buildspec/shared/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# - "Webview is disposed": only happens on vscode "minimum" (1.68.0)
1010
# - "HTTPError: Response code …": caused by github rate-limiting.
1111
# - "npm WARN deprecated querystring": transitive dep of aws sdk v2 (check `npm ls querystring`), so that's blocked until we migrate to v3.
12-
_ignore_pat='Timed-out waiting for browser login flow\|HTTPError: Response code 403\|HTTPError: Response code 404\|npm WARN deprecated querystring'
12+
_ignore_pat='Timed-out waiting for browser login flow\|HTTPError: Response code 403\|HTTPError: Response code 404\|npm WARN deprecated querystring\|npm WARN deprecated'
1313
if [ "$VSCODE_TEST_VERSION" = 'minimum' ]; then
1414
_ignore_pat="$_ignore_pat"'\|Webview is disposed'
1515
fi

docs/build.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
# Build
22

3-
The AmazonQ features rely on the `codewhisperer-streaming` service, who's client
4-
is generated from the service's smithy models and placed in
5-
`src.gen/@amzn/codewhisperer-streaming` (For more
6-
information about this client and how it is generated, please see this
3+
The AmazonQ features rely on the `codewhisperer-streaming` service, to support both Sigv4 and Bearer token modes of this service,
4+
two clients are generated from the service's smithy models and placed in
5+
`src.gen/@amzn/amazon-q-developer-streaming-client` and `src.gen/@amzn/codewhisperer-streaming` respectively (For more
6+
information about these clients and how they are generated, please see this
77
[quip document](https://quip-amazon.com/2dAWAvTIYXXr/Build-instructions-for-AWS-CodeWhisperer-Streaming-Typescript-client)).
88

9+
## @amzn/amazon-q-developer-streaming client
10+
11+
This client is a standalone npm project in typescript, and it is added to
12+
the project as a workspace in the project's root `package.json` with the line `"workspaces": [ ..., "src.gen/@amzn/amazon-q-developer-streaming" ]`.
13+
The client may be manually built using `npm run build -w @amzn/amazon-q-developer-streaming"`.
14+
The `generateClients` run script ensures that this dependency is
15+
built before the toolkit project itself. Workspaces are automatically ready to
16+
be imported in the root toolkit project by their declared package.json name,
17+
(`@amzn/amazon-q-developer-streaming` in this case).
18+
19+
## @amzn/codewhisperer-streaming client
20+
921
This client is a standalone npm project in typescript, and it is added to
1022
the project as a workspace in the project's root `package.json` with the line `"workspaces": [ ..., "src.gen/@amzn/codewhisperer-streaming" ]`.
1123
The client may be manually built using `npm run build -w @amzn/codewhisperer-streaming"`.

0 commit comments

Comments
 (0)