-
Notifications
You must be signed in to change notification settings - Fork 378
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
Conversation
541f30b
to
50e8645
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
a46a5ab
to
fed36c9
Compare
@Chriscbr How does this look related to upgrade issue? |
.projen/tasks.json
Outdated
"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'" |
There was a problem hiding this comment.
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.
Lines 7 to 11 in d20bc27
{ | |
"name": "@types/fs-extra", | |
"version": "^8", | |
"type": "build" | |
}, |
There was a problem hiding this comment.
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).
test/upgrade-dependencies.test.ts
Outdated
@@ -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", () => { |
There was a problem hiding this comment.
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
)
There was a problem hiding this comment.
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.
test/upgrade-dependencies.test.ts
Outdated
// 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"); | ||
}); | ||
} |
There was a problem hiding this comment.
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(...);
// 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)) { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
).
185a24b
to
940267b
Compare
940267b
to
ca136c1
Compare
fixes: #1659
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.