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

Trying to make a compilation check before deploy, got warnings I don't understand #1341

Closed
Doshirae opened this Issue Jun 9, 2018 · 6 comments

Comments

Projects
None yet
3 participants
@Doshirae

Doshirae commented Jun 9, 2018

So, as I always forget to compile my blog before deploying it (resulting in me deploying, checking my site, seeing I didn't compiled, feeling dumb, compiling, redeploying)
I'm trying to build a check that will compile the site for me (It would have made more sense to check if the site has been compiled instead of actually compiling it, but I don't know how to do that and I'm too lazy right now to think about it)

So, my check goes like this :

Nanoc::Check.define(:has_been_compiled) do
	Nanoc::CLI.run(["compile"])
end

But I have those warnings (along with the compilation errors I talked about in #1338):

nanoc-4.9.2/lib/nanoc/cli/commands/show-plugins.rb:75: warning: already initialized constant Nanoc::CLI::Commands::ShowPlugins::PLUGIN_CLASS_ORDER

nanoc-4.9.2/lib/nanoc/cli/commands/show-plugins.rb:75: warning: previous definition of PLUGIN_CLASS_ORDER was here

nanoc-4.9.2/lib/nanoc/cli/commands/show-plugins.rb:81: warning: already initialized constant Nanoc::CLI::Commands::ShowPlugins::PLUGIN_CLASSES

nanoc-4.9.2/lib/nanoc/cli/commands/show-plugins.rb:81: warning: previous definition of PLUGIN_CLASSES was here

nanoc-4.9.2/lib/nanoc/cli/commands/view.rb:18: warning: already initialized constant Nanoc::CLI::Commands::View::DEFAULT_HANDLER_NAME

nanoc-4.9.2/lib/nanoc/cli/commands/view.rb:18: warning: previous definition of DEFAULT_HANDLER_NAME was here

So, yeah :/

@ddfreyne

This comment has been minimized.

Show comment
Hide comment
@ddfreyne

ddfreyne Jun 10, 2018

Member

Hi,

Running compile from inside a check won’t do what you expect: checks are not run in a pre-defined order, and so some checks might run before, and some checks might run after the has_been_compiled check. Therefore, some checks might run before the site is compiled.

The warnings happen because, at this point, Nanoc expects Nanoc::CLI.run (or more specifically, Nanoc::CLI.setup) to be called only once during a single nanoc run. Nanoc::CLI.setup will generate warnings when it is called twice or more, although the warnings are harmless — the constants are redefined with the same value. I’ll see what I can do about preventing this, though.

As for running compile before check/deploy: An approach that I’ve used is to create a script/deploy file, which runs nanoc followed by nanoc deploy (alternative: a make deploy target). (Though usually, I run nanoc-live and when I’m done making changes, I know that the site is up to date.)

Member

ddfreyne commented Jun 10, 2018

Hi,

Running compile from inside a check won’t do what you expect: checks are not run in a pre-defined order, and so some checks might run before, and some checks might run after the has_been_compiled check. Therefore, some checks might run before the site is compiled.

The warnings happen because, at this point, Nanoc expects Nanoc::CLI.run (or more specifically, Nanoc::CLI.setup) to be called only once during a single nanoc run. Nanoc::CLI.setup will generate warnings when it is called twice or more, although the warnings are harmless — the constants are redefined with the same value. I’ll see what I can do about preventing this, though.

As for running compile before check/deploy: An approach that I’ve used is to create a script/deploy file, which runs nanoc followed by nanoc deploy (alternative: a make deploy target). (Though usually, I run nanoc-live and when I’m done making changes, I know that the site is up to date.)

@th-h

This comment has been minimized.

Show comment
Hide comment
@th-h

th-h Jun 10, 2018

So, as I always forget to compile my blog before deploying it (resulting in me deploying, checking my site, seeing I didn't compiled, feeling dumb, compiling, redeploying)

What about using a Nanoc command or - even easier - a shell alias for deploying?

Using e.g. alias nanoc-deploy='nanoc; nanoc deploy' in your .bashrc or whereever should do the trick, I think.

th-h commented Jun 10, 2018

So, as I always forget to compile my blog before deploying it (resulting in me deploying, checking my site, seeing I didn't compiled, feeling dumb, compiling, redeploying)

What about using a Nanoc command or - even easier - a shell alias for deploying?

Using e.g. alias nanoc-deploy='nanoc; nanoc deploy' in your .bashrc or whereever should do the trick, I think.

@Doshirae

This comment has been minimized.

Show comment
Hide comment
@Doshirae

Doshirae Jun 10, 2018

Yeah you're right. A Makefile/Rakefile or a shell alias would be simpler. I just wanted to use nanoc's own commands, and not put something on top of it

Doshirae commented Jun 10, 2018

Yeah you're right. A Makefile/Rakefile or a shell alias would be simpler. I just wanted to use nanoc's own commands, and not put something on top of it

@ddfreyne

This comment has been minimized.

Show comment
Hide comment
@ddfreyne

ddfreyne Jun 14, 2018

Member

Do either of you have opinions around how you’d like this to work, or look like?

Some of my ideas:

  1. --compile flag to `nanoc check:

    % nanoc check --compile
    

    … though the following already works, is shorter, and is perhaps easier to understand:

    % nanoc; nanoc check
    
  2. A compile option in nanoc.yaml, which defaults to false, but if set to true, can be overridden on the CLI:

    % nanoc check --no-compile
    
Member

ddfreyne commented Jun 14, 2018

Do either of you have opinions around how you’d like this to work, or look like?

Some of my ideas:

  1. --compile flag to `nanoc check:

    % nanoc check --compile
    

    … though the following already works, is shorter, and is perhaps easier to understand:

    % nanoc; nanoc check
    
  2. A compile option in nanoc.yaml, which defaults to false, but if set to true, can be overridden on the CLI:

    % nanoc check --no-compile
    
@Doshirae

This comment has been minimized.

Show comment
Hide comment
@Doshirae

Doshirae Jun 14, 2018

I like the 2nd option better I think. I like the idea of having the choice through the settings in nanoc.yaml

Doshirae commented Jun 14, 2018

I like the 2nd option better I think. I like the idea of having the choice through the settings in nanoc.yaml

@ddfreyne

This comment has been minimized.

Show comment
Hide comment
@ddfreyne

ddfreyne Jul 7, 2018

Member

I’ve moved this to the features repo: nanoc/features#43.

Member

ddfreyne commented Jul 7, 2018

I’ve moved this to the features repo: nanoc/features#43.

@ddfreyne ddfreyne closed this Jul 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment