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

print progress in lein release #2605

Merged

Conversation

saitouena
Copy link
Contributor

justification

This make it easier to rollback release-tasks or complete them by hand.
#2402

  • If a release fails, show the user which steps succeeded, which one
    failed, and which ones are left to run.

lein release works like this with this patch.

$ cat project.clj 
;; This is Leiningen's own project configuration. See doc/TUTORIAL.md
;; file as well as sample.project.clj for help writing your own.

(defproject leiningen "2.9.1"
...
  :release-tasks [["echo" "aaa"]
                  ["echo" "bbb"]
                  ["echo" "ccc"]]
  :source-paths ["leiningen-core/src" "src"]
  :eval-in :leiningen)
$ bin/lein release
[ 0 / 3 ] Executing lein echo aaa
aaa
[ 1 / 3 ] Executing lein echo bbb
bbb
[ 2 / 3 ] Executing lein echo ccc
ccc
[ 3 / 3 ] Completed lein release.

@saitouena saitouena changed the title add progress in lein release print progress in lein release Jul 22, 2019
Copy link
Collaborator

@danielcompton danielcompton left a comment

Choose a reason for hiding this comment

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

Thanks for looking at this, I've made some suggestions.

(main/resolve-and-apply current-project task))))))
(let [all-tasks (:release-tasks project)
total-task-count (count all-tasks)]
(doseq [[i task] (zipmap (range total-task-count) all-tasks)]
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 zipmap is the right function for this, it returns a map, not a sequence. Below 8 entries everything will appear to work, but above 8 the order of the entries in the map is not the same as their insertion. I think map would work better here.

Side note, zipmap (and map) can take a finite and infinite sequence and produce a finite map, e.g. (zipmap (range) all-tasks) would also work.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we might want to start counting at 1 rather than 0 here? When I see 2/3, I think that that is the second task of the three, when it's actually the last one. That would also mean we could avoid having a final "Completed lein release." log message at the end.

Copy link
Contributor Author

@saitouena saitouena Jul 29, 2019

Choose a reason for hiding this comment

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

I don't think zipmap is the right function for this, it returns a map, not a sequence.

I should use (map vector (range) release-tasks) here.

I think we might want to start counting at 1 rather than 0 here?

I'm not sure about this. I realized Chrome text search(Ctrl+F) starts from 1, so I'll take your suggestion.

(let [current-project (project/init-project (project/read))]
(main/resolve-and-apply current-project task))))))
(let [all-tasks (:release-tasks project)
total-task-count (count all-tasks)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

task-count might be a better name?

Suggested change
total-task-count (count all-tasks)]
task-count (count all-tasks)]

(doseq [task (:release-tasks project)]
(let [current-project (project/init-project (project/read))]
(main/resolve-and-apply current-project task))))))
(let [all-tasks (:release-tasks project)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
(let [all-tasks (:release-tasks project)
(let [release-tasks (:release-tasks project)

(let [all-tasks (:release-tasks project)
total-task-count (count all-tasks)]
(doseq [[i task] (zipmap (range total-task-count) all-tasks)]
(apply main/info (concat ["[" i "/" total-task-count "] Executing lein"] task))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer "running" to "executing" but I think this is mostly a matter of taste.

Suggested change
(apply main/info (concat ["[" i "/" total-task-count "] Executing lein"] task))
(apply main/info (concat ["[" i "/" total-task-count "] Running lein"] task))

@saitouena saitouena force-pushed the print-progress-in-lein-release branch from b918907 to db0a5e7 Compare July 29, 2019 04:04
@saitouena
Copy link
Contributor Author

@danielcompton I like all your suggestions.
lein release looks like this now.

$ ./bin/lein release
[ 1 / 3 ] Running lein echo aaa
aaa
[ 2 / 3 ] Running lein echo bbb
bbb
[ 3 / 3 ] Running lein echo ccc
ccc

CI failed but ./bin/lein test succeeded in my local environment. Any ideas? It seems that CI is unstable for now. https://circleci.com/gh/technomancy/leiningen

Copy link
Collaborator

@danielcompton danielcompton left a comment

Choose a reason for hiding this comment

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

This is looking pretty close. I’ll defer to others on whether they’d prefer to see a different format for the log messages. I don’t know if there is a more “Leiningen style” logging format?

src/leiningen/release.clj Show resolved Hide resolved
(let [release-tasks (:release-tasks project)
task-count (count release-tasks)]
(doseq [[i task] (map vector (range 1 (inc task-count)) release-tasks)]
(apply main/info (concat ["[" i "/" task-count "] Running lein"] task))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This might be clearer using format, or possibly just removing the concat and wrapping collection, I don’t think it’s necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree.

@saitouena saitouena force-pushed the print-progress-in-lein-release branch from db0a5e7 to 7e1f7bb Compare July 29, 2019 13:56
@saitouena saitouena force-pushed the print-progress-in-lein-release branch from 7e1f7bb to 8f0f0b0 Compare July 29, 2019 13:58
@technomancy
Copy link
Owner

Thanks; this looks great. I can't think of any other comparable output to try to make it more consistent with, so I think we should go with this. I'm looking into the CI failure but it's unrelated to your change.

@technomancy technomancy merged commit 84e99a5 into technomancy:master Aug 3, 2019
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