authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-06-16 20:03:14-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-06-17 00:10:35-07:00
log651225c2d4d86c661dba134eee2e3af421bf04b0
tree35d4908e2e67384b5d2026d2c44358c99807e4ad
parentfda2458f6ac9c4f5ddc7d0fb70ab6194ce1adc47

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

Eliminates a TODO from the CI scripts; makes it easier to check validity of html when working on the langref locally.

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

build.zig+18
...@@ -31,10 +31,18 @@ pub fn build(b: *std.Build) !void {...@@ -31,10 +31,18 @@ pub fn build(b: *std.Build) !void {
31 const skip_install_langref = b.option(bool, "no-langref", "skip copying of langref to the installation prefix") orelse skip_install_lib_files;31 const skip_install_langref = b.option(bool, "no-langref", "skip copying of langref to the installation prefix") orelse skip_install_lib_files;
32 const std_docs = b.option(bool, "std-docs", "include standard library autodocs") orelse false;32 const std_docs = b.option(bool, "std-docs", "include standard library autodocs") orelse false;
33 const no_bin = b.option(bool, "no-bin", "skip emitting compiler binary") orelse false;33 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
35 const langref_file = generateLangRef(b);36 const langref_file = generateLangRef(b);
36 const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");37 const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");
38 const check_langref = tidyCheck(b, langref_file);
39 const check_autodocs = tidyCheck(b, b.path("lib/docs/index.html"));
40 if (enable_tidy) {
41 test_step.dependOn(check_langref);
42 test_step.dependOn(check_autodocs);
43 }
37 if (!skip_install_langref) {44 if (!skip_install_langref) {
45 if (enable_tidy) install_langref.step.dependOn(check_langref);
38 b.getInstallStep().dependOn(&install_langref.step);46 b.getInstallStep().dependOn(&install_langref.step);
39 }47 }
4048
...@@ -51,6 +59,7 @@ pub fn build(b: *std.Build) !void {...@@ -51,6 +59,7 @@ pub fn build(b: *std.Build) !void {
51 .install_subdir = "doc/std",59 .install_subdir = "doc/std",
52 });60 });
53 if (std_docs) {61 if (std_docs) {
62 if (enable_tidy) install_std_docs.step.dependOn(check_autodocs);
54 b.getInstallStep().dependOn(&install_std_docs.step);63 b.getInstallStep().dependOn(&install_std_docs.step);
55 }64 }
5665
...@@ -1308,3 +1317,12 @@ fn generateLangRef(b: *std.Build) std.Build.LazyPath {...@@ -1308,3 +1317,12 @@ fn generateLangRef(b: *std.Build) std.Build.LazyPath {
1308 docgen_cmd.addFileArg(b.path("doc/langref.html.in"));1317 docgen_cmd.addFileArg(b.path("doc/langref.html.in"));
1309 return docgen_cmd.addOutputFileArg("langref.html");1318 return docgen_cmd.addOutputFileArg("langref.html");
1310}1319}
1320
1321fn tidyCheck(b: *std.Build, html_file: std.Build.LazyPath) *std.Build.Step {
1322 const run_tidy = b.addSystemCommand(&.{
1323 "tidy", "--drop-empty-elements", "no", "-qe",
1324 });
1325 run_tidy.addFileArg(html_file);
1326 run_tidy.expectExitCode(0);
1327 return &run_tidy.step;
1328}
ci/aarch64-linux-debug.sh+2-5
...@@ -61,11 +61,8 @@ stage3-debug/bin/zig build test docs \...@@ -61,11 +61,8 @@ stage3-debug/bin/zig build test docs \
61 -Dstatic-llvm \61 -Dstatic-llvm \
62 -Dtarget=native-native-musl \62 -Dtarget=native-native-musl \
63 --search-prefix "$PREFIX" \63 --search-prefix "$PREFIX" \
64 --zig-lib-dir "$PWD/../lib"64 --zig-lib-dir "$PWD/../lib" \
6565 -Denable-tidy
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"
6966
70# Ensure that updating the wasm binary from this commit will result in a viable build.67# Ensure that updating the wasm binary from this commit will result in a viable build.
71stage3-debug/bin/zig build update-zig168stage3-debug/bin/zig build update-zig1
ci/aarch64-linux-release.sh+2-5
...@@ -61,11 +61,8 @@ stage3-release/bin/zig build test docs \...@@ -61,11 +61,8 @@ stage3-release/bin/zig build test docs \
61 -Dstatic-llvm \61 -Dstatic-llvm \
62 -Dtarget=native-native-musl \62 -Dtarget=native-native-musl \
63 --search-prefix "$PREFIX" \63 --search-prefix "$PREFIX" \
64 --zig-lib-dir "$PWD/../lib"64 --zig-lib-dir "$PWD/../lib" \
6565 -Denable-tidy
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"
6966
70# Ensure that updating the wasm binary from this commit will result in a viable build.67# Ensure that updating the wasm binary from this commit will result in a viable build.
71stage3-release/bin/zig build update-zig168stage3-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 \...@@ -69,11 +69,8 @@ stage3-debug/bin/zig build test docs \
69 -Dstatic-llvm \69 -Dstatic-llvm \
70 -Dtarget=native-native-musl \70 -Dtarget=native-native-musl \
71 --search-prefix "$PREFIX" \71 --search-prefix "$PREFIX" \
72 --zig-lib-dir "$PWD/../lib"72 --zig-lib-dir "$PWD/../lib" \
7373 -Denable-tidy
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"
7774
78# Ensure that updating the wasm binary from this commit will result in a viable build.75# Ensure that updating the wasm binary from this commit will result in a viable build.
79stage3-debug/bin/zig build update-zig176stage3-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 \...@@ -69,11 +69,8 @@ stage3-release/bin/zig build test docs \
69 -Dstatic-llvm \69 -Dstatic-llvm \
70 -Dtarget=native-native-musl \70 -Dtarget=native-native-musl \
71 --search-prefix "$PREFIX" \71 --search-prefix "$PREFIX" \
72 --zig-lib-dir "$PWD/../lib"72 --zig-lib-dir "$PWD/../lib" \
7373 -Denable-tidy
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"
7774
78# Ensure that stage3 and stage4 are byte-for-byte identical.75# Ensure that stage3 and stage4 are byte-for-byte identical.
79stage3-release/bin/zig build \76stage3-release/bin/zig build \