8000 CI: Only run release job for release PRs by tcharding · Pull Request #1758 · rust-bitcoin/rust-bitcoin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

CI: Only run release job for release PRs #1758

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

Merged
merged 1 commit into from
Apr 10, 2023

Conversation

tcharding
Copy link
Member

Currently we run the release jobs for all PRs, this leads to red CI runs any time we have unreleased changes in one crate used by another i.e., basically days after a release comes out.

Add a release.sh script that has more smarts to try and figure out if the patch series currently ontop of tip of mater contains changes that imply its a release PR. To do so we check for changes to the version field in the manifest of each crate.

Comment on lines 23 to 24
if git log --patch --reverse master.. | grep --quiet "^\+\+\+ b/$crate/Cargo.toml"; then
if git log --patch --reverse master.. | grep --quiet "^\+version"; then
Copy link
Member Author

Choose a reason for hiding this comment

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

This logic could lead to false positives if there are changes to one crate's manifest but not the version field and the version field is updated in another manifest - does this matter? Someone want to take flex their shell-fu?

Copy link
Member

Choose a reason for hiding this comment

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

You can filter git log by file, so you can one-line this (and then drop the if since it looks like you're just forwarding the return value anyway):

release_changes() {
    git log --patch --reverse master.. -- $crate/Cargo.toml | grep version || true
}

The || true is to prevent set -e from killing the script when this fails. I'd also drop the --quiet from grep. If there are changes it might be nice to see exactly what they are.

Copy link
Member

Choose a reason for hiding this comment

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

Oops, || true will not forward the return value. Maybe we do need an if here.

Copy link
Member Author

Choose a reason for hiding this comment

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

oooh, -- <file> is what I was looking for - nice! Will re-work

Copy link
Member

Choose a reason for hiding this comment

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

Since, this is only for CI, you can also query crates.io to get the latest version. For the current PR, you can use env variables that cargo sets for you. See: https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates

Copy link
Member

Choose a reason for hiding this comment

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

No strong preference, just suggesting another alternative.

Copy link
Member Author

Choose a reason for hiding this comment

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

Cool, cheers.

Copy link
Member

Choose a reason for hiding this comment

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

On further thought, maybe we don't need the if, since we are calling release_changes in an if. I'm not sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't seem to need the || true. We now have:

release_changes() {
    local crate=$1
    git log --patch --reverse master.. -- $crate/Cargo.toml | grep version
}

Kixunil
Kixunil previously approved these changes Apr 2, 2023
Copy link
Collaborator
@Kixunil Kixunil left a comment

Choose a reason for hiding this comment

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

ACK 3335c1f9b0d53a15d82b5c368ead46285800640d

@tcharding
Copy link
Member Author

I'm not sure if @apoelstra or @sanket1729 are requesting changes or ok with this as is?

@tcharding
Copy link
Member Author

Marking high-priority because a bunch of open PRs are failing CI and this hopefully fixes them.

@tcharding tcharding added the P-high High priority label Apr 3, 2023
@apoelstra
Copy link
Member

@tcharding I'd like the release-changes line to be changed to be a single git invocation that doesn't have false positives.

@tcharding
Copy link
Member Author

Sure thing, I'll hack it up.

Currently we run the release jobs for all PRs, this leads to red CI runs
any time we have unreleased changes in one crate used by another i.e.,
basically days after a release comes out.

Add a `release.sh` script that has more smarts to try and figure out if
the patch series currently ontop of tip of mater contains changes that
imply its a release PR. To do so we check for changes to the version
field in the manifest of each crate.
@apoelstra
Copy link
Member

Cool! Looks great.

Copy link
Member
@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK e223cbe

@tcharding
Copy link
Member Author

Can we get this one in crew, there is red in every other open PR that this one fixes.

@stevenroose
Copy link
Collaborator

ACK e223cbe

@tcharding
Copy link
Member Author

Can you click the "approve" button too please @stevenroose, silly redundancy I know but we need both two ACKS and two "approves" to merge. Well at least I think we do, please correct me if I'm wrong @apoelstra?

@apoelstra
Copy link
Member

Yeah, we need two actual ACKs, then the closest thing we can get Github to do is to enforce "two clicks of the green button".

I suppose we could drop the Github requirements and just have maintainers manually enforce the rules.

@apoelstra apoelstra merged commit 36500b4 into rust-bitcoin:master Apr 10, 2023
@tcharding tcharding deleted the 03-29-publish-on-release branch April 11, 2023 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-high High priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0