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

Add warnings as errors for ex_doc #8596

Merged

Conversation

garazdawi
Copy link
Contributor

This PR adds a mechanism to scan the stderr output from ex_doc for warnings and if found fail the build.

@garazdawi garazdawi added team:VM Assigned to OTP team VM feature labels Jun 19, 2024
@garazdawi garazdawi added this to the OTP-27.1 milestone Jun 19, 2024
@garazdawi garazdawi self-assigned this Jun 19, 2024
Copy link
Contributor

github-actions bot commented Jun 19, 2024

CT Test Results

    5 files    191 suites   2h 11m 6s ⏱️
1 953 tests 1 893 ✅ 59 💤 1 ❌
2 714 runs  2 626 ✅ 87 💤 1 ❌

For more details on these failures, see this check.

Results for commit 75913d7.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@@ -4,7 +4,7 @@ ARGS=("$@")

set -eo pipefail {0}

EX_DOC=$(command -v ex_doc)
EX_DOC=$(command -v ex_doc || true)
Copy link
Contributor

Choose a reason for hiding this comment

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

I am getting "Could not find ex_doc!" because this is overriding EX_DOC.

EX_DOC=${EX_DOC:=$(command -v ex_doc || true)}

Copy link
Contributor

Choose a reason for hiding this comment

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

I just realized you are basically using EX_DOC to point to the wrapper.

Best case for the nix derivations is I can just define which EX_DOC to use directly and thread that into the wrapper.

@@ -15,7 +15,7 @@ if [ -z "${EX_DOC}" ]; then
if $ERL_TOP/otp_build download_ex_doc; then
read -p "Press any key to continue..." -n 1 -r
echo "continuing"
EX_DOC=$(command -v ex_doc)
EX_DOC=$(command -v ex_doc || true)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is fine because EX_DOC wouldn't have been defined previously

@chiroptical
Copy link
Contributor

Made some comments. Feel free to tag me if you want me to test again. Really appreciate you helping me with this!

(I don't expect you to do this) If for some reason you want to test yourself my branch is here https://github.com/chiroptical/nixpkgs/tree/test-ex-doc-updates. You would need nix and then run nix-build -A erlang_27. I am more than happy to do this because after the initial change works I want to remove some configuration from the builder and test that.

@garazdawi garazdawi force-pushed the lukas/otp/fix-ex_doc-warnings-as-errors branch 2 times, most recently from af8fd65 to 80e418e Compare June 20, 2024 09:05
@garazdawi
Copy link
Contributor Author

New attempt, you should be able to set EX_DOC=/path/to/ex_doc before running make or configure and it should use that ex_doc.

@@ -151,7 +151,7 @@ current_datetime = System.os_time() |> DateTime.from_unix!(:native)
config = [
proglang: :erlang,
source_url_pattern: source_url_pattern,
assets: Path.join(cwd, "/assets"),
assets: %{ Path.join(cwd, "/assets") => "assets" },
Copy link
Contributor

Choose a reason for hiding this comment

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

Next error I get from the nix build

warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell) or set the ELIXIR_ERL_OPTIONS="+fnu" environment variable
** (FunctionClauseError) no function clause matching in IO.chardata_to_string/1    
    
    The following arguments were given to IO.chardata_to_string/1:
    
        # 1
        %{"/build/source/lib/stdlib/doc/assets" => "assets"}

Copy link
Contributor

Choose a reason for hiding this comment

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

stack trace

    (elixir 1.16.3) lib/io.ex:687: IO.chardata_to_string/1
    (elixir 1.16.3) lib/path.ex:662: Path.join/2
    (ex_doc 0.32.1) lib/ex_doc/formatter/html.ex:294: ExDoc.Formatter.HTML.copy_assets/2
    (ex_doc 0.32.1) lib/ex_doc/formatter/html.ex:288: ExDoc.Formatter.HTML.generate_assets/3
    (ex_doc 0.32.1) lib/ex_doc/formatter/html.ex:25: ExDoc.Formatter.HTML.run/3
    (ex_doc 0.32.1) lib/ex_doc/cli.ex:69: anonymous fn/6 in ExDoc.CLI.generate/3
    (elixir 1.16.3) lib/enum.ex:1700: Enum."-map/2-lists^map/1-1-"/2
    (elixir 1.16.3) lib/kernel/cli.ex:136: anonymous fn/3 in Kernel.CLI.exec_fun/2

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this comes from https://github.com/elixir-lang/ex_doc/blob/v0.34.0/CHANGELOG.md#v0340-2024-05-30? i.e. I think this requires a specific version of ex_doc now. Unsure if that is intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will always require a specific version of ex_doc, which one is listed in https://github.com/erlang/otp/blob/master/make/ex_doc_vsn

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, okay! Let me update that and keep testing thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are some bugs in v0.34.0 of ex_doc that cause some issues, so you may have to wait for v0.35.0 in order for everything to pass.

@wojtekmach
Copy link
Contributor

@garazdawi as you may know we have an open PR that adds --warnings-as-errors to ExDoc (elixir-lang/ex_doc#1831) which I think would handle most if not all warnings that this PR catches. So if you'd be OK with relying on ExDoc for this instead we can try to push it over the finish line soon.

@@ -52,15 +52,17 @@ else
DOC_TARGETS?=html
endif

EX_DOC_WARNINGS_AS_ERRORS?=true
Copy link
Contributor

Choose a reason for hiding this comment

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

Last question, should this be false by default?

I immediately had to turn it off in the nix build. Which worked by the way! Here is the simplification I was able to do with this https://github.com/chiroptical/nixpkgs/pull/4/files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No I want it to be on by default as there should never be any warnings if you use the correct ExDoc vsn.

Copy link
Contributor

Choose a reason for hiding this comment

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

I get this from the build with that set to true.

warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell) or set the ELIXIR_ERL_OPTIONS="+fnu" environment variable

I guess you may want to set this in the wrapper then?

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 would be something that needs fixing in nix I think. The Erlang VM thinks that filenames should be encoded in latin1 because the locale is not set to utf8.

The elixir nix package seems to set LANG and LC_TYPE to C.UTF-8 which should do the trick.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess so! Really appreciate you looking through all this.

@garazdawi
Copy link
Contributor Author

@wojtekmach I would be happy to use a built-in ex_doc warnings as errors. I did this PR because a bunch of warnings slipped trough in Erlang/OTP and it did not seem like there was much interest in getting elixir-lang/ex_doc#1831 merged anytime soon.

Copy link
Contributor

@chiroptical chiroptical left a comment

Choose a reason for hiding this comment

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

From my standpoint, it looks great!

@garazdawi garazdawi force-pushed the lukas/otp/fix-ex_doc-warnings-as-errors branch from 80e418e to 75913d7 Compare June 24, 2024 12:04
@garazdawi garazdawi added the testing currently being tested, tag is used by OTP internal CI label Jun 24, 2024
@garazdawi garazdawi merged commit d9f922e into erlang:master Jun 25, 2024
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants