From 1400e6f65cf8e156b8aaeddc4cb37311a37a3fc3 Mon Sep 17 00:00:00 2001 From: Kamil Sobol Date: Mon, 16 Dec 2024 15:56:30 -0800 Subject: [PATCH] Test latest cdk deeply. (#2333) * parameter * try this * try this * try this * try this * try this * try this * boop * does this work ? * try this * Comment. * try this * try this * this * Revert "this" This reverts commit 94939555559e9d7edc303fca53687b4d52a5d323. * this * this * this * more * try this * try this * try this * try this * try this * try this * try this * try this * try this * try this * try this * try this * try this * try this * try this * try this * comment * make node version required * fix that * fix that * try this * try this * try this * fix that * remove from canaries * that * that * that * try this --- .changeset/good-jokes-eat.md | 2 + .github/actions/build_with_cache/action.yml | 23 +- .github/actions/install_with_cache/action.yml | 28 +- .../actions/restore_build_cache/action.yml | 23 +- .../actions/restore_install_cache/action.yml | 20 +- .../actions/run_with_e2e_account/action.yml | 10 +- .../actions/setup_baseline_version/action.yml | 6 + .github/actions/setup_node/action.yml | 12 +- .github/workflows/canary_checks.yml | 7 +- .github/workflows/deprecate_release.yml | 10 + .github/workflows/e2e_resource_cleanup.yml | 5 + .github/workflows/health_checks.yml | 288 ++++++++++++++++-- .github/workflows/restore_release.yml | 10 + .github/workflows/snapshot_release.yml | 20 ++ .github/workflows/validate_cdk_release.yml | 30 ++ package-lock.json | 1 + packages/integration-tests/package.json | 1 + .../predicated_action_queue_builder.ts | 2 + scripts/generate_sparse_test_matrix.ts | 20 +- 19 files changed, 482 insertions(+), 36 deletions(-) create mode 100644 .changeset/good-jokes-eat.md create mode 100644 .github/workflows/validate_cdk_release.yml diff --git a/.changeset/good-jokes-eat.md b/.changeset/good-jokes-eat.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/good-jokes-eat.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/.github/actions/build_with_cache/action.yml b/.github/actions/build_with_cache/action.yml index cbe1e5a5da8..6e93905d1e1 100644 --- a/.github/actions/build_with_cache/action.yml +++ b/.github/actions/build_with_cache/action.yml @@ -2,17 +2,36 @@ name: build_with_cache description: builds the source code if cache miss and caches the result inputs: node-version: - default: 18 + required: true + cdk-version: + required: true runs: using: composite steps: + # Validate that non-blank inputs are provided. + # This is to ensure that inputs are plumbed and not defaulted accidentally in action call chains. + # The 'required' input property does not assert this if value is provided at runtime. + - name: Validate input + shell: bash + run: | + if [ -z "${{ inputs.cdk-version }}" ]; then + echo "CDK version must be provided" + exit 1; + fi + if [ -z "${{ inputs.node-version }}" ]; then + echo "Node version must be provided" + exit 1; + fi - uses: ./.github/actions/install_with_cache + with: + node-version: ${{ inputs.node-version }} + cdk-version: ${{ inputs.cdk-version }} # cache build output based on commit sha - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # version 4.0.2 id: build-cache with: path: '**/lib' - key: ${{ github.sha }}-node${{ inputs.node-version }} + key: ${{ github.sha }}-node${{ inputs.node-version }}-cdk${{ inputs.cdk-version }} enableCrossOsArchive: true # only build if cache miss - if: steps.build-cache.outputs.cache-hit != 'true' diff --git a/.github/actions/install_with_cache/action.yml b/.github/actions/install_with_cache/action.yml index e8eedf39c1a..cf2549fbb06 100644 --- a/.github/actions/install_with_cache/action.yml +++ b/.github/actions/install_with_cache/action.yml @@ -2,10 +2,26 @@ name: install_with_cache description: installs node_modules if cache miss and stores in the cache inputs: node-version: - default: 18 + required: true + cdk-version: + required: true runs: using: composite steps: + # Validate that non-blank inputs are provided. + # This is to ensure that inputs are plumbed and not defaulted accidentally in action call chains. + # The 'required' input property does not assert this if value is provided at runtime. + - name: Validate input + shell: bash + run: | + if [ -z "${{ inputs.cdk-version }}" ]; then + echo "CDK version must be provided" + exit 1; + fi + if [ -z "${{ inputs.node-version }}" ]; then + echo "Node version must be provided" + exit 1; + fi # cache node_modules based on package-lock.json hash - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # version 4.0.2 id: npm-cache @@ -13,8 +29,14 @@ runs: path: | node_modules packages/**/node_modules - key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-node${{ inputs.node-version }} + key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-node${{ inputs.node-version }}-cdk${{ inputs.cdk-version }} # only install if cache miss - if: steps.npm-cache.outputs.cache-hit != 'true' shell: bash - run: npm ci + run: | + npm ci + if [[ ${{ inputs.cdk-version }} != 'FROM_PACKAGE_LOCK' ]]; then + echo "Installing CDK version ${{ inputs.cdk-version }}" + npm install --no-save aws-cdk@${{ inputs.cdk-version }} aws-cdk-lib@${{ inputs.cdk-version }} + npx cdk --version + fi diff --git a/.github/actions/restore_build_cache/action.yml b/.github/actions/restore_build_cache/action.yml index 83adef08346..27785b4789e 100644 --- a/.github/actions/restore_build_cache/action.yml +++ b/.github/actions/restore_build_cache/action.yml @@ -3,16 +3,35 @@ description: composes restoring node_modules and restoring build artifacts inputs: node-version: description: node version used to configure environment with - default: 18 + required: true + cdk-version: + required: true runs: using: composite steps: + # Validate that non-blank inputs are provided. + # This is to ensure that inputs are plumbed and not defaulted accidentally in action call chains. + # The 'required' input property does not assert this if value is provided at runtime. + - name: Validate input + shell: bash + run: | + if [ -z "${{ inputs.cdk-version }}" ]; then + echo "CDK version must be provided" + exit 1; + fi + if [ -z "${{ inputs.node-version }}" ]; then + echo "Node version must be provided" + exit 1; + fi - uses: ./.github/actions/restore_install_cache + with: + node-version: ${{ inputs.node-version }} + cdk-version: ${{ inputs.cdk-version }} # restore build output from cache - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # version 4.0.2 id: build-cache with: path: '**/lib' - key: ${{ github.sha }}-node${{ inputs.node-version }} + key: ${{ github.sha }}-node${{ inputs.node-version }}-cdk${{ inputs.cdk-version }} fail-on-cache-miss: true enableCrossOsArchive: true diff --git a/.github/actions/restore_install_cache/action.yml b/.github/actions/restore_install_cache/action.yml index a6141cf65c1..e070d63c808 100644 --- a/.github/actions/restore_install_cache/action.yml +++ b/.github/actions/restore_install_cache/action.yml @@ -3,10 +3,26 @@ description: restores node_modules from the cache and fails if no cache entry fo inputs: node-version: description: node version used to configure environment with - default: 18 + required: true + cdk-version: + required: true runs: using: composite steps: + # Validate that non-blank inputs are provided. + # This is to ensure that inputs are plumbed and not defaulted accidentally in action call chains. + # The 'required' input property does not assert this if value is provided at runtime. + - name: Validate input + shell: bash + run: | + if [ -z "${{ inputs.cdk-version }}" ]; then + echo "CDK version must be provided" + exit 1; + fi + if [ -z "${{ inputs.node-version }}" ]; then + echo "Node version must be provided" + exit 1; + fi # restore node_modules from cache - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # version 4.0.2 id: npm-cache @@ -14,5 +30,5 @@ runs: path: | node_modules packages/**/node_modules - key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-node${{ inputs.node-version }} + key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-node${{ inputs.node-version }}-cdk${{ inputs.cdk-version }} fail-on-cache-miss: true diff --git a/.github/actions/run_with_e2e_account/action.yml b/.github/actions/run_with_e2e_account/action.yml index 5af2303bdc1..0a170e433ef 100644 --- a/.github/actions/run_with_e2e_account/action.yml +++ b/.github/actions/run_with_e2e_account/action.yml @@ -9,7 +9,7 @@ inputs: required: false node_version: description: node version used to configure environment with - required: false + required: true e2e_test_accounts: description: Serialized JSON array of strings with account numbers required: true @@ -22,6 +22,8 @@ inputs: fresh_build: description: Whether should build from scratch default: false + cdk-version: + required: true runs: using: composite steps: @@ -32,9 +34,15 @@ runs: - name: Restore Build Cache if: inputs.fresh_build != 'true' uses: ./.github/actions/restore_build_cache + with: + cdk-version: ${{ inputs.cdk-version }} + node-version: ${{ inputs.node_version }} - name: Build With Cache if: inputs.fresh_build == 'true' uses: ./.github/actions/build_with_cache + with: + cdk-version: ${{ inputs.cdk-version }} + node-version: ${{ inputs.node_version }} - name: Link CLI if: inputs.link_cli == 'true' shell: bash diff --git a/.github/actions/setup_baseline_version/action.yml b/.github/actions/setup_baseline_version/action.yml index 1594ab6dde6..7091cbd5190 100644 --- a/.github/actions/setup_baseline_version/action.yml +++ b/.github/actions/setup_baseline_version/action.yml @@ -1,5 +1,9 @@ name: setup_baseline_version description: Set up a baseline or "previous" version of the library for testing. Mostly useful for backwards compatibility +inputs: + node_version: + description: node version used to configure environment with + required: true outputs: baseline_dir: description: 'Path where baseline project directory is setup' @@ -35,6 +39,8 @@ runs: with: ref: ${{ steps.get_baseline_commit_sha.outputs.baseline_commit_sha }} - uses: ./.github/actions/setup_node + with: + node-version: ${{ inputs.node_version }} - name: Install and build baseline version shell: bash run: | diff --git a/.github/actions/setup_node/action.yml b/.github/actions/setup_node/action.yml index 8f407ee4370..d8a794f9b4c 100644 --- a/.github/actions/setup_node/action.yml +++ b/.github/actions/setup_node/action.yml @@ -4,10 +4,20 @@ name: setup_node inputs: node-version: description: node version used to configure environment with - default: 18 + required: true runs: using: composite steps: + # Validate that non-blank inputs are provided. + # This is to ensure that inputs are plumbed and not defaulted accidentally in action call chains. + # The 'required' input property does not assert this if value is provided at runtime. + - name: Validate input + shell: bash + run: | + if [ -z "${{ inputs.node-version }}" ]; then + echo "Node version must be provided" + exit 1; + fi - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # version 4.0.2 with: node-version: ${{ inputs.node-version }} diff --git a/.github/workflows/canary_checks.yml b/.github/workflows/canary_checks.yml index e534fe29c1f..af08fd3592b 100644 --- a/.github/workflows/canary_checks.yml +++ b/.github/workflows/canary_checks.yml @@ -11,6 +11,8 @@ jobs: steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - name: Install and build without lock file shell: bash run: | @@ -46,7 +48,10 @@ jobs: uses: ./.github/actions/run_with_e2e_account with: e2e_test_accounts: ${{ vars.E2E_TEST_ACCOUNTS }} - node_version: ${{ matrix.node-version }} + node_version: 18 + # Use version from package lock. Tests projects are created outside of repository root + # and are using latest CDK version. + cdk-version: FROM_PACKAGE_LOCK aws_region: ${{ matrix.region }} fresh_build: true shell: bash diff --git a/.github/workflows/deprecate_release.yml b/.github/workflows/deprecate_release.yml index 83bc4e69c73..f618695cad9 100644 --- a/.github/workflows/deprecate_release.yml +++ b/.github/workflows/deprecate_release.yml @@ -28,7 +28,12 @@ jobs: steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/install_with_cache + with: + node-version: 18 + cdk-version: FROM_PACKAGE_LOCK deprecate_release: needs: - install @@ -47,6 +52,11 @@ jobs: # fetch full history so that we can properly lookup past releases fetch-depth: 0 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_install_cache + with: + node-version: 18 + cdk-version: FROM_PACKAGE_LOCK - name: Deprecate release versions run: npx tsx scripts/deprecate_release.ts diff --git a/.github/workflows/e2e_resource_cleanup.yml b/.github/workflows/e2e_resource_cleanup.yml index ff3e7554b7e..406ac3981e7 100644 --- a/.github/workflows/e2e_resource_cleanup.yml +++ b/.github/workflows/e2e_resource_cleanup.yml @@ -24,7 +24,12 @@ jobs: steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/install_with_cache + with: + node-version: 18 + cdk-version: FROM_PACKAGE_LOCK - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2 with: diff --git a/.github/workflows/health_checks.yml b/.github/workflows/health_checks.yml index d00ef3e5144..22bc67ab861 100644 --- a/.github/workflows/health_checks.yml +++ b/.github/workflows/health_checks.yml @@ -11,13 +11,74 @@ on: - hotfix - feature/** schedule: - # Every day at At minute 0 past hour 0, 6, 12, and 18 UTC. + # Every day at minute 0 past hour 0, 6, 12, and 18 UTC. # This is to make sure that there is at least one workflow run every 24 hours # taking into account that # 1) scheduled runs may not fire at exact prescribed time; # 2) transient failures may happen and auto recover; - cron: '0 0,6,12,18 * * *' workflow_dispatch: + inputs: + desired-cdk-version: + description: 'AWS CDK version (exact or tag). Defaults to package-locked version.' + required: false + type: string + include-package-manager-e2e-tests: + description: 'Include package manager e2e tests?' + required: false + type: boolean + default: true + include-create-amplify-e2e-tests: + description: 'Include create-amplify e2e tests?' + required: false + type: boolean + default: true + include-macos: + description: 'Include MacOS?' + required: false + type: boolean + default: true + include-windows: + description: 'Include Windows?' + required: false + type: boolean + default: true + node: + description: 'Node versions list (as JSON array).' + required: false + type: string + default: '["18", "20"]' + workflow_call: + inputs: + desired-cdk-version: + description: 'AWS CDK version (exact or tag). Defaults to package-locked version.' + required: false + type: string + include-package-manager-e2e-tests: + description: 'Include package manager e2e tests?' + required: false + type: boolean + default: true + include-create-amplify-e2e-tests: + description: 'Include create-amplify e2e tests?' + required: false + type: boolean + default: true + include-macos: + description: 'Include MacOS?' + required: false + type: boolean + default: true + include-windows: + description: 'Include Windows?' + required: false + type: boolean + default: true + node: + description: 'Node versions list (as JSON array).' + required: false + type: string + default: '["18", "20"]' env: # Health checks can run on un-released code. Often work in progress. @@ -25,6 +86,49 @@ env: AMPLIFY_DISABLE_TELEMETRY: true jobs: + # This workflow may be called by variety of events. + # This steps resolves and applies appropriate defaults depending on the trigger. + resolve_inputs: + runs-on: ubuntu-latest + outputs: + cdk_version: ${{ steps.resolve_inputs.outputs.cdk_version }} + os: ${{ steps.resolve_inputs.outputs.os }} + os_for_e2e: ${{ steps.resolve_inputs.outputs.os_for_e2e }} + node: ${{ steps.resolve_inputs.outputs.node }} + steps: + - name: Resolve Inputs + id: resolve_inputs + # This is intentionally in pure bash to make this job independent of repo checkout and fast. + run: | + if [ -z "${{ inputs.desired-cdk-version }}" ]; then + echo "cdk_version=FROM_PACKAGE_LOCK" >> "$GITHUB_OUTPUT" + else + echo "cdk_version=$(npm view aws-cdk@${{ inputs.desired-cdk-version }} version)" >> "$GITHUB_OUTPUT" + fi + # Build JSON array in readable way in bash... + os='["ubuntu-latest"' + os_for_e2e='["ubuntu-latest"' + if [ "${{ inputs.include-macos }}" != "false" ]; then + os+=', "macos-14"' + os_for_e2e+=', "macos-14-xlarge"' + fi + if [ "${{ inputs.include-windows }}" != "false" ]; then + os+=', "windows-latest"' + os_for_e2e+=', "windows-latest"' + fi + os+=']' + os_for_e2e+=']' + echo "os=$os" >> "$GITHUB_OUTPUT" + echo "os_for_e2e=$os_for_e2e" >> "$GITHUB_OUTPUT" + if [ -z "${{ inputs.node }}" ]; then + echo 'node=["18", "20"]' >> "$GITHUB_OUTPUT" + else + echo 'node=${{ inputs.node }}' >> "$GITHUB_OUTPUT" + fi + - run: echo cdk_version set to ${{ steps.resolve_inputs.outputs.cdk_version }} + - run: echo os set to ${{ steps.resolve_inputs.outputs.os }} + - run: echo os_for_e2e set to ${{ steps.resolve_inputs.outputs.os_for_e2e }} + - run: echo node set to ${{ steps.resolve_inputs.outputs.node }} install: strategy: matrix: @@ -32,9 +136,15 @@ jobs: # Larger workers use different drive (C: instead of D:) to check out project and NPM installation # creates file system links that include drive letter. # Changing between standard and custom workers requires full install cache invalidation - os: [ubuntu-latest, macos-14, windows-latest] - node: [18, 20] + os: ${{ fromJSON(needs.resolve_inputs.outputs.os) }} + node: ${{ fromJSON(needs.resolve_inputs.outputs.node) }} + # Always include Node 18 and Ubuntu. Non-testing jobs depend on it. + include: + - os: ubuntu-latest + node: 18 runs-on: ${{ matrix.os }} + needs: + - resolve_inputs timeout-minutes: 10 steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 @@ -44,13 +154,18 @@ jobs: - uses: ./.github/actions/install_with_cache with: node-version: ${{ matrix.node }} + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} build: strategy: matrix: - node: [18, 20] + node: ${{ fromJSON(needs.resolve_inputs.outputs.node) }} + # Always include Node 18. Non-testing jobs depend on it. + include: + - node: 18 runs-on: ubuntu-latest needs: - install + - resolve_inputs steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node @@ -59,13 +174,15 @@ jobs: - uses: ./.github/actions/build_with_cache with: node-version: ${{ matrix.node }} + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} test_with_coverage: needs: - build + - resolve_inputs strategy: matrix: - os: [ubuntu-latest, macos-14, windows-latest] - node: [18, 20] + os: ${{ fromJSON(needs.resolve_inputs.outputs.os) }} + node: ${{ fromJSON(needs.resolve_inputs.outputs.node) }} runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 @@ -75,27 +192,40 @@ jobs: - uses: ./.github/actions/restore_build_cache with: node-version: ${{ matrix.node }} + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} - run: npm run set-script-shell - run: npm run test:coverage:threshold test_scripts: needs: - build + - resolve_inputs runs-on: ubuntu-latest steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_build_cache + with: + node-version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} - run: | npm run set-script-shell npm run test:scripts test_with_baseline_dependencies: needs: - install + - resolve_inputs runs-on: ubuntu-latest steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_install_cache + with: + node-version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} - name: Pin some dependencies to nearest patch and rebuild run: | npx tsx scripts/set_baseline_dependency_versions.ts @@ -111,13 +241,19 @@ jobs: if: github.event_name == 'pull_request' needs: - build + - resolve_inputs runs-on: ubuntu-latest timeout-minutes: 10 steps: - name: Checkout pull request ref uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_build_cache + with: + node-version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} - name: Publish packages locally timeout-minutes: 2 run: | @@ -136,6 +272,7 @@ jobs: do_include_e2e: needs: - install + - resolve_inputs runs-on: ubuntu-latest permissions: # This is required so that the step can read the labels on the pull request @@ -145,14 +282,39 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} outputs: run_e2e: ${{ steps.check.outputs.run_e2e }} + include_package_manager_e2e: ${{ steps.check_package_manager.outputs.include_package_manager_e2e }} + include_create_amplify_e2e: ${{ steps.check_create_amplify.outputs.include_create_amplify_e2e }} steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_install_cache - - name: Check if E2E tests should run + with: + node-version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} + - name: Check if any E2E tests should run id: check run: echo "run_e2e=$(npx tsx scripts/do_include_e2e.ts)" >> "$GITHUB_OUTPUT" - run: echo run_e2e set to ${{ steps.check.outputs.run_e2e }} + - name: Check if Package Manager E2E tests should be included + id: check_package_manager + run: | + if [ -z "${{ inputs.include-package-manager-e2e-tests }}" ]; then + echo "include_package_manager_e2e=true" >> "$GITHUB_OUTPUT" + else + echo "include_package_manager_e2e=${{ inputs.include-package-manager-e2e-tests }}" >> "$GITHUB_OUTPUT" + fi + - run: echo include_package_manager_e2e set to ${{ steps.check_package_manager.outputs.include_package_manager_e2e }} + - name: Check if Create Amplify E2E tests should be included + id: check_create_amplify + run: | + if [ -z "${{ inputs.include-create-amplify-e2e-tests }}" ]; then + echo "include_create_amplify_e2e=true" >> "$GITHUB_OUTPUT" + else + echo "include_create_amplify_e2e=${{ inputs.include-create-amplify-e2e-tests }}" >> "$GITHUB_OUTPUT" + fi + - run: echo include_create_amplify_e2e set to ${{ steps.check_create_amplify.outputs.include_create_amplify_e2e }} e2e_iam_access_drift: if: needs.do_include_e2e.outputs.run_e2e == 'true' runs-on: ubuntu-latest @@ -160,6 +322,7 @@ jobs: needs: - do_include_e2e - build + - resolve_inputs permissions: # these permissions are required for the configure-aws-credentials action to get a JWT from GitHub id-token: write @@ -172,13 +335,16 @@ jobs: - name: Setup baseline version uses: ./.github/actions/setup_baseline_version id: setup_baseline_version + with: + node_version: 18 - name: Checkout current version uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - name: Run e2e iam access drift test uses: ./.github/actions/run_with_e2e_account with: e2e_test_accounts: ${{ vars.E2E_TEST_ACCOUNTS }} - node_version: ${{ matrix.node-version }} + node_version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} run: npm run test:dir packages/integration-tests/lib/test-e2e/iam_access_drift.test.js env: BASELINE_DIR: ${{ steps.setup_baseline_version.outputs.baseline_dir }} @@ -189,6 +355,7 @@ jobs: needs: - do_include_e2e - build + - resolve_inputs permissions: # these permissions are required for the configure-aws-credentials action to get a JWT from GitHub id-token: write @@ -201,13 +368,16 @@ jobs: - name: Setup baseline version uses: ./.github/actions/setup_baseline_version id: setup_baseline_version + with: + node_version: 18 - name: Checkout current version uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - name: Run e2e amplify outputs backwards compatibility test uses: ./.github/actions/run_with_e2e_account with: e2e_test_accounts: ${{ vars.E2E_TEST_ACCOUNTS }} - node_version: ${{ matrix.node-version }} + node_version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} run: npm run test:dir packages/integration-tests/lib/test-e2e/amplify_outputs_backwards_compatibility.test.js env: BASELINE_DIR: ${{ steps.setup_baseline_version.outputs.baseline_dir }} @@ -220,12 +390,16 @@ jobs: needs: - do_include_e2e - build + - resolve_inputs steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/restore_build_cache - - run: echo "$(npx tsx scripts/generate_sparse_test_matrix.ts 'packages/integration-tests/lib/test-e2e/deployment/*.deployment.test.js')" + with: + node-version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} + - run: echo "$(npx tsx scripts/generate_sparse_test_matrix.ts 'packages/integration-tests/lib/test-e2e/deployment/*.deployment.test.js' '${{ needs.resolve_inputs.outputs.node }}' '${{ needs.resolve_inputs.outputs.os_for_e2e }}')" - id: generateMatrix - run: echo "matrix=$(npx tsx scripts/generate_sparse_test_matrix.ts 'packages/integration-tests/lib/test-e2e/deployment/*.deployment.test.js')" >> "$GITHUB_OUTPUT" + run: echo "matrix=$(npx tsx scripts/generate_sparse_test_matrix.ts 'packages/integration-tests/lib/test-e2e/deployment/*.deployment.test.js' '${{ needs.resolve_inputs.outputs.node }}' '${{ needs.resolve_inputs.outputs.os_for_e2e }}')" >> "$GITHUB_OUTPUT" e2e_deployment: if: needs.do_include_e2e.outputs.run_e2e == 'true' strategy: @@ -239,6 +413,7 @@ jobs: - do_include_e2e - build - e2e_generate_deployment_tests_matrix + - resolve_inputs permissions: # these permissions are required for the configure-aws-credentials action to get a JWT from GitHub id-token: write @@ -250,6 +425,7 @@ jobs: with: e2e_test_accounts: ${{ vars.E2E_TEST_ACCOUNTS }} node_version: ${{ matrix.node-version }} + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} link_cli: true run: | npm run test:dir ${{ matrix.testPaths }} @@ -262,12 +438,16 @@ jobs: needs: - do_include_e2e - build + - resolve_inputs steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/restore_build_cache - - run: echo "$(npx tsx scripts/generate_sparse_test_matrix.ts 'packages/integration-tests/lib/test-e2e/sandbox/*.sandbox.test.js')" + with: + node-version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} + - run: echo "$(npx tsx scripts/generate_sparse_test_matrix.ts 'packages/integration-tests/lib/test-e2e/sandbox/*.sandbox.test.js' '${{ needs.resolve_inputs.outputs.node }}' '${{ needs.resolve_inputs.outputs.os_for_e2e }}')" - id: generateMatrix - run: echo "matrix=$(npx tsx scripts/generate_sparse_test_matrix.ts 'packages/integration-tests/lib/test-e2e/sandbox/*.sandbox.test.js')" >> "$GITHUB_OUTPUT" + run: echo "matrix=$(npx tsx scripts/generate_sparse_test_matrix.ts 'packages/integration-tests/lib/test-e2e/sandbox/*.sandbox.test.js' '${{ needs.resolve_inputs.outputs.node }}' '${{ needs.resolve_inputs.outputs.os_for_e2e }}')" >> "$GITHUB_OUTPUT" e2e_sandbox: if: needs.do_include_e2e.outputs.run_e2e == 'true' strategy: @@ -281,6 +461,7 @@ jobs: - do_include_e2e - build - e2e_generate_sandbox_tests_matrix + - resolve_inputs permissions: # these permissions are required for the configure-aws-credentials action to get a JWT from GitHub id-token: write @@ -292,6 +473,7 @@ jobs: with: e2e_test_accounts: ${{ vars.E2E_TEST_ACCOUNTS }} node_version: ${{ matrix.node-version }} + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} link_cli: true run: npm run test:dir ${{ matrix.testPaths }} e2e_backend_output: @@ -301,6 +483,7 @@ jobs: needs: - do_include_e2e - build + - resolve_inputs permissions: # these permissions are required for the configure-aws-credentials action to get a JWT from GitHub id-token: write @@ -311,17 +494,18 @@ jobs: uses: ./.github/actions/run_with_e2e_account with: e2e_test_accounts: ${{ vars.E2E_TEST_ACCOUNTS }} - node_version: ${{ matrix.node-version }} + node_version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} link_cli: true run: npm run test:dir packages/integration-tests/lib/test-e2e/backend_output.test.js e2e_create_amplify: - if: needs.do_include_e2e.outputs.run_e2e == 'true' + if: needs.do_include_e2e.outputs.run_e2e == 'true' && needs.do_include_e2e.outputs.include_create_amplify_e2e == 'true' strategy: # will finish running other test matrices even if one fails fail-fast: false matrix: - os: [ubuntu-latest, macos-14, windows-latest] - node-version: [18, 20] + os: ${{ fromJSON(needs.resolve_inputs.outputs.os) }} + node-version: ${{ fromJSON(needs.resolve_inputs.outputs.node) }} # skip multiple node version test on other os exclude: - os: macos-14 @@ -333,22 +517,26 @@ jobs: needs: - do_include_e2e - build + - resolve_inputs steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node with: node-version: ${{ matrix.node-version }} - uses: ./.github/actions/restore_build_cache + with: + node-version: ${{ matrix.node-version }} + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} - run: cd packages/cli && npm link - name: Run e2e create-amplify tests run: npm run test:dir packages/integration-tests/lib/test-e2e/create_amplify.test.js e2e_package_manager: - if: needs.do_include_e2e.outputs.run_e2e == 'true' + if: needs.do_include_e2e.outputs.run_e2e == 'true' && needs.do_include_e2e.outputs.include_package_manager_e2e == 'true' strategy: # will finish running other test matrices even if one fails fail-fast: false matrix: - os: [ubuntu-latest, macos-14, windows-latest] + os: ${{ fromJSON(needs.resolve_inputs.outputs.os) }} pkg-manager: [npm, yarn-classic, yarn-modern, pnpm] node-version: ['20'] env: @@ -358,6 +546,7 @@ jobs: needs: - build - do_include_e2e + - resolve_inputs permissions: # these permissions are required for the configure-aws-credentials action to get a JWT from GitHub id-token: write @@ -370,6 +559,7 @@ jobs: with: e2e_test_accounts: ${{ vars.E2E_TEST_ACCOUNTS }} node_version: ${{ matrix.node-version }} + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} shell: bash run: | PACKAGE_MANAGER=${{matrix.pkg-manager}} npm run test:dir packages/integration-tests/src/package_manager_sanity_checks.test.ts @@ -377,46 +567,76 @@ jobs: runs-on: ubuntu-latest needs: - build + - resolve_inputs steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_build_cache + with: + node-version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} - run: npm run lint check_dependencies: runs-on: ubuntu-latest needs: - install + - resolve_inputs steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_install_cache + with: + node-version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} - run: npm run check:dependencies check_tsconfig_refs: runs-on: ubuntu-latest needs: - install + - resolve_inputs steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_install_cache + with: + node-version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} - run: npm run check:tsconfig-refs check_api_extract: runs-on: ubuntu-latest needs: - build + - resolve_inputs steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_build_cache + with: + node-version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} - run: npm run check:api docs_build_and_publish: runs-on: ubuntu-latest needs: - build + - resolve_inputs steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_build_cache + with: + node-version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} - run: npm run docs - if: ${{ github.event_name == 'push' && github.ref_name == 'main' }} uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # version 4.0.0 @@ -429,10 +649,16 @@ jobs: runs-on: ubuntu-latest needs: - install + - resolve_inputs steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_install_cache + with: + node-version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} - run: git fetch origin - run: npm run diff:check "$BASE_SHA" env: @@ -442,13 +668,19 @@ jobs: runs-on: ubuntu-latest needs: - install + - resolve_inputs steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 with: # fetch full history so that changeset can properly compute divergence point fetch-depth: 0 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_install_cache + with: + node-version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} - name: Validate that PR has changeset run: npx changeset status --since origin/"$BASE_REF" env: @@ -468,10 +700,16 @@ jobs: timeout-minutes: 10 needs: - install + - resolve_inputs steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_install_cache + with: + node-version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} - run: npx changeset version - run: npm run check:package-versions @@ -479,11 +717,17 @@ jobs: if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'hotfix') }} needs: - install + - resolve_inputs runs-on: ubuntu-latest steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_install_cache + with: + node-version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} - id: is_version_packages_commit run: echo "is_version_packages_commit=$(npx tsx scripts/is_version_packages_commit.ts)" >> "$GITHUB_OUTPUT" - name: Create or update Version Packages PR @@ -506,11 +750,17 @@ jobs: - e2e_deployment - e2e_sandbox - e2e_create_amplify + - resolve_inputs runs-on: ubuntu-latest steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_build_cache + with: + node-version: 18 + cdk-version: ${{ needs.resolve_inputs.outputs.cdk_version }} - id: is_version_packages_commit run: echo "is_version_packages_commit=$(npx tsx scripts/is_version_packages_commit.ts)" >> "$GITHUB_OUTPUT" - name: Publish packages diff --git a/.github/workflows/restore_release.yml b/.github/workflows/restore_release.yml index 403c9d84a61..219b33692df 100644 --- a/.github/workflows/restore_release.yml +++ b/.github/workflows/restore_release.yml @@ -24,7 +24,12 @@ jobs: steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/install_with_cache + with: + node-version: 18 + cdk-version: FROM_PACKAGE_LOCK restore_release: needs: - install @@ -42,6 +47,11 @@ jobs: # fetch full history so that we can properly lookup past releases fetch-depth: 0 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_install_cache + with: + node-version: 18 + cdk-version: FROM_PACKAGE_LOCK - name: Restore release versions run: npx tsx scripts/restore_release.ts diff --git a/.github/workflows/snapshot_release.yml b/.github/workflows/snapshot_release.yml index 048c06de062..4f5b5a22e8a 100644 --- a/.github/workflows/snapshot_release.yml +++ b/.github/workflows/snapshot_release.yml @@ -9,7 +9,12 @@ jobs: steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/install_with_cache + with: + node-version: 18 + cdk-version: FROM_PACKAGE_LOCK build: runs-on: ubuntu-latest needs: @@ -17,7 +22,12 @@ jobs: steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/build_with_cache + with: + node-version: 18 + cdk-version: FROM_PACKAGE_LOCK test: needs: - build @@ -25,7 +35,12 @@ jobs: steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_build_cache + with: + node-version: 18 + cdk-version: FROM_PACKAGE_LOCK - run: npm run set-script-shell - run: npm run test publish_snapshot: @@ -35,7 +50,12 @@ jobs: steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4 - uses: ./.github/actions/setup_node + with: + node-version: 18 - uses: ./.github/actions/restore_build_cache + with: + node-version: 18 + cdk-version: FROM_PACKAGE_LOCK - name: Authenticate run: | echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc diff --git a/.github/workflows/validate_cdk_release.yml b/.github/workflows/validate_cdk_release.yml new file mode 100644 index 00000000000..d54707ef0b2 --- /dev/null +++ b/.github/workflows/validate_cdk_release.yml @@ -0,0 +1,30 @@ +name: validate_cdk_release + +on: + schedule: + # Every day at 16:00 UTC (8:00 PST) and 18:00 UTC (10:00 PST) + # So that it produces at least 2 data points daily. + - cron: '0 16,18 * * *' + workflow_dispatch: + inputs: + desired-cdk-version: + description: 'AWS CDK version (exact or tag). Defaults to latest version.' + required: false + type: string + +jobs: + health_checks_with_cdk_version: + uses: ./.github/workflows/health_checks.yml + secrets: inherit + with: + # This runs all deployment and sandbox tests. + desired-cdk-version: ${{ inputs.desired-cdk-version || 'latest' }} + # Exclude additional runtimes. + # They don't bring much value, but may bring instability and extra latency. + include-macos: false + include-windows: false + node: '["18"]' + # Exclude package manager and create-amplify tests. + # They don't bring functional coverage for CDK usage patterns. + include-package-manager-e2e-tests: false + include-create-amplify-e2e-tests: false diff --git a/package-lock.json b/package-lock.json index c3fe5324670..21a75c93778 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32828,6 +32828,7 @@ "node-fetch": "^3.3.2", "semver": "^7.6.3", "ssh2": "^1.15.0", + "strip-ansi": "^6.0.1", "uuid": "^9.0.1" } }, diff --git a/packages/integration-tests/package.json b/packages/integration-tests/package.json index 576363de098..2a60ce15446 100644 --- a/packages/integration-tests/package.json +++ b/packages/integration-tests/package.json @@ -43,6 +43,7 @@ "node-fetch": "^3.3.2", "semver": "^7.6.3", "ssh2": "^1.15.0", + "strip-ansi": "^6.0.1", "uuid": "^9.0.1" }, "license": "Apache-2.0" diff --git a/packages/integration-tests/src/process-controller/predicated_action_queue_builder.ts b/packages/integration-tests/src/process-controller/predicated_action_queue_builder.ts index 6b0e3572ab5..06429df8290 100644 --- a/packages/integration-tests/src/process-controller/predicated_action_queue_builder.ts +++ b/packages/integration-tests/src/process-controller/predicated_action_queue_builder.ts @@ -5,6 +5,7 @@ import { } from './predicated_action.js'; import os from 'os'; import fs from 'fs/promises'; +import stripANSI from 'strip-ansi'; import { killExecaProcess } from './execa_process_killer.js'; import { ExecaMethod } from 'execa'; @@ -92,6 +93,7 @@ export class PredicatedActionBuilder { action: (strWithDeploymentTime: string) => { // the time can be in fractional or whole seconds. 24.3, 24, 24.22 etc. const regex = /^✨ {2}Total time: (\d*\.*\d*)s.*$/; + strWithDeploymentTime = stripANSI(strWithDeploymentTime); const deploymentTime = strWithDeploymentTime.match(regex); if ( deploymentTime && diff --git a/scripts/generate_sparse_test_matrix.ts b/scripts/generate_sparse_test_matrix.ts index c5a76eb9654..0f2c9ffb541 100644 --- a/scripts/generate_sparse_test_matrix.ts +++ b/scripts/generate_sparse_test_matrix.ts @@ -4,14 +4,16 @@ import { SparseTestMatrixGenerator } from './components/sparse_test_matrix_gener // Every test must run on each type of OS and each version of node. // However, we don't have to run every combination. -if (process.argv.length < 3) { +if (process.argv.length < 5) { console.log( - "Usage: npx tsx scripts/generate_sparse_test_matrix.ts '' " + "Usage: npx tsx scripts/generate_sparse_test_matrix.ts '' '' '' " ); } const testGlobPattern = process.argv[2]; -const maxTestsPerJob = process.argv[3] ? parseInt(process.argv[3]) : 2; +const nodeVersions = JSON.parse(process.argv[3]) as Array; +let os = JSON.parse(process.argv[4]) as Array; +const maxTestsPerJob = process.argv[5] ? parseInt(process.argv[5]) : 2; if (!Number.isInteger(maxTestsPerJob)) { throw new Error( @@ -19,12 +21,20 @@ if (!Number.isInteger(maxTestsPerJob)) { ); } +os = os.map((entry) => { + if (entry === 'macos-14') { + // replace with large. + return 'macos-14-xlarge'; + } + return entry; +}); + const matrix = await new SparseTestMatrixGenerator({ testGlobPattern, maxTestsPerJob, dimensions: { - 'node-version': ['18', '20'], - os: ['ubuntu-latest', 'macos-14-xlarge', 'windows-latest'], + 'node-version': nodeVersions, + os, }, }).generate();