-
Notifications
You must be signed in to change notification settings - Fork 55
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
Interactive cli #83
Interactive cli #83
Conversation
Lists available CI providers and executes the respective script
import ( | ||
"fmt" | ||
"github.com/manifoldco/promptui" | ||
"github.com/spf13/cobra" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cobra is a tool to create CLI interfaces in Go.
"fmt" | ||
"github.com/manifoldco/promptui" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
viper is a tool to manage configuration. It pairs well with cobra. I have not used it yet but decided to get it in already since I am sure that we will make use of it.
cmd/root.go
Outdated
var setupScript string | ||
var err error | ||
|
||
if len(os.Args) > 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to add this in order to set a CI provider at the CircleCI job that tests the application.
@fjgarlin thoughts about this so far? |
Code-wise, it all looks good (my knowledge of
-- |
I'll test it all locally, just wanted to give some quick feedback as I found it. |
1: yep! I just adjusted that |
This is so awesome, it opens the door to future improvements like rewriting bash scripts in go, choosing the PHP version (once we figure out images), etc. And most importantly, it lowers the entry barrier to this project. A super small suggestion. When you run the command, after choosing the platform, it takes around 5~10 seconds until you get the first line of output. For a second I wasn't sure if my machine was hanging, so it might be good to put a So something like:
Could be |
cmd/root.go
Outdated
if len(args) > 1 { | ||
return &args[1], nil | ||
} | ||
ciProviders := []string{"Bitbucket", "CircleCI", "GitHub Actions", "GitLab CI", "Travis CI"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm new to go
language. Can we not import/use the const
defined in scripts/scripts.go
to avoid repetition? If we can't that's totally fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
You missed replacing the old command with the new one here: https://github.com/Lullabot/drupal9ci/blob/82-interactive-cli/README.md#github-actions |
@fjgarlin this is ready for another look. |
Codecov Report
@@ Coverage Diff @@
## master #83 +/- ##
=========================================
Coverage ? 40.54%
=========================================
Files ? 1
Lines ? 37
Branches ? 0
=========================================
Hits ? 15
Misses ? 21
Partials ? 1 Continue to review full report at Codecov.
|
@fjgarlin I will merge this tomorrow. Let me know if you find any issues. We can work on further changes in new pull requests. |
I was away from the computer yesterday and couldn't check the activity. I've been checking the code changes and everything looks really solid. I think it's good to be merged. Approving the PR. Great work! |
|
||
jobs: | ||
publish-docker-image: | ||
name: Publish Docker image |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional questions, but PR is good to be merged:
- Does this publish the image generated from
Dockerfile
into github? or is it another unrelated thing? - If it's the image from
Dockerfile
, how would we use it later in the different platforms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional questions, but PR is good to be merged:
- Does this publish the image generated from
Dockerfile
into github? or is it another unrelated thing?
Yes, here: https://github.com/Lullabot/drupal9ci/pkgs/container/drupal9ci
- If it's the image from
Dockerfile
, how would we use it later in the different platforms?
I suggest that we start supporting only the Dockerile9 (I replaced Dockerfile with Dockerfile9). Next, we can improve the cli so it asks for Drupal version and picks the right Dockerfile (at which point we could restore the old Dockerfile and build and publish both images in this job). Alternatively, I wonder if we can detect the version and pick the Dockerfile automatically. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think giving the user the option to choose might be enough. We can just give them options like this:
* Dockerfile9: php8.1, composer 2, npm 16...
* Dockerfile: php7.4, composer 1, npm 12...
* Choose your own image: this might not work out of the box. You'll be prompted to type it.
Then with that info, we can search/replace the config file of the platform they've used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! I like that.
@@ -0,0 +1,41 @@ | |||
name: Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loving the additional tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! This is just the beginning. I want to move the shell scripts into easily testable Go code as you suggested.
Notice that I kind of hacked the default Cobra command: I removed sub-commands so you can just run drupal9ci
but you can certainly have multiple sub commands so you could do, for example drupal9ci check
to check for requirements and, when ready, run drupal9ci install
to run the installer. We could also do this in a follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point (sorry I am throwing out a lot of thoughts here), I would like to rename (again, I know) this repository to drupalci
since we will be able to support multiple Drupal versions. Thoughts about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100% on this.
@fjgarlin I may have broken some of the providers by updating the Docker images. I am going to merge and then will start testing them one by one with a sample repository. Feel free to suggest whatever fixes you may consider. |
Not a problem. As this is not a package that is updated on people's projects, but rather a "use once, then tweak in your own copy", we will not be breaking people's projects. If new users find issues I'm sure they'll report them. But yeah, in any case, it's a good idea to give it a quick try by yourself and if I find time next week I can also do the same, but all of it as follow-ups. |
For #82
This is raw and lacks error handling and best practices but already does something:
drupal9ci
executable.As I am writing this I think that I can simply run the script without having to download it since it is packaged within the executable. I will fix this in this pull request.
Once we have this in place we could: