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

feat: new ignite doctor command #3381

Merged
merged 13 commits into from Apr 6, 2023
Merged

feat: new ignite doctor command #3381

merged 13 commits into from Apr 6, 2023

Conversation

tbruyelle
Copy link
Contributor

@tbruyelle tbruyelle commented Jan 6, 2023

Fix #3291 #3268

  • add ignite doctor command (hidden for the moment)
    • migrate config.yml if needed
    • create tools/tools.go if not present, then install dependency tools.
      The tools/tools.go scaffold is handled by the same generator as scaffold chain, with an update allowing it to filter the fileset.
      xgenny.NewEmbedWalker, which was used to remove the files/ prefix, is replaced by fs.Sub from the standard library.
  • update cosmosgen.InstallDepTools()
    • remove retro compatibilty with chain that doesn't have tools/tools.go, in other words, remove the call to go get
    • run go mod tidy to update go.sum
    • suggest to run ignite doctor when dependency tools install fails
  • move GOSUMDB=off inside gocmd.ModTidy instead of setting it prior to the call. This ensures it's always set.

Because the command uses intensively the filesystem, I chose to test it with integration tests only. The integration test introduces a new library called testscript [0], which is very convenient for this kind of tests.

testscript is based on txt files, where each file is a test case that contains some instructions. The txt file for ignite doctor runs ignite doctor and then asserts what has changed in the filesystem, according to some commands like cmp. The initial filesystem state before the command is run is also specified in the txt file, with a list of files designated by -- filename -- followed by the file content.

[0] https://pkg.go.dev/github.com/rogpeppe/go-internal/testscript

Fix #3291

- add ignite doctor command (hidden for the moment)
  - migrate config.yml if needed
  - create tools/tools.go if not present, then install dependency tools.
    The `tools/tools.go` scaffold is handled by the same generator as
    `scaffold chain`, with an update allowing it to filter the fileset.
    `xgenny.NewEmbedWalker`, which was used to remove the `files/`
    prefix, is replaced by `fs.Sub` from the standard library.
- update `cosmosgen.InstallDepTools()`
  - remove retro compatibilty with chain that doesn't have
    `tools/tools.go`, in other words, remove the call to `go get`
  - run `go mod tidy` to update `go.sum`
  - suggest to run ignite doctor when dependency tools install fails
- move `GOSUMDB=off` inside `gocmd.ModTidy` instead of setting it prior
  to the call. This ensures it's always set.

Because the command uses intensively the filesystem, I chose to test it
with integration tests only. The integration test introduces a new library
called `testscript` [0], which is very convenient for this kind of tests.

`testscript` is based txt files, where each file is a test case that
contains some instructions. The txt file for `ignite doctor` runs
`ignite doctor` and then asserts what has changed in the filesystem,
according to some commands like `cmp`. The initial state before the
command is run is also specified in the txt file, with a list of files
designated by `-- filename --` followed by the file content.

[0] https://pkg.go.dev/github.com/rogpeppe/go-internal/testscript
@tbruyelle
Copy link
Contributor Author

There's an issue with the network integration: the test runs ignite chain serve on spn, but since I removed the go get in cosmosgen.InstallDepTools(), the command fails with
image

I see 2 solutions:

Any other solution ?

@aljo242
Copy link
Contributor

aljo242 commented Jan 8, 2023

There's an issue with the network integration: the test runs ignite chain serve on spn, but since I removed the go get in cosmosgen.InstallDepTools(), the command fails with image

I see 2 solutions:

Any other solution ?

Let's discuss in the community call?

@tbruyelle tbruyelle closed this Jan 13, 2023
@tbruyelle tbruyelle reopened this Mar 9, 2023
@tbruyelle tbruyelle requested a review from ilgooz as a code owner March 9, 2023 16:22
@tbruyelle
Copy link
Contributor Author

Hey guys, this PR should be merged: I got the confirmation it fixes an annoying downgrade issue.

The PR is stuck because of a problem with spn, but I noticed that the removal of the network command is on the roadmap. So let's also remove/comment the integration/network test, and the CI will pass for this PR, and it can get merged.

ilgooz
ilgooz previously approved these changes Mar 10, 2023
Copy link
Member

@ilgooz ilgooz left a comment

Choose a reason for hiding this comment

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

Great!

@jeronimoalbi can you please review / merge? Thanks.

@jeronimoalbi
Copy link
Member

LGTM 👍

Once the issue with the tests and the conversations are resolved we can merge.

Co-authored-by: Jerónimo Albi <jeronimo.albi@tendermint.com>
@jeronimoalbi jeronimoalbi merged commit b9ffc43 into main Apr 6, 2023
22 checks passed
@jeronimoalbi jeronimoalbi deleted the feat/doctor_cmd branch April 6, 2023 11:09
Jchicode pushed a commit to Jchicode/cli that referenced this pull request Aug 9, 2023
* feat: new ignite doctor command

Fix ignite#3291

- add ignite doctor command (hidden for the moment)
  - migrate config.yml if needed
  - create tools/tools.go if not present, then install dependency tools.
    The `tools/tools.go` scaffold is handled by the same generator as
    `scaffold chain`, with an update allowing it to filter the fileset.
    `xgenny.NewEmbedWalker`, which was used to remove the `files/`
    prefix, is replaced by `fs.Sub` from the standard library.
- update `cosmosgen.InstallDepTools()`
  - remove retro compatibilty with chain that doesn't have
    `tools/tools.go`, in other words, remove the call to `go get`
  - run `go mod tidy` to update `go.sum`
  - suggest to run ignite doctor when dependency tools install fails
- move `GOSUMDB=off` inside `gocmd.ModTidy` instead of setting it prior
  to the call. This ensures it's always set.

Because the command uses intensively the filesystem, I chose to test it
with integration tests only. The integration test introduces a new library
called `testscript` [0], which is very convenient for this kind of tests.

`testscript` is based txt files, where each file is a test case that
contains some instructions. The txt file for `ignite doctor` runs
`ignite doctor` and then asserts what has changed in the filesystem,
according to some commands like `cmp`. The initial state before the
command is run is also specified in the txt file, with a list of files
designated by `-- filename --` followed by the file content.

[0] https://pkg.go.dev/github.com/rogpeppe/go-internal/testscript

* fix lint

* chore: rename xfilepath.Must

* Update ignite/pkg/gocmd/gocmd.go

Co-authored-by: Jerónimo Albi <jeronimo.albi@tendermint.com>

* Update ignite/services/doctor/doctor.go

Co-authored-by: İlker G. Öztürk <ilker@ilgooz.com>

* fix lint

---------

Co-authored-by: Alex Johnson <alex@shmeeload.xyz>
Co-authored-by: Jerónimo Albi <jeronimo.albi@tendermint.com>
Co-authored-by: İlker G. Öztürk <ilker@ilgooz.com>
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.

Create ignite doctor cmd
5 participants