authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-06-17 05:41:09-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-06-17 05:41:09-04:00
log455899668b620dfda40252501c748c0a983555bd
tree3e9afb62aad2d00361c0632d6b6e61f77c363e46
parentfda2458f6ac9c4f5ddc7d0fb70ab6194ce1adc47
parent1e9e29398a8e35917fd044f21b7cd0ab7394e5fb
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #20322 from ziglang/ci-tidy

add -Denable-tidy flag and use it in the CI

5 files changed, 30 insertions(+), 20 deletions(-)

build.zig+22
......@@ -31,9 +31,21 @@ pub fn build(b: *std.Build) !void {
3131 const skip_install_langref = b.option(bool, "no-langref", "skip copying of langref to the installation prefix") orelse skip_install_lib_files;
3232 const std_docs = b.option(bool, "std-docs", "include standard library autodocs") orelse false;
3333 const no_bin = b.option(bool, "no-bin", "skip emitting compiler binary") orelse false;
34 const enable_tidy = b.option(bool, "enable-tidy", "Check langref output HTML validity") orelse false;
3435
3536 const langref_file = generateLangRef(b);
3637 const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");
38 const check_langref = tidyCheck(b, langref_file);
39 if (enable_tidy) install_langref.step.dependOn(check_langref);
40 // Checking autodocs is disabled because tidy gives a false positive:
41 // line 304 column 9 - Warning: moved <style> tag to <head>! fix-style-tags: no to avoid.
42 // I noticed that `--show-warnings no` still incorrectly causes exit code 1.
43 // I was unable to find an alternative to tidy.
44 //const check_autodocs = tidyCheck(b, b.path("lib/docs/index.html"));
45 if (enable_tidy) {
46 test_step.dependOn(check_langref);
47 //test_step.dependOn(check_autodocs);
48 }
3749 if (!skip_install_langref) {
3850 b.getInstallStep().dependOn(&install_langref.step);
3951 }
......@@ -50,6 +62,7 @@ pub fn build(b: *std.Build) !void {
5062 .install_dir = .prefix,
5163 .install_subdir = "doc/std",
5264 });
65 //if (enable_tidy) install_std_docs.step.dependOn(check_autodocs);
5366 if (std_docs) {
5467 b.getInstallStep().dependOn(&install_std_docs.step);
5568 }
......@@ -1308,3 +1321,12 @@ fn generateLangRef(b: *std.Build) std.Build.LazyPath {
13081321 docgen_cmd.addFileArg(b.path("doc/langref.html.in"));
13091322 return docgen_cmd.addOutputFileArg("langref.html");
13101323}
1324
1325fn tidyCheck(b: *std.Build, html_file: std.Build.LazyPath) *std.Build.Step {
1326 const run_tidy = b.addSystemCommand(&.{
1327 "tidy", "--drop-empty-elements", "no", "-qe",
1328 });
1329 run_tidy.addFileArg(html_file);
1330 run_tidy.expectExitCode(0);
1331 return &run_tidy.step;
1332}
ci/aarch64-linux-debug.sh+2-5
......@@ -61,11 +61,8 @@ stage3-debug/bin/zig build test docs \
6161 -Dstatic-llvm \
6262 -Dtarget=native-native-musl \
6363 --search-prefix "$PREFIX" \
64 --zig-lib-dir "$PWD/../lib"
65
66# Look for HTML errors.
67# TODO: move this to a build.zig flag (-Denable-tidy)
68tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html"
64 --zig-lib-dir "$PWD/../lib" \
65 -Denable-tidy
6966
7067# Ensure that updating the wasm binary from this commit will result in a viable build.
7168stage3-debug/bin/zig build update-zig1
ci/aarch64-linux-release.sh+2-5
......@@ -61,11 +61,8 @@ stage3-release/bin/zig build test docs \
6161 -Dstatic-llvm \
6262 -Dtarget=native-native-musl \
6363 --search-prefix "$PREFIX" \
64 --zig-lib-dir "$PWD/../lib"
65
66# Look for HTML errors.
67# TODO: move this to a build.zig flag (-Denable-tidy)
68tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html"
64 --zig-lib-dir "$PWD/../lib" \
65 -Denable-tidy
6966
7067# Ensure that updating the wasm binary from this commit will result in a viable build.
7168stage3-release/bin/zig build update-zig1
ci/x86_64-linux-debug.sh+2-5
......@@ -69,11 +69,8 @@ stage3-debug/bin/zig build test docs \
6969 -Dstatic-llvm \
7070 -Dtarget=native-native-musl \
7171 --search-prefix "$PREFIX" \
72 --zig-lib-dir "$PWD/../lib"
73
74# Look for HTML errors.
75# TODO: move this to a build.zig flag (-Denable-tidy)
76tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html"
72 --zig-lib-dir "$PWD/../lib" \
73 -Denable-tidy
7774
7875# Ensure that updating the wasm binary from this commit will result in a viable build.
7976stage3-debug/bin/zig build update-zig1
ci/x86_64-linux-release.sh+2-5
......@@ -69,11 +69,8 @@ stage3-release/bin/zig build test docs \
6969 -Dstatic-llvm \
7070 -Dtarget=native-native-musl \
7171 --search-prefix "$PREFIX" \
72 --zig-lib-dir "$PWD/../lib"
73
74# Look for HTML errors.
75# TODO: move this to a build.zig flag (-Denable-tidy)
76tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html"
72 --zig-lib-dir "$PWD/../lib" \
73 -Denable-tidy
7774
7875# Ensure that stage3 and stage4 are byte-for-byte identical.
7976stage3-release/bin/zig build \