Commit a9d5b84
fix(cli): use caret version for aws-cdk-lib in init templates (#1002)
Fixes #946 - more or less.
The `cdk init` command generates `package.json` files with a pinned
`aws-cdk-lib` version (e.g., `"2.232.2"`), which prevents users from
updating the library using `npm update`. This change adds a caret prefix
(`^`) to the version, allowing semver-compatible updates while still
ensuring compatibility.
Additionally, this PR separates the `aws-cdk-lib` upgrade from the
regular dependency upgrade workflow. This allows us to track
`aws-cdk-lib` updates independently and ensures the init templates
always reference a recent version. There's no guarantee that these
updates are merged more often (they still need to pass integ tests), but
being decoupled from other updates they are much less likely to fail.
## Why this is safe
The main question is if we are still testing what we are releasing.
Specifically adding the `^` caret has to consequences:
- pre release versions are only matched exactly (the `^`) is ignored, we
use pre-release versions in our integ tests
- when a new version of `aws-cdk-lib` is released, can we ensure we have
tested this combination of Toolkit and Construct Lib
### Tests in this repo
We are already running all our `cdk init` tests against the latest
version of `aws-cdk-lib`.
This is done by finding the latest version:
https://github.com/aws/aws-cdk-cli/blob/af211ad102643f752caad307b6ec1e74ba93680e/.github/workflows/integ.yml#L107
which then ends up being explicitly requested as part of `cdk init`:
https://github.com/aws/aws-cdk-cli/blob/af211ad102643f752caad307b6ec1e74ba93680e/packages/@aws-cdk-testing/cli-integ/tests/init-fsharp/init-fsharp.integtest.ts#L10
There is therefore no change in testing coverage.
We do however default `cdk init` to a fixed, "known good" version. This
version is not actively tested, but can be assumed "good" because it
would have been the latest version at the time of the upgrade PR (and
therefore tested). **This assumption is actually incorrect.** Upgrade
PRs are created/updated weekly, but need to be manually approved to run
integ tests. In the time the PR was created and tests run, a new version
could have been released. Thus we could be merging a `aws-cdk-lib`
version (and consequently a `cdk init` default) that is not actually
tested. It is however reasonable to declare that if a later versions
works, previous versions will work as well.
This leaves us with `aws-cdk-lib` releasing new versions.
### Tests in `aws/aws-cdk`
As part of our release pipeline we are explicitly testing the release
candidate with the full proposed version, e.g. `2.123.0`. This version
is staged in a private articat repository instead of npmjs.com.
Otherwise the `cdk init` tests behave exactly the same as in this repo
(duh, it's the same code): The version is explicitly requested as part
of the `init` command. **This means that no version of `aws-cdk-lib` is
released without passing init template tests.** In turn this means that
it's safe to include the `^` because any future version will only be
released if it passes.
### Continuous checks ("canaries")
Similar to the other tests, our continuous canary checks will explicitly
install the latest available version. So in addition to the previous
assertions, we also have ongoing checks that the latest version of
`aws-cdk-lib` works.
---
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license
---------
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>1 parent af211ad commit a9d5b84
File tree
15 files changed
+162
-11
lines changed- .github/workflows
- .projen
- packages
- @aws-cdk/toolkit-lib/lib/util
- aws-cdk
- .projen
- lib
- commands/init
- init-templates
- app
- go
- python
- sample-app
- go
- python
15 files changed
+162
-11
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1175 | 1175 | | |
1176 | 1176 | | |
1177 | 1177 | | |
| 1178 | + | |
1178 | 1179 | | |
1179 | 1180 | | |
1180 | 1181 | | |
| |||
1234 | 1235 | | |
1235 | 1236 | | |
1236 | 1237 | | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
1237 | 1252 | | |
1238 | 1253 | | |
1239 | 1254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
568 | 568 | | |
569 | 569 | | |
570 | 570 | | |
571 | | - | |
572 | 571 | | |
| 572 | + | |
573 | 573 | | |
574 | 574 | | |
575 | 575 | | |
576 | 576 | | |
577 | 577 | | |
578 | 578 | | |
| 579 | + | |
579 | 580 | | |
580 | 581 | | |
581 | 582 | | |
| 583 | + | |
582 | 584 | | |
583 | 585 | | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
584 | 590 | | |
585 | 591 | | |
586 | 592 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
0 commit comments