-
Notifications
You must be signed in to change notification settings - Fork 171
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
Updating Hugo detection logic and bumping up version #2009
Conversation
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.
A few comments to take a look at
doc/runtimes/hugo.md
Outdated
@@ -16,6 +16,8 @@ The Hugo toolset is run when one of following conditions met: | |||
2. Recursively look up config directory: `config/**/*.yaml`, `config/**/*.toml`, | |||
`config/**/*.yml` or `config/**/*.json` configuration files in sub-directories. | |||
|
|||
**Note**: Starting from [Hugo version `0.110.0`](https://gohugo.io/getting-started/configuration/#hugotoml-vs-configtoml), configuration file name has changed from `config.toml` etc. to `hugo.toml` etc. Please note the old naming convention is still supported. |
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.
We could probably scrap this line in favor of updating the (1.) bullet above to mention that we look for the hugo.*
equivalent files.
doc/runtimes/hugo.md
Outdated
@@ -16,6 +16,8 @@ The Hugo toolset is run when one of following conditions met: | |||
2. Recursively look up config directory: `config/**/*.yaml`, `config/**/*.toml`, | |||
`config/**/*.yml` or `config/**/*.json` configuration files in sub-directories. | |||
|
|||
**Note**: Starting from [Hugo version `0.110.0`](https://gohugo.io/getting-started/configuration/#hugotoml-vs-configtoml), configuration file name has changed from `config.toml` etc. to `hugo.toml` etc. Please note the old naming convention is still supported. |
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.
nit: let's keep the maximum length of a line in Markdown to 120 characters
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.
Few minor things. Overall, looks good to me, so happy to approve once a few minor things are resolved.
Also, thanks for adding the test!
Edit: also noticed builds are failing, and cormac had some good comments to look at :)
doc/runtimes/hugo.md
Outdated
@@ -12,7 +12,7 @@ details on components and configuration of build images. | |||
|
|||
The Hugo toolset is run when one of following conditions met: | |||
|
|||
1. `config.yaml`, `config.toml`, `config.yml` or `config.json` configuration files in root of repo. | |||
1. `config.yaml`, `config.toml`, `config.yml`, `config.json` or `hugo.*` equivalent configuration files in root of repo. |
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.
Please consider writing specifically hugo.toml
, hugo.yaml
, or hugo.json
. I feel like in the doc being very precise about what we support is important, especially as customers might look for specific strings/find these from search engines.
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.
That makes sense! Updating it right now
@@ -78,8 +79,8 @@ public void IsHugoApp_ReturnsTrue_ForAllSupportedConfigurationKeys_InTomlFile(st | |||
} | |||
|
|||
[Theory] | |||
[InlineData(HugoConstants.JsonFileName)] | |||
[InlineData(HugoConstants.ConfigFolderName, HugoConstants.JsonFileName)] | |||
[InlineData("config.json")] |
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.
Just curious: we can't directly use HugoConstants.JsonFileNames.First()
in these InlineData fields to remain consistent?
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.
So the InlineData requires const variables, and since HugoConstants.JsonFileNames
and other file names are now a static readonly list, it doesn't allow to use it there.
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.
Looks good to me! Thanks for fixing 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.
Looks good to me as well.
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.
A few comments we should take care of before merging
doc/runtimes/hugo.md
Outdated
@@ -12,7 +12,7 @@ details on components and configuration of build images. | |||
|
|||
The Hugo toolset is run when one of following conditions met: | |||
|
|||
1. `config.yaml`, `config.toml`, `config.yml` or `config.json` configuration files in root of repo. | |||
1. `config/hugo.yaml`, `config/hugo.toml`, `config/hugo.yml` or `config/hugo.json` configuration files in root of repo. |
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 actually think we should word this line differently as users may interpret the config
part of each file type as the directory name, especially because our second bullet below mentions we search the config
directory recursively.
I'd be in favor of writing this as something like the following:
1. Any supported config.*
files at the root of the repository: config.toml
, config.yaml
, config.yml
, config.json
2. Any supported hugo.*
files at the root of the repository: hugo.toml
, hugo.yaml
, hugo.yml
, hugo.json
3. Recursively look up supported files in the config
directory: config/**/*.toml
, config/**/*.toml
config/**/*.yml
, config/**/*.json
[InlineData(HugoConstants.TomlFileName)] | ||
[InlineData(HugoConstants.ConfigFolderName, HugoConstants.TomlFileName)] | ||
[InlineData("config.toml")] | ||
[InlineData(HugoConstants.ConfigFolderName, "config.toml")] | ||
public void IsHugoApp_ReturnsTrue_ForAppWithConfigTomlFile(params string[] subPaths) |
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.
Let's introduce the same set of tests that we have in this file but for the hugo.*
files that we now support to ensure that we're detecting them properly.
@@ -63,7 +64,7 @@ public void IsHugoApp_ReturnsTrue_ForAllSupportedConfigurationKeys_InTomlFile(st | |||
{ | |||
// Arrange | |||
var appDir = CreateAppDir(); | |||
WriteFile($"{configurationKeyName}=\"test\"", appDir, HugoConstants.TomlFileName); | |||
WriteFile($"{configurationKeyName}=\"test\"", appDir, HugoConstants.TomlFileNames.First()); |
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.
We should extract out the name of the file to be an additional argument of this test to ensure that the support configuration keys work for all versions of .toml
file.
This comment also applies for the other tests below where we've made the same change.
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.
Has this been released yet? |
@jpconstantineau Hi! Sorry for the delay here. We have a release inbound today that includes this fix. Meanwhile, I would encourage you to post this as an issue if you continue to experience it since comments in closed PRs could be accidentally ignored. |
Thanks. It's web app indeed. I'll wait for the release here first. Hopefully, the GitHub action doesn't need updating itself but simply picks up the latest release (or the one the web app team points to through config) |
Due to new Hugo versions changed the config name convention from
config.toml
etc. tohugo.toml
etc., this PR updates the detection logic and make sure the new naming convention is also supported while not affecting the old ones. This PR also added a new modified sample app and a test case in order to make sure new naming convention is correctly supported.And because this change starts from Hugo version 0.110.0, this PR also upgrades the current hugo version to the latest
0.112.5
.