Ensure release-tools is up-to-date before executing tasks
@jameslopez Ran into an issue during a release today that was fixed in the latest master
of release-tools
, but he hadn't yet pulled. We should perform a fetch
before executing tasks and bail if we're not up-to-date.
We should probably limit this to executing tasks on master
to prevent potentially breaking the workflow of a temporary or development branch.
Designs
- Show closed items
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- Developer
Wondering if we should do the same in
chef-repo
... - James Lopez assigned to @jameslopez
assigned to @jameslopez
- James Lopez mentioned in merge request !97 (merged)
mentioned in merge request !97 (merged)
- Maintainer
@jameslopez FYI
chef-repo
already does that:- https://dev.gitlab.org/cookbooks/chef-repo/blob/master/Rakefile#L665
- https://dev.gitlab.org/cookbooks/chef-repo/blob/master/Rakefile#L807-812
I think we should abort if:
- We're not on
master
- We're on
master
butgit pull --ff-only
fails
- Developer
@rymai yep, that's similar to what I'm doing in this MR https://gitlab.com/gitlab-org/release-tools/merge_requests/97
I didn't now
chef-repo
had a similar check. Although it will just checkoutmaster
directly... - Maintainer
@jameslopez Oops, I've done the same thing, at the Rake dependencies level:
commit 43590d1bcaf313ddd2981fb89de3f8a2876e1852 Author: Rémy Coutable <remy@rymai.me> Date: Wed Mar 15 15:29:12 2017 +0100 Ensure we're on an up-to-date `master` before running a Rake task Signed-off-by: Rémy Coutable <remy@rymai.me> diff --git a/Rakefile b/Rakefile index fbec671..b518f98 100644 --- a/Rakefile +++ b/Rakefile @@ -11,8 +11,16 @@ rescue LoadError # no rspec available end +desc "Chek that we're ready to roll!" +task :ready_to_roll do + branch = `git rev-parse --abbrev-ref HEAD`.strip + raise 'Please checkout `master`!' unless branch == 'master' + + raise 'Your master is not fast-forwardable!' unless system('git pull --ff-only 2> /dev/null') +end + desc "Create release" -task :release, [:version] do |_t, args| +task :release, [:version] => :ready_to_roll do |_t, args| version = get_version(args) if security_release? @@ -36,13 +44,13 @@ task :release, [:version] do |_t, args| end desc "Create a security release" -task :security_release, [:version] do |_t, args| +task :security_release, [:version] => :ready_to_roll do |_t, args| ENV['SECURITY'] = 'true' Rake::Task[:release].invoke(args[:version]) end desc "Promote security release packages to public" -task :promote_security_release, [:version] do |_t, args| +task :promote_security_release, [:version] => :ready_to_roll do |_t, args| ENV['SECURITY'] = 'true' version = get_version(args) @@ -50,7 +58,7 @@ task :promote_security_release, [:version] do |_t, args| end desc "Sync master branch in remotes" -task :sync do +task sync: :ready_to_roll do if skip?('ee') $stdout.puts 'Skipping sync for EE'.colorize(:yellow) else @@ -71,7 +79,7 @@ task :sync do end desc "Create the monthly release issue" -task :monthly_issue, [:version] do |_t, args| +task :monthly_issue, [:version] => :ready_to_roll do |_t, args| version = get_version(args) issue = MonthlyIssue.new(version) @@ -79,7 +87,7 @@ task :monthly_issue, [:version] do |_t, args| end desc "Create the regression tracking issue" -task :regression_issue, [:version] do |_t, args| +task :regression_issue, [:version] => :ready_to_roll do |_t, args| version = get_version(args) issue = RegressionIssue.new(version) @@ -87,7 +95,7 @@ task :regression_issue, [:version] do |_t, args| end desc "Create a patch issue" -task :patch_issue, [:version] do |_t, args| +task :patch_issue, [:version] => :ready_to_roll do |_t, args| version = get_version(args) issue = PatchIssue.new(version) @@ -95,7 +103,7 @@ task :patch_issue, [:version] do |_t, args| end desc "Create a security patch issue" -task :security_patch_issue, [:version] do |_t, args| +task :security_patch_issue, [:version] => :ready_to_roll do |_t, args| version = get_version(args) issue = SecurityPatchIssue.new(version)
I think if we're already on
master
, we should try togit pull --ff-only
. - Developer
@rymai yeah, that makes sense to add too
- Robert Speicher closed via merge request !97 (merged)
closed via merge request !97 (merged)
- Robert Speicher mentioned in commit phil7/release-tools@8c94537d
mentioned in commit phil7/release-tools@8c94537d