From 24c671b0fe733621c8786adeabbb6f0f17b018a6 Mon Sep 17 00:00:00 2001 From: Niranjan Jayakar Date: Tue, 16 Feb 2021 17:50:00 +0000 Subject: [PATCH] chore: update contribution guide with feature flag support for v2 (#13084) 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* --- CONTRIBUTING.md | 16 ++++++++++++++++ packages/@aws-cdk/cx-api/test/features.test.ts | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1d113183c9a67..8f26e8198abc2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/packages/@aws-cdk/cx-api/test/features.test.ts b/packages/@aws-cdk/cx-api/test/features.test.ts index fbff6c236b984..81b42773fd292 100644 --- a/packages/@aws-cdk/cx-api/test/features.test.ts +++ b/packages/@aws-cdk/cx-api/test/features.test.ts @@ -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); }); \ No newline at end of file