Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: record CLI version in manifest package #184

Merged
merged 18 commits into from
Mar 7, 2025

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Mar 3, 2025

Record the current CLI version in the manifest package when we release the manifest.

This by itself will not trigger a new release of the cloud-assembly-schema package, so the version only gets recorded (and published!) when there is a new version of cloud-assembly-schema to publish anyway, and the version will only be displayed back to the user if there is an incompatibility of the major version number.

That means we won't necessarily show the lowest possible CLI version number when the user needs to upgrade, but we'll show a valid CLI version number that will definitely support the given manifest.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

rix0rrr added 2 commits March 3, 2025 13:03
Record the current CLI version in the manifest package when we release
the manifest. This will have the effect of recording the CLI version
that supports a given manifest version.
@rix0rrr rix0rrr requested a review from a team March 3, 2025 12:34
@aws-cdk-automation aws-cdk-automation requested a review from a team March 3, 2025 12:34
@github-actions github-actions bot added the p2 label Mar 3, 2025
@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.09%. Comparing base (a6d4516) to head (9214af2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #184      +/-   ##
==========================================
- Coverage   85.36%   85.09%   -0.27%     
==========================================
  Files         207      207              
  Lines       35816    35837      +21     
  Branches     4663     4625      -38     
==========================================
- Hits        30575    30497      -78     
- Misses       5084     5190     +106     
+ Partials      157      150       -7     
Flag Coverage Δ
suite.unit 85.09% <100.00%> (-0.27%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines 15 to 26
const releaseTask = this.project.tasks.tryFind(this.props.taskName);
if (!releaseTask) {
throw new Error(`Did not find task ${this.props.taskName}`);
}

// Find the bump task, and do the CLI version copy straight after
const bumpIx = releaseTask.steps.findIndex(s => s.exec === this.props.beforeExec);
if (bumpIx === -1) {
throw new Error(`Did not find step: ${this.props.beforeExec}`);
}

releaseTask.steps.splice(bumpIx, 0, ...this.props.insertSteps);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable names here are not reflecting the generic task

.projenrc.ts Outdated
insertSteps: [
{ exec: 'ts-node projenrc/copy-cli-version-to-assembly.task.ts' },
],
beforeExec: 'yarn workspaces run build',
Copy link
Contributor

@iliapolo iliapolo Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest making the necessary changes to InsertTaskStep so that invoking it eventually looks like this:

Suggested change
beforeExec: 'yarn workspaces run build',
afterExec: 'yarn workspaces run bump',

Since the bump task is our "dependency" here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had that first but I find a "before" much more natural for an "insert" operation.

Also, yes it has to be after bump, but it also equally has to be before build, so both make sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had that first but I find a "before" much more natural for an "insert" operation.

hh so call it AppendTaskStep :)

Its fine. just a personal preference.

.projenrc.ts Outdated
@@ -374,11 +375,24 @@ new JsiiBuild(cloudAssemblySchema, {
(() => {
cloudAssemblySchema.preCompileTask.exec('tsx projenrc/update.ts');

// This file will be generated at release time. It needs to be gitignored or it will
// fail projen's "no tamper" check, which means it must also be generated every build time.
cloudAssemblySchema.preCompileTask.exec('[[ -f cli-version.json ]] || echo \'{ "version": "" }\' > cli-version.json');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not call the same copy-cli-version-to-assembly.task.ts script and have it create the empty file in case the version is 0.0.0? Just trying to minimize bash.

@rix0rrr rix0rrr temporarily deployed to integ-approval March 7, 2025 11:17 — with GitHub Actions Inactive
@@ -0,0 +1,24 @@
import { promises as fs } from 'fs';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just FYI, not sure which is better

Suggested change
import { promises as fs } from 'fs';
import * fs from 'fs/promises';

Signed-off-by: github-actions <github-actions@github.com>
Signed-off-by: github-actions <github-actions@github.com>
@aws-cdk-automation aws-cdk-automation added this pull request to the merge queue Mar 7, 2025
Merged via the queue into main with commit ef550a0 Mar 7, 2025
11 checks passed
@aws-cdk-automation aws-cdk-automation deleted the huijbers/insert-cli-versioun branch March 7, 2025 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2 pr/exempt-integ-test Skips the integ test steps if set.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants