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

Backpropagate Cargo.lock updates to all lock files #9180

Merged
merged 5 commits into from
Apr 21, 2020

Conversation

ryoqun
Copy link
Member

@ryoqun ryoqun commented Mar 31, 2020

Problem

Non-default Cargo lock files tend to be forgot to update. this causes many problems:

This is a problem which I noticed at #8882. Since then, I've been always bothered with our trust-chain in the build/CI system a bit... Let's fortify it step by step before we get pray of third-party crate publisher's credential hack :)

Summary of Changes

  • never accept stale lock files
  • for that, give special handling to dependabot

live example: https://github.com/solana-labs/solana/pull/9159/commits

partly related to this: #8587 (comment)

upstream (dependabot)'s related issue: https://github.com/dependabot/feedback/issues/5

@ryoqun ryoqun requested a review from mvines March 31, 2020 13:34
ci/docker-run.sh Outdated Show resolved Hide resolved
@ryoqun ryoqun changed the title Experiment to backpropagate Cargo.lock updates to all lock files Backpropagate Cargo.lock updates to all lock files Mar 31, 2020
ci/docker-run.sh Outdated Show resolved Hide resolved
ci/test-checks.sh Outdated Show resolved Hide resolved
ci/docker-run.sh Outdated Show resolved Hide resolved
@mvines
Copy link
Member

mvines commented Mar 31, 2020

This seems really complex :-/

Maybe unchecking this box will help?
image

Also isn't there a new Cargo.lock format available now that we could enable that'll reduce the backport conflicts?

@ryoqun
Copy link
Member Author

ryoqun commented Mar 31, 2020

This seems really complex :-/

Yeah, but I researched this a bit and no better solution came up for weeks while pondering when waiting builds...

Maybe unchecking this box will help?
image

I think the top-level here means the crates specified directly by Cargo.toml. So, non-top-level packages is the so-called transitively-dependant packages. So, this isn't what we want. Unchecking that would produce tons of tons dependabot PRs because plain cargo update produces so large diff locally already. Also, that would increase frequency of PRs even after we got over the initial surge.

For the dependabot fiddling path, I could register each Cargo.{toml,lock}s to dependabot but it'd cause separate PRs just for the same crate update until they support grouping of update.

Also isn't there a new Cargo.lock format available now that we could enable that'll reduce the backport conflicts?

Yeah, that's true. But that doesn't solve all problems I'd like to fix as described above. Can do as a separate PR for the format change.

@mvines
Copy link
Member

mvines commented Mar 31, 2020

Ok so I think my main concern about this PR is that how it adds a ton of stuff into ci/docker-run.sh and ci/test-checks.sh, where instead I think ideally this is all very isolated in it's own ci/dependabot-pr.sh-like file.

I think the ideal end state is a new build step in https://github.com/solana-labs/solana/blob/master/ci/buildkite.yml, that:
a. runs ci/dependabot-pr.sh before checks, with a "wait" directive,
b. but only runs for dependabot PRs

To get there will be a multi-step process:

  1. We aren't surfacing all the right build environment variables to buildkite from ci-gate in order to implement 1. https://github.com/mvines/ci-gate/blob/51d99887ea7cf3dd1d030a55cc6980f1fc8d09c7/index.js#L121-L127 is missing the "author" information (cc: https://buildkite.com/docs/apis/rest-api/builds#create-a-build) in particular, so all builds appear to be coming from me 🙃.
  2. Buildkite has support for build step conditionals, https://buildkite.com/docs/pipelines/conditionals, that will allow us to filter out this special build step from non-dependabot PRs (build.env() in particular)

I can look at adding (1) if this approach sounds good to you.

@stale
Copy link

stale bot commented Apr 8, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Apr 8, 2020
@stale
Copy link

stale bot commented Apr 15, 2020

This stale pull request has been automatically closed. Thank you for your contributions.

@stale stale bot closed this Apr 15, 2020
@ryoqun
Copy link
Member Author

ryoqun commented Apr 15, 2020

Ok so I think my main concern about this PR is that how it adds a ton of stuff into ci/docker-run.sh and ci/test-checks.sh, where instead I think ideally this is all very isolated in it's own ci/dependabot-pr.sh-like file.

I think the ideal end state is a new build step in https://github.com/solana-labs/solana/blob/master/ci/buildkite.yml, that:
a. runs ci/dependabot-pr.sh before checks, with a "wait" directive,
b. but only runs for dependabot PRs

To get there will be a multi-step process:

1. We aren't surfacing all the right build environment variables to buildkite from ci-gate in order to implement 1.    https://github.com/mvines/ci-gate/blob/51d99887ea7cf3dd1d030a55cc6980f1fc8d09c7/index.js#L121-L127 is missing the "author" information (cc: https://buildkite.com/docs/apis/rest-api/builds#create-a-build) in particular, so all builds appear to be coming from me upside_down_face.

2. Buildkite has support for build step conditionals, https://buildkite.com/docs/pipelines/conditionals, that will allow us to filter out this special build step from non-dependabot PRs (`build.env()` in particular)

I can look at adding (1) if this approach sounds good to you.

Yeah, that looks great way to accomplish what I want to achieve. :)

@ryoqun ryoqun reopened this Apr 15, 2020
@stale stale bot removed the stale [bot only] Added to stale content; results in auto-close after a week. label Apr 15, 2020
@ryoqun ryoqun force-pushed the cargo-lock-backpropagation branch from 7d0a648 to 933aa1d Compare April 17, 2020 08:36
@codecov
Copy link

codecov bot commented Apr 17, 2020

Codecov Report

Merging #9180 into master will decrease coverage by 0.0%.
The diff coverage is n/a.

@@           Coverage Diff            @@
##           master   #9180     +/-   ##
========================================
- Coverage    80.6%   80.6%   -0.1%     
========================================
  Files         279     279             
  Lines       63375   63375             
========================================
- Hits        51110   51105      -5     
- Misses      12265   12270      +5     

@ryoqun ryoqun force-pushed the cargo-lock-backpropagation branch from 3c0c76f to c7fe413 Compare April 17, 2020 15:24
@ryoqun
Copy link
Member Author

ryoqun commented Apr 17, 2020

@mvines I think this pr is ready for review again!

I'm playing with this dependabot's PR this time: https://github.com/solana-labs/solana/pull/9508/commits

test builds:

this pr (for normal users): https://buildkite.com/solana-labs/solana/builds/22845
test subject pr build take 1 (it back-propagates updates to all locks): https://buildkite.com/solana-labs/solana/builds/22842
test subject pr build take 2 (--locked build and usual test runs with success): https://buildkite.com/solana-labs/solana/builds/22843

@@ -13,6 +13,15 @@ export RUSTFLAGS="-D warnings"
# Look for failed mergify.io backports
_ git show HEAD --check --oneline

if _ scripts/cargo-for-all-lock-files.sh check --locked; 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 is what I really want to do before any our depending crates are compromised. :)

scripts/cargo-for-all-lock-files.sh Outdated Show resolved Hide resolved
package=$(echo "$parsed_update_args" | awk '{print $2}')
if [[ -n $parsed_update_args ]]; then
# shellcheck disable=SC2086
_TARGET_LOCK_FILES=$(git grep --files-with-matches "$package" :**/Cargo.lock) \
Copy link
Member

Choose a reason for hiding this comment

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

Using _TARGET_LOCK_FILES to pass a list into scripts/cargo-for-all-lock-files.sh feels a little too sneaky to me. It would be nice to fit this on the scripts/cargo-for-all-lock-files.sh command line.

$ scripts/cargo-for-all-lock-files.sh $(_TARGET_LOCK_FILES) -- update $parsed_update_args perhaps? And if there's no -- argument then we use $(git ls-files :**/Cargo.lock)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I've been concerned a bit too... I followed an easier path considering these script's intended usage frequency. Thanks for accurately pin-pointing this while reviewing! I've changed my mind and give this some love. :)

ci/dependabot-pr.sh Outdated Show resolved Hide resolved
@ryoqun ryoqun force-pushed the cargo-lock-backpropagation branch from 54f155f to a092c3f Compare April 20, 2020 10:25
@ryoqun ryoqun requested a review from mvines April 20, 2020 13:48
@ryoqun
Copy link
Member Author

ryoqun commented Apr 20, 2020

@mvines I think I've fixed all your suggestions! Also, I've updated my experiment pr: #9508 Off course, both builds are passing. :)

@ryoqun
Copy link
Member Author

ryoqun commented Apr 21, 2020

I've rebased all outstading dependabot's PRs on this after the merge.Now, all those prs seem to be working: #9446 #9607.

@ryoqun
Copy link
Member Author

ryoqun commented Apr 21, 2020

I'll wait a week or so before I back-port this to all version branches (It should be almost no effort).

Also, I'll do quick-post to the upstream's dependabot/feedback#5 to share this for the rust+dependabot community.

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.

3 participants