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(javascript): allow users to run post-upgrade tasks #1476

Merged
merged 3 commits into from
Jan 11, 2022

Conversation

misterjoshua
Copy link
Contributor

@misterjoshua misterjoshua commented Jan 3, 2022

Allows users to add post-upgrade tasks. This is useful in case the user wants to run commands after the upgrade workflow, such as automatically updating integration test snapshots. Example:

project.upgradeWorkflow?.postUpgradeTask.spawn(project.tasks.tryFind('bundle'));
project.upgradeWorkflow?.postUpgradeTask.spawn(project.tasks.tryFind('integ:my-test:snapshot'));

Fixes #1348
Related #1256


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

@misterjoshua misterjoshua marked this pull request as ready for review January 3, 2022 20:58
@misterjoshua
Copy link
Contributor Author

@Chriscbr Hey. Any ideas what's needed to move this PR along, discussion, code-change, or otherwise?

Copy link
Contributor

@Chriscbr Chriscbr left a comment

Choose a reason for hiding this comment

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

Hi, thanks for the ping. I took one more look to see if there's any quick fixes for the upgrade task not being available for escape hatching, but since I couldn't see any, I'm cool with adding this for now. Just a few small comments 🙂

Comment on lines 458 to 463
/**
* A task run after the upgrade task.
*/
public get postUpgradeTask() {
return this.upgradeWorkflow?.postUpgradeTask;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove this since the upgradeWorkflow property is public anyways - I'd prefer to minimize the API surface area we're adding.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problemo.

@@ -197,6 +208,8 @@ export class UpgradeDependencies extends Component {
// run "projen" to give projen a chance to update dependencies (it will also run "yarn install")
task.exec(this._project.projenCommand);

task.spawn(this.postUpgradeTask);
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 add a unit test? I think we just want to validate that is there is some way to run things after the upgrade task.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I've added a unit test that checks that the upgrade task spawns post-upgrade as its last step. In the test, I didn't add anything to the post-upgrade task, but I can if you feel it's necessary.

@codecov-commenter
Copy link

Codecov Report

Merging #1476 (e842f8e) into main (d90284c) will increase coverage by 1.18%.
The diff coverage is 88.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1476      +/-   ##
==========================================
+ Coverage   88.06%   89.24%   +1.18%     
==========================================
  Files         132      141       +9     
  Lines        5109     5781     +672     
  Branches     1207     1468     +261     
==========================================
+ Hits         4499     5159     +660     
- Misses        610      620      +10     
- Partials        0        2       +2     
Impacted Files Coverage Δ
src/cdk/consts.ts 100.00% <ø> (+36.36%) ⬆️
src/dev-env.ts 83.33% <0.00%> (ø)
src/java/index.ts 100.00% <ø> (ø)
src/python/index.ts 100.00% <ø> (ø)
src/release/index.ts 100.00% <ø> (ø)
src/typescript/typescript-typedoc.ts 20.00% <0.00%> (ø)
src/web/react.ts 100.00% <ø> (ø)
src/web/tailwind.ts 100.00% <ø> (ø)
src/xmlfile.ts 92.30% <ø> (+0.64%) ⬆️
src/yaml.ts 100.00% <ø> (ø)
... and 157 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9b1b0ca...e842f8e. Read the comment docs.

@misterjoshua misterjoshua requested a review from Chriscbr January 11, 2022 20:32
@misterjoshua
Copy link
Contributor Author

@Chriscbr Alright - I've made changes following your review. Let me know whether you need anything else! Thanks.

@mergify mergify bot merged commit 292aefa into projen:main Jan 11, 2022
@misterjoshua misterjoshua deleted the feat-post-upgrade branch January 12, 2022 17:40
jogold added a commit to jogold/projen that referenced this pull request Jan 19, 2022
The task is named `integ:snapshot-all` and can be used together with the
feat added in projen#1476.
mergify bot pushed a commit that referenced this pull request Jan 19, 2022
The task is named `integ:snapshot-all` and can be used together with the
feat added in #1476.

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

upgrade workflow doesn't update integration test snapshots for bundled lambdas
3 participants