Skip to content

Commit

Permalink
chore(cli): integ test current version against all supported versions…
Browse files Browse the repository at this point in the history
… of TS (#23244)

We currently only test against a single TS version as defined in the init-templates. This change will run these tests against all supported TS minor versions (currently `typescript@>=3.9`). A recent change on main that broke support for >=TS4.0 went undetected due to missing these tests.

Tests are about 2min per TS version, with a total of 11 supported versions, these tests will now take 22min instead of 2min. Other actions in the same pipeline stage take 25min and over 50min (docs), so this shouldn't have an effect on total pipeline runtime.

~This PR is based off and tested with the last released version (v2.53.0), as `main` is currently not building.~

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Construct Runtime Dependencies:

* [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
mrgrain committed Dec 9, 2022
1 parent 3951f09 commit 7b7294c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/aws-cdk/test/integ/init/test-typescript-versions.sh
@@ -0,0 +1,29 @@
#!/bin/bash
#------------------------------------------------------------------
# setup
#------------------------------------------------------------------
set -eu
scriptdir=$(cd $(dirname $0) && pwd)
integdir=$(dirname $scriptdir)
source ${scriptdir}/common.bash

header TypeScript Versions

#------------------------------------------------------------------

MIN_SUPPORTED_TS_VERSION=${1:-"3.9"}
SUPPORTED_TS_VERSIONS=$(node ${integdir}/typescript-versions.js ${MIN_SUPPORTED_TS_VERSION})

for version in $SUPPORTED_TS_VERSIONS; do
echo "Testing against TypeScript v$version"

setup

cdk init -l typescript sample-app --generate-only
npm pkg delete devDependencies
npm install --save-dev typescript@$version
npm prune && npm ls
rm test/*
npm run build
cdk synth
done
10 changes: 10 additions & 0 deletions packages/aws-cdk/test/integ/typescript-versions.ts
@@ -0,0 +1,10 @@
import { spawnSync } from 'child_process';

const minSupportedVersion = process.argv.slice(2, 3);

const { stdout } = spawnSync('npm', ['--silent', 'view', `typescript@>=${minSupportedVersion}`, 'version', '--json']);

const versions: string[] = JSON.parse(stdout);
const minorVersions = Array.from(new Set(versions.map(v => v.split('.').slice(0, 2).join('.'))));

process.stdout.write(minorVersions.join(' '));

0 comments on commit 7b7294c

Please sign in to comment.