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: Exclude packages that has version set by Projen from upgrade task #1665

Merged
merged 3 commits into from
Mar 8, 2022

Conversation

Hi-Fi
Copy link
Contributor

@Hi-Fi Hi-Fi commented Mar 6, 2022

fixes: #1659


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

@Hi-Fi Hi-Fi force-pushed the feat/upgrade_versions_as_set branch from 541f30b to 50e8645 Compare March 6, 2022 19:39
@codecov-commenter
Copy link

codecov-commenter commented Mar 7, 2022

Codecov Report

Merging #1665 (ca136c1) into main (d90284c) will increase coverage by 1.45%.
The diff coverage is 89.65%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1665      +/-   ##
==========================================
+ Coverage   88.06%   89.51%   +1.45%     
==========================================
  Files         132      150      +18     
  Lines        5109     6064     +955     
  Branches     1207     1562     +355     
==========================================
+ Hits         4499     5428     +929     
- Misses        610      634      +24     
- Partials        0        2       +2     
Impacted Files Coverage Δ
src/awscdk/internal.ts 100.00% <ø> (ø)
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/tasks.ts 94.11% <ø> (+0.78%) ⬆️
src/testing.ts 80.00% <ø> (ø)
src/textfile.ts 100.00% <ø> (ø)
src/toml.ts 90.90% <ø> (ø)
... and 179 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 2f0c7f2...ca136c1. Read the comment docs.

@Hi-Fi Hi-Fi force-pushed the feat/upgrade_versions_as_set branch from a46a5ab to fed36c9 Compare March 7, 2022 09:13
@Hi-Fi
Copy link
Contributor Author

Hi-Fi commented Mar 7, 2022

@Chriscbr How does this look related to upgrade issue?

"exec": "npm-check-updates --dep dev --upgrade --target=minor --reject='markmac,projen'"
"exec": "npm-check-updates --dep dev --upgrade --target=minor --reject='@types/fs-extra,@types/node,@typescript-eslint/eslint-plugin,@typescript-eslint/parser,eslint,jest-junit,npm-check-updates,standard-version,glob,yaml,markmac,projen'"
Copy link
Contributor

@Chriscbr Chriscbr Mar 7, 2022

Choose a reason for hiding this comment

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

We should only be rejecting those that are specifically pinned, no? For example here it shows that "@types/fs-extra" is set to "^8" -- so I would think running npm-check-updates with --target=minor on it should still include updates to this dependency.

{
"name": "@types/fs-extra",
"version": "^8",
"type": "build"
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's more like opinion thing, as with current solution user still gets correct version to lockfile as this step runs the upgrade step.

ncu doesn't seem to be updating versions in that format, so the filtering out just fully pinned (or ones with ~ could be done if needed).

@@ -192,6 +194,111 @@ test("github runner can be customized", () => {
expect(upgrade.jobs.pr["runs-on"]).toEqual("self-hosted");
});

describe("upgrade task created without projen defined versions", () => {
test("at NodeProject", () => {
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 just test this for NodeProject. I think the resulting change to other project types might be better captured by snapshot tests (like we see in the changes to test/web/__snapshots__/nextjs-project.test.ts.snap)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests were also for my TDD approach, but if snapshot tests are the main thing I can remove these.

In this case TDD with snapshots would have been quite a lot of harder and slower.

Comment on lines 204 to 215
// Presynthesize upgradeWorkflow to get tasks to project that can be checked
prj.upgradeWorkflow?.preSynthesize();
const upgradeTask = prj.tasks.tryFind("upgrade");
expect(upgradeTask).toBeDefined();
if (upgradeTask) {
const execSteps = upgradeTask.steps.filter((step) =>
step.exec?.toString().includes("npm-check-updates")
);
execSteps.forEach((execStep) => {
expect(execStep.exec).toContain("npm");
});
}
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 make an assertion on the snapshot of the project instead, like we have some of the other test cases:

  const tasks = synthSnapshot(project)[TaskRuntime.MANIFEST_FILE].tasks;
  expect(tasks.upgrade.steps...).toStrictEqual(...);

test/upgrade-dependencies.test.ts Show resolved Hide resolved
Comment on lines 192 to 193
// Don't add anything if there's only includes that are excluded by e.g. setting the version.
if (includeLength === 0 || (includeLength > 0 && ncuIncludesLength > 0)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we create the task if includeLength === 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Include's are exlicit includes, e.g. projen for upgrade-projen task.

So we should create task if...

  • we don't have any explicit includes
  • we have explicit includes, that are not pinned versions (ncuIncludes).

@Hi-Fi Hi-Fi force-pushed the feat/upgrade_versions_as_set branch from 185a24b to 940267b Compare March 8, 2022 06:50
@Hi-Fi Hi-Fi force-pushed the feat/upgrade_versions_as_set branch from 940267b to ca136c1 Compare March 8, 2022 06:57
@mergify mergify bot merged commit b2625a4 into projen:main Mar 8, 2022
@Hi-Fi Hi-Fi deleted the feat/upgrade_versions_as_set branch March 8, 2022 19:41
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.

Bug: upgrade -task doesn't honor versions set in .projenrc causing task to fail
3 participants