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(cmd): allow to manually skip rebuilding #4457

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(cmd): allow to manually skip rebuilding
  • Loading branch information
julienrbrt committed Jan 8, 2025
commit d66fff2c564530d2009e206290bcb80bbe0f866d
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

### Changes

- []() Add `ski-build` flag to `chain serve` command to avoid building the chain
- [#4094](/~https://github.com/ignite/cli/pull/4094) Scaffolding a multi-index map using `ignite s map foo bar baz --index foobar,foobaz` is no longer supported. Use one index instead of use `collections.IndexedMap`.
- [#4058](/~https://github.com/ignite/cli/pull/4058) Simplify scaffolded modules by including `ValidateBasic()` logic in message handler.
- [#4058](/~https://github.com/ignite/cli/pull/4058) Use `address.Codec` instead of `AccAddressFromBech32`.
Expand Down
5 changes: 5 additions & 0 deletions ignite/cmd/chain_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ production, you may want to run "appd start" manually.
c.Flags().AddFlagSet(flagSetHome())
c.Flags().AddFlagSet(flagSetCheckDependencies())
c.Flags().AddFlagSet(flagSetSkipProto())
c.Flags().AddFlagSet(flagSetSkipBuild())
c.Flags().AddFlagSet(flagSetVerbose())
c.Flags().BoolP(flagForceReset, "f", false, "force reset of the app state on start and every source change")
c.Flags().BoolP(flagResetOnce, "r", false, "reset the app state once on init")
Expand Down Expand Up @@ -183,6 +184,10 @@ func chainServe(cmd *cobra.Command, session *cliui.Session) error {
serveOptions = append(serveOptions, chain.ServeSkipProto())
}

if flagGetSkipBuild(cmd) {
serveOptions = append(serveOptions, chain.ServeSkipBuild())
}

if quitOnFail {
serveOptions = append(serveOptions, chain.QuitOnFail())
}
Expand Down
12 changes: 12 additions & 0 deletions ignite/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
flagYes = "yes"
flagClearCache = "clear-cache"
flagSkipProto = "skip-proto"
flagSkipBuild = "skip-build"

checkVersionTimeout = time.Millisecond * 600
cacheFileName = "ignite_cache.db"
Expand Down Expand Up @@ -216,6 +217,17 @@ func flagGetSkipProto(cmd *cobra.Command) bool {
return skip
}

func flagSetSkipBuild() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)
fs.Bool(flagSkipBuild, false, "skip initial build of the app (uses local binary)")
return fs
}

func flagGetSkipBuild(cmd *cobra.Command) bool {
skip, _ := cmd.Flags().GetBool(flagSkipBuild)
return skip
}

func flagSetClearCache(cmd *cobra.Command) {
cmd.PersistentFlags().Bool(flagClearCache, false, "clear the build cache (advanced)")
}
Expand Down
20 changes: 18 additions & 2 deletions ignite/services/chain/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type serveOptions struct {
forceReset bool
resetOnce bool
skipProto bool
skipBuild bool
quitOnFail bool
generateClients bool
buildTags []string
Expand Down Expand Up @@ -119,6 +120,14 @@ func ServeSkipProto() ServeOption {
}
}

// ServeSkipBuild allows to serve the app without rebuilding it.
// It looks up the binary in the PATH.
func ServeSkipBuild() ServeOption {
return func(c *serveOptions) {
c.skipBuild = true
}
}

// BuildTags set the build tags for the go build.
func BuildTags(buildTags ...string) ServeOption {
return func(c *serveOptions) {
Expand Down Expand Up @@ -190,6 +199,7 @@ func (c *Chain) Serve(ctx context.Context, cacheStorage cache.Storage, options .
serveOptions.buildTags,
shouldReset,
serveOptions.skipProto,
serveOptions.skipBuild,
serveOptions.generateClients,
)
serveOptions.resetOnce = false
Expand Down Expand Up @@ -324,7 +334,7 @@ func (c *Chain) serve(
ctx context.Context,
cacheStorage cache.Storage,
buildTags []string,
forceReset, skipProto, generateClients bool,
forceReset, skipProto, skipBuild, generateClients bool,
) error {
conf, err := c.Config()
if err != nil {
Expand Down Expand Up @@ -406,7 +416,13 @@ func (c *Chain) serve(
}

// build phase
if !isInit || appModified {
// if the app is not initialized or the source/binary has been modified
// and if the --skip-build flag is not set
if skipBuild {
c.ev.SendInfo("Skip building activated. Binary won't be rebuilt, nor refresh on changes")
}

if (!isInit || appModified) && !skipBuild {
// build the blockchain app
if err := c.build(ctx, cacheStorage, buildTags, "", skipProto, generateClients, true); err != nil {
return err
Expand Down
Loading