Skip to content

Commit

Permalink
chore: update contribution guide with feature flag support for v2 (#1…
Browse files Browse the repository at this point in the history
…3084)

Update how feature flags that are destined to be dropped in v2 should be
developed.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
Niranjan Jayakar authored Feb 16, 2021
1 parent b984b19 commit ca08245
Showing 2 changed files with 21 additions and 0 deletions.
16 changes: 16 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -849,6 +849,22 @@ CDK](https://github.com/aws/aws-cdk/issues/3398) we will either remove the
legacy behavior or flip the logic for all these features and then
reset the `FEATURE_FLAGS` map for the next cycle.
#### CDKv2
We have started working on the next version of the CDK, specifically CDKv2. This is currently being maintained
on a separate branch `v2-main` whereas `master` continues to track versions `1.x`.
Feature flags introduced in the CDK 1.x and removed in 2.x, must be added to the `FUTURE_FLAGS_EXPIRED` list in
[cx-api/lib/features.ts](https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/cx-api/lib/features.ts)
on the `v2-main` branch.
This will make the default behaviour in CDKv2 as if the flag is enabled and also prevents users from disabling
the feature flag.
A couple of [jest helper methods] are available for use with unit tests. These help run unit tests that test
behaviour when flags are enabled or disabled in the two major versions.
[jest helper methods]: https://github.com/aws/aws-cdk/blob/master/tools/cdk-build-tools/lib/feature-flag.ts
### Versioning and Release
The `release.json` file at the root of the repo determines which release line
5 changes: 5 additions & 0 deletions packages/@aws-cdk/cx-api/test/features.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { testLegacyBehavior } from 'cdk-build-tools/lib/feature-flag';
import * as feats from '../lib/features';

test('all future flags have defaults configured', () => {
Object.keys(feats.FUTURE_FLAGS).forEach(flag => {
expect(typeof(feats.futureFlagDefault(flag))).toEqual('boolean');
});
});

testLegacyBehavior('FUTURE_FLAGS_EXPIRED must be empty in CDKv1', Object, () => {
expect(feats.FUTURE_FLAGS_EXPIRED.length).toEqual(0);
});

0 comments on commit ca08245

Please sign in to comment.