Skip to content

Conversation

@iankhou
Copy link
Contributor

@iankhou iankhou commented Apr 1, 2025

Fixes #367

Uses projen to generate the api-extractor config.

Adds api-extractor JSON output and .md files to the S3 bucket for docs during release.

Does not affect the existing TypeDoc site workflow.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@iankhou iankhou requested a review from rix0rrr April 1, 2025 18:24
@iankhou iankhou self-assigned this Apr 1, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team April 1, 2025 18:24
@github-actions github-actions bot added the p2 label Apr 1, 2025
@codecov-commenter
Copy link

codecov-commenter commented Apr 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.55%. Comparing base (d21e66e) to head (bbbedb9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #303      +/-   ##
==========================================
+ Coverage   85.49%   85.55%   +0.06%     
==========================================
  Files         219      219              
  Lines       24103    24103              
  Branches     2585     2594       +9     
==========================================
+ Hits        20607    20622      +15     
+ Misses       3445     3428      -17     
- Partials       51       53       +2     
Flag Coverage Δ
suite.unit 85.55% <ø> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

const apiExtractorDocsTask = project.addTask('api-extractor-docs', {
exec: [
// Ensure API Extractor is installed
'npm install -g @microsoft/api-extractor || true',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use a global install, just add it as devDep

// Ensure API Extractor is installed
'npm install -g @microsoft/api-extractor || true',
// Run api-extractor to generate the API model
// Use || true to ensure the task continues even if api-extractor reports failures
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems counter intuitive? Why continue on failure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api-extractor will still output a file when there are certain failures. Will work on fixing the underlying issue, but I did this to temporarily unblock it.

Copy link
Contributor Author

@iankhou iankhou Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below that, we check whether the file was outputted instead of relying on api-extractor to reliably report an error.

'if [ -f dist/toolkit-lib.api.json ]; then cp dist/toolkit-lib.api.json dist/api-extractor-docs/cdk/api/toolkit-lib/; else echo "Warning: API JSON file not found"; fi',
// Add version file
'(cat dist/version.txt || echo "latest") > dist/api-extractor-docs/cdk/api/toolkit-lib/VERSION',
// Find and copy all markdown files (excluding node_modules)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reckon we can limit this to all files in the docs directory and README.md

You will probably want all files because we might have images.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, that makes sense to me. I was thinking we might have .md files in subdirectories, but if that isn't the case, then we won't need anything outside of docs and README.md. And will include all file types.


const safeName = this.project.name.replace('@', '').replace('/', '-');

releaseWf.addJob(`${safeName}_release_api_extractor_docs`, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a replication of the S3 docs workflow. Let's refactor that code to be reusable and support both uploads

"docModel": {
"enabled": true,
"apiJsonFilePath": "./dist/<unscopedPackageName>.api.json",
"projectFolderUrl": "https://github.com/aws/aws-cdk-cli"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this?

Suggested change
"projectFolderUrl": "https://github.com/aws/aws-cdk-cli"
"projectFolderUrl": "https://github.com/aws/aws-cdk-cli/tree/main/packages/%40aws-cdk/toolkit-lib"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change it to this.

mrgrain
mrgrain previously requested changes Apr 2, 2025
Copy link
Contributor

@mrgrain mrgrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments

@iankhou iankhou requested a review from mrgrain April 2, 2025 14:48
@iankhou iankhou force-pushed the iankhou-api-extractor branch from bacdfda to bbbedb9 Compare April 6, 2025 17:49
@iankhou iankhou temporarily deployed to integ-approval April 6, 2025 17:49 — with GitHub Actions Inactive
@iankhou iankhou requested review from Copilot and removed request for mrgrain April 6, 2025 17:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 4 out of 11 changed files in this pull request and generated no comments.

Files not reviewed (7)
  • packages/@aws-cdk/toolkit-lib/.gitattributes: Language not supported
  • packages/@aws-cdk/toolkit-lib/.gitignore: Language not supported
  • packages/@aws-cdk/toolkit-lib/.projen/deps.json: Language not supported
  • packages/@aws-cdk/toolkit-lib/.projen/files.json: Language not supported
  • packages/@aws-cdk/toolkit-lib/.projen/tasks.json: Language not supported
  • packages/@aws-cdk/toolkit-lib/api-extractor.json: Language not supported
  • packages/@aws-cdk/toolkit-lib/package.json: Language not supported
Comments suppressed due to low confidence (3)

projenrc/s3-docs-publishing.ts:100

  • [nitpick] Consider extracting the computed role-session-name into a constant to reduce duplication across steps and mitigate potential inconsistencies.
role-session-name: `s3-${isApiExtractor ? 'api-' : ''}docs-publishing@aws-cdk-cli`

.github/workflows/release.yml:1219

  • [nitpick] The S3_PATH is hardcoded for the API Extractor artifact and does not use the dynamic naming logic from S3DocsPublishing; consider aligning these values for consistency.
S3_PATH="$DOCS_STREAM/aws-cdk-toolkit-lib-api-model-v$(cat dist/version.txt).zip"

.projenrc.ts:1057

  • Using '|| true' after running api-extractor may suppress critical error output; verify that this handling is intentional and that errors aren’t being inadvertently masked.
'api-extractor run --diagnostics || true'

@iankhou iankhou requested review from a team and removed request for a team April 6, 2025 17:52
@iankhou iankhou added the pr/exempt-integ-test Skips the integ test steps if set. label Apr 6, 2025
@iankhou iankhou removed the pr/exempt-integ-test Skips the integ test steps if set. label Apr 6, 2025
@iankhou iankhou dismissed mrgrain’s stale review April 7, 2025 14:15

OOTO, changes addressed.

@aws-cdk-automation aws-cdk-automation added this pull request to the merge queue Apr 7, 2025
Merged via the queue into main with commit 4771ed8 Apr 7, 2025
25 checks passed
@aws-cdk-automation aws-cdk-automation deleted the iankhou-api-extractor branch April 7, 2025 14:23
@github-actions
Copy link

Total lines changed 1870 is greater than 1000. Please consider breaking this PR down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upload api-extractor output for static site generation

5 participants