Skip to content

Commit 6dbff72

Browse files
authored
fix: Code coverage report for amazon q (aws#5322)
* fix: code coverage not reporting for amazon q Problem: - Codecoverage for amazon q wasn't actually generating any lcov.info information since the c8rc.json lived in core and amazonq couldn't find it Solution: - Make a c8rc file inside of q for configuring c8 - note: tried hoisting the c8rc from core into the root and sharing it between the two projects but it seems to break file paths - Add code coverage report for q - Change code coverage directory for toolkit - Update codecov codewhisperer/featureDev paths
1 parent 479c037 commit 6dbff72

File tree

9 files changed

+41
-18
lines changed

9 files changed

+41
-18
lines changed

.github/workflows/node.js.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,38 @@ jobs:
3232
uses: coactions/setup-xvfb@v1
3333
with:
3434
run: npm test
35-
- name: Code coverage
35+
- name: Code coverage (Core)
3636
env:
3737
# Unset NODE_OPTIONS because of https://github.com/codecov/uploader/issues/475
3838
NODE_OPTIONS: ''
3939
if: ${{ github.repository == 'aws/aws-toolkit-vscode' && ( github.ref == 'master' || github.event_name == 'pull_request' ) }}
4040
uses: codecov/codecov-action@v4
4141
with:
42-
flags: macos-unittests
42+
flags: macos-core-unittests
4343
verbose: true
44-
file: ./coverage/lcov.info
44+
file: ./coverage/core/lcov.info
45+
token: ${{ secrets.CODECOV_TOKEN }}
46+
- name: Code coverage (Toolkit)
47+
env:
48+
# Unset NODE_OPTIONS because of https://github.com/codecov/uploader/issues/475
49+
NODE_OPTIONS: ''
50+
if: ${{ github.repository == 'aws/aws-toolkit-vscode' && ( github.ref == 'master' || github.event_name == 'pull_request' ) }}
51+
uses: codecov/codecov-action@v4
52+
with:
53+
flags: macos-toolkit-unittests
54+
verbose: true
55+
file: ./coverage/toolkit/lcov.info
56+
token: ${{ secrets.CODECOV_TOKEN }}
57+
- name: Code coverage (Amazon Q)
58+
env:
59+
# Unset NODE_OPTIONS because of https://github.com/codecov/uploader/issues/475
60+
NODE_OPTIONS: ''
61+
if: ${{ github.repository == 'aws/aws-toolkit-vscode' && ( github.ref == 'master' || github.event_name == 'pull_request' ) }}
62+
uses: codecov/codecov-action@v4
63+
with:
64+
flags: macos-amazonq-unittests
65+
verbose: true
66+
file: ./coverage/amazonq/lcov.info
4567
token: ${{ secrets.CODECOV_TOKEN }}
4668
- name: Code coverage (CodeWhisperer)
4769
env:
@@ -52,7 +74,7 @@ jobs:
5274
with:
5375
flags: codewhisperer
5476
verbose: true
55-
file: ./coverage/lcov.info
77+
file: ./coverage/core/lcov.info
5678
token: ${{ secrets.CODECOV_TOKEN }}
5779

5880
web:

CONTRIBUTING.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,7 @@ To run tests against a specific folder in VSCode, do any one of:
218218
219219
### Coverage report
220220
221-
You can find the coverage report at `./coverage/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. A few manual steps are needed instead:
222-
223-
- Run the command `Tasks: Run Build Task` if not already active
224-
- Instrument built code with `npm run instrument`
225-
- Exercise the code (`Extension Tests`, `Integration Tests`, etc.)
226-
- Generate a report with `npm run report`
221+
You can find the coverage report at `./coverage/amazonq/lcov-report/index.html` and `./coverage/core/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.
227222
228223
### CodeCatalyst Blueprints
229224

buildspec/linuxE2ETests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ phases:
4141
- VCS_COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}"
4242
- CI_BUILD_URL=$(echo $CODEBUILD_BUILD_URL | sed 's/#/%23/g')
4343
- CI_BUILD_ID="${CODEBUILD_BUILD_ID}"
44-
- test -n "${CODECOV_TOKEN}" && ./codecov --token=${CODECOV_TOKEN} --branch=${CODEBUILD_RESOLVED_SOURCE_VERSION} --repository=${CODEBUILD_SOURCE_REPO_URL} --file=./coverage/lcov.info
44+
- test -n "${CODECOV_TOKEN}" && ./codecov --token=${CODECOV_TOKEN} --branch=${CODEBUILD_RESOLVED_SOURCE_VERSION} --repository=${CODEBUILD_SOURCE_REPO_URL} --file=./coverage/core/lcov.info --file=./coverage/amazonq/lcov.info --file=./coverage/toolkit/lcov.info
4545
finally:
4646
- rm -rf ~/.aws/sso/cache || true
4747
reports:

buildspec/linuxIntegrationTests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ phases:
7575
- VCS_COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}"
7676
- CI_BUILD_URL=$(echo $CODEBUILD_BUILD_URL | sed 's/#/%23/g')
7777
- CI_BUILD_ID="${CODEBUILD_BUILD_ID}"
78-
- test -n "${CODECOV_TOKEN}" && ./codecov --token=${CODECOV_TOKEN} --branch=${CODEBUILD_RESOLVED_SOURCE_VERSION} --repository=${CODEBUILD_SOURCE_REPO_URL} --file=./coverage/lcov.info
78+
- test -n "${CODECOV_TOKEN}" && ./codecov --token=${CODECOV_TOKEN} --branch=${CODEBUILD_RESOLVED_SOURCE_VERSION} --repository=${CODEBUILD_SOURCE_REPO_URL} --file=./coverage/core/lcov.info --file=./coverage/amazonq/lcov.info --file=./coverage/toolkit/lcov.info
7979
post_build:
8080
commands:
8181
# Destroy .netrc to avoid leaking $GITHUB_READONLY_TOKEN.

buildspec/linuxTests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ phases:
4848
- VCS_COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}"
4949
- CI_BUILD_URL=$(echo $CODEBUILD_BUILD_URL | sed 's/#/%23/g') # Encode `#` in the URL because otherwise the url is clipped in the Codecov.io site
5050
- CI_BUILD_ID="${CODEBUILD_BUILD_ID}"
51-
- test -n "${CODECOV_TOKEN}" && ./codecov --token=${CODECOV_TOKEN} --branch=${CODEBUILD_RESOLVED_SOURCE_VERSION} --repository=${CODEBUILD_SOURCE_REPO_URL} --file=./coverage/lcov.info
51+
- test -n "${CODECOV_TOKEN}" && ./codecov --token=${CODECOV_TOKEN} --branch=${CODEBUILD_RESOLVED_SOURCE_VERSION} --repository=${CODEBUILD_SOURCE_REPO_URL} --file=./coverage/core/lcov.info --file=./coverage/amazonq/lcov.info --file=./coverage/toolkit/lcov.info
5252

5353
reports:
5454
unit-test:

codecov.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ coverage:
1818
codewhisperer:
1919
target: 70%
2020
paths:
21-
- src/codewhisperer/*
21+
- packages/core/src/codewhisperer/*
2222
flags:
2323
- 'codewhisperer'
2424
amazonqFeatureDev:
2525
target: 70%
2626
paths:
27-
- src/amazonqFeatureDev/*
27+
- packages/core/src/amazonqFeatureDev/*
2828
flags:
2929
- 'amazonqFeatureDev'
3030
patch: no

docs/arch_develop.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ Current quirks of the current monorepo status that should be resolved/evaluated
3737
- This package contains shortcuts to some of the `npm` scripts found in the subproject(s).
3838
- `createRelease` and `newChange` run at the subproject level only, e.g. from root level, try npm run createRelease -w packages/toolkit
3939
- To run a script not present in the root `package.json`, use `npm run -w packages/toolkit <script>`
40-
- `coverage/`, `.test-reports/`, `node_modules/` are hoisted to the project root. As more subprojects are added,
41-
we will need to evaluate how to merge and publish coverage reports.
40+
- `coverage/`, `.test-reports/`, `node_modules/` are hoisted to the project root.
4241
- `dist/` however remains at the subproject level, along with a local `node_modules/`. See [`npm workspaces`](https://docs.npmjs.com/cli/v8/using-npm/workspaces)
4342
for more info on how `node_modules/` hoisting works.
4443
- Because of `node_modules/` hoisting, references to this folder in code access the root project modules folder. This may be

packages/amazonq/.c8rc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"report-dir": "../../coverage/amazonq",
3+
"reporter": ["lcov"],
4+
"all": true,
5+
"include": ["src/**", "dist/src/**"],
6+
"exclude": ["dist/test/**", "src/test/**"]
7+
}

packages/core/.c8rc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"report-dir": "../../coverage",
2+
"report-dir": "../../coverage/core",
33
"reporter": ["lcov"],
44
"all": true,
55
"include": ["src/**", "dist/src/**"],

0 commit comments

Comments
 (0)