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

Add a sqitch check command that prints changes in plan for which script has changed #477

Closed
wants to merge 15 commits into from

Conversation

matthieu-foucault
Copy link
Contributor

Re #475

I'm thinking about adding a --redeploy option that would revert to the appropriate change and deploy the plan again, so that the database has deployed changes matching the working directoy.

It's my first time writing in Perl, so let me know if I am missing some language idioms, or if there are some lines in there that look horribly wrong.

It's still a draft. I haven't written any test yet, and I am sure I am missing a lot of edge cases.
Happy to receive feedback either way :)

wenzowski added a commit to bcgov/cas-ggircs that referenced this pull request Jun 10, 2019
@theory
Copy link
Collaborator

theory commented Jun 11, 2019

At a glance, it looks pretty complete, thanks! It will likely be a week or so before I can look at it in detail due to a super busy work week.

I'm thinking about adding a --redeploy option that would revert to the appropriate change and deploy the plan again, so that the database has deployed changes matching the working directoy.

Sounds like the rebase command. Or do I misunderstand? Oh, maybe you mean so it knows what version to revert to? Might be useful to add some sort of --revised option to the rebase command, I think.

@matthieu-foucault
Copy link
Contributor Author

It's the rebase command indeed. I can add a --revised option that finds the parent of the first script that is different in the working directory and rebases onto that

wenzowski added a commit to bcgov/cas-ggircs that referenced this pull request Jun 12, 2019
@theory theory self-requested a review June 18, 2019 21:02
@theory theory self-assigned this Jun 18, 2019
Copy link
Collaborator

@theory theory left a comment

Choose a reason for hiding this comment

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

This looks like a great start, thank you! I have most of my feedback in comments on this PR; I don't think it'll take you long to tweak and refactor; if you're new to Perl I can't tell!

One thing more it needs, however, is tests. Once you move the actual checks to the Engine module, I suggest adding them to t/engine.t, following the examples there for testing the verify method to test the new check method. Then add tests for the command module itself to a new test file t/check.t, and borrow from t/verify.t to get some nice test coverage.

Is that work you'd be able to do, @matthieu-foucault? This is awesome, and I'm excited to such a great new contribution.

Thank you!

lib/App/Sqitch/Command/check.pm Outdated Show resolved Hide resolved
lib/App/Sqitch/Command/check.pm Outdated Show resolved Hide resolved
lib/App/Sqitch/Command/check.pm Outdated Show resolved Hide resolved
lib/App/Sqitch/Command/check.pm Show resolved Hide resolved
lib/App/Sqitch/Command/check.pm Outdated Show resolved Hide resolved
lib/App/Sqitch/Command/check.pm Show resolved Hide resolved
lib/App/Sqitch/Command/check.pm Outdated Show resolved Hide resolved
lib/App/Sqitch/Role/DBIEngine.pm Show resolved Hide resolved
lib/sqitch-check.pod Outdated Show resolved Hide resolved
t/lib/DBIEngineTest.pm Show resolved Hide resolved
@theory theory added this to the v1.1.0 milestone Jun 18, 2019
@theory theory added the feature label Jun 18, 2019
@matthieu-foucault
Copy link
Contributor Author

matthieu-foucault commented Jun 18, 2019

Thanks for the review @theory ! I'll have time to work on it this week, and add the rebase --revised option mentioned above.

@matthieu-foucault
Copy link
Contributor Author

Both check and rebase --revised work at this point. I should be able to work on adding tests tomorrow.

@matthieu-foucault matthieu-foucault marked this pull request as ready for review June 21, 2019 00:03
@matthieu-foucault
Copy link
Contributor Author

@theory There are still tests running on TavisCI, but I think this is good for a review 🎉

@matthieu-foucault
Copy link
Contributor Author

It seems that the windows build can't find Test::MockObject::Extends, which I added to be able to mock a script_hash change. @theory any idea on how to fix that?

@theory
Copy link
Collaborator

theory commented Jul 10, 2019

Thanks for that update. Reviewing this PR is on my list, but not sure when I will get to it. Life pretty bananas right now…appreciate your patience.

Copy link
Collaborator

@theory theory left a comment

Choose a reason for hiding this comment

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

Apologies for the delay in review, Matthieu. This looks great! Just a few minor tweaks and I think it's ready to go. Amazing work, really appreciate it!

sub options {
return qw(
onto-change|onto=s
upto-change|upto=s
revised!
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we want this to be negate-able; the ! means that there is also a --no-revised option, which doesn't seem necessary. Am I missing something?

return -1;
}

sub planned_deployed_common_ancestor_id {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I didn't see a test for this method, or for _find_planned_deployed_divergence_idx. Are they implicit in the tests for check?

@@ -63,6 +65,13 @@ L<sqitchchanges> for the various ways in which changes can be specified.
Specify the deployment change. Defaults to the last point in the plan. See
L<sqitchchanges> for the various ways in which changes can be specified.

=item C<--revised>

Finds the change to revert onto based on the output of L<sqitch-check>. The
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure this is accurate: based on the output of L<sqitch-check>. Is there output from sqitch check when you run this? I thought it was simply that it would rebase on the last change that does not conflict between the plan and the deployed changes. I think you can omit the part about the output of sqitch check from this description.


=head1 Description

Runs various checks on the state of the working directory and the database.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it "various checks" at this point? Seems like there's just the one at the moment; perhaps mention that more may be added in the future?

@theory
Copy link
Collaborator

theory commented May 2, 2020

Hey @matthieu-foucault, would you give me permission to push to your branch? Details here. I've rebased it and made a few tweaks. If I can push to your branch, it will keep this PR in-tact, which is nice for history, and I can get it merged post-haste. Thanks!

@matthieu-foucault
Copy link
Contributor Author

Hi @theory , thanks for taking over that PR.
Unfortunately, I cannot allow edits from maintainers as the PR is coming from an org repo, not a my personal user repo (see https://github.community/t5/How-to-use-Git-and-GitHub/How-can-we-enable-allow-edits-from-maintainers-by-default/m-p/51971/highlight/true#M11129)

@theory
Copy link
Collaborator

theory commented May 2, 2020

Bummer. Guess I'll have to close this PR and make a new one. :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants