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

Updating Hugo detection logic and bumping up version #2009

Merged
merged 6 commits into from
Jun 5, 2023

Conversation

harryli0108
Copy link
Contributor

@harryli0108 harryli0108 commented May 31, 2023

Due to new Hugo versions changed the config name convention from config.toml etc. to hugo.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.

@harryli0108 harryli0108 requested a review from a team as a code owner May 31, 2023 20:22
Copy link
Contributor

@cormacpayne cormacpayne left a 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

build/constants.yaml Outdated Show resolved Hide resolved
src/Detector/Hugo/HugoDetector.cs Outdated Show resolved Hide resolved
src/Detector/Hugo/HugoDetector.cs Outdated Show resolved Hide resolved
src/Detector/Hugo/HugoDetector.cs Outdated Show resolved Hide resolved
src/Detector/Hugo/HugoDetector.cs Outdated Show resolved Hide resolved
@@ -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.
Copy link
Contributor

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.

@@ -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.
Copy link
Contributor

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

Copy link
Member

@pauld-msft pauld-msft left a 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 :)

src/Detector/Hugo/HugoDetector.cs Outdated Show resolved Hide resolved
build/constants.yaml Outdated Show resolved Hide resolved
src/Detector/Hugo/HugoDetector.cs Outdated Show resolved Hide resolved
@@ -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.
Copy link
Contributor

@daniv-msft daniv-msft May 31, 2023

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.

Copy link
Contributor Author

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")]
Copy link
Contributor

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?

Copy link
Contributor Author

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.

daniv-msft
daniv-msft previously approved these changes Jun 1, 2023
Copy link
Contributor

@daniv-msft daniv-msft left a 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

Copy link
Contributor

@waliMSFT waliMSFT left a 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.

Copy link
Contributor

@cormacpayne cormacpayne left a 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

@@ -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.
Copy link
Contributor

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)
Copy link
Contributor

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());
Copy link
Contributor

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.

Copy link
Contributor

@cormacpayne cormacpayne left a comment

Choose a reason for hiding this comment

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

:shipit:

@harryli0108 harryli0108 merged commit a4feb35 into main Jun 5, 2023
1 check passed
@jpconstantineau
Copy link

Has this been released yet?
I am having an issue that this PR solves. (wrong/old hugo version)
How do I get my github action to use this fix? Will it once it get released?

@harryli0108
Copy link
Contributor Author

@jpconstantineau Hi! Sorry for the delay here. We have a release inbound today that includes this fix.
In order to use this in GH Action, depending on if you're using Azure Web Apps task or the new Container App task. With the Web Apps one, I think you might need to wait for the App service team to include this fix in their new release. But with Container Apps task, you can either specify the oryx build image used in your Dockerfile, or you might need to wait for our team to release the next builder.

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.

@jpconstantineau
Copy link

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)

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.

None yet

6 participants