commit 455899668b620dfda40252501c748c0a983555bd (tree)
parent fda2458f6ac9c4f5ddc7d0fb70ab6194ce1adc47
Author: Andrew Kelley <andrew@ziglang.org>
Date: Mon, 17 Jun 2024 05:41:09 -0400
Merge pull request #20322 from ziglang/ci-tidy
add -Denable-tidy flag and use it in the CI
Diffstat:
5 files changed, 30 insertions(+), 20 deletions(-)
diff --git a/build.zig b/build.zig
@@ -31,9 +31,21 @@ pub fn build(b: *std.Build) !void {
const skip_install_langref = b.option(bool, "no-langref", "skip copying of langref to the installation prefix") orelse skip_install_lib_files;
const std_docs = b.option(bool, "std-docs", "include standard library autodocs") orelse false;
const no_bin = b.option(bool, "no-bin", "skip emitting compiler binary") orelse false;
+ const enable_tidy = b.option(bool, "enable-tidy", "Check langref output HTML validity") orelse false;
const langref_file = generateLangRef(b);
const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");
+ const check_langref = tidyCheck(b, langref_file);
+ if (enable_tidy) install_langref.step.dependOn(check_langref);
+ // Checking autodocs is disabled because tidy gives a false positive:
+ // line 304 column 9 - Warning: moved <style> tag to <head>! fix-style-tags: no to avoid.
+ // I noticed that `--show-warnings no` still incorrectly causes exit code 1.
+ // I was unable to find an alternative to tidy.
+ //const check_autodocs = tidyCheck(b, b.path("lib/docs/index.html"));
+ if (enable_tidy) {
+ test_step.dependOn(check_langref);
+ //test_step.dependOn(check_autodocs);
+ }
if (!skip_install_langref) {
b.getInstallStep().dependOn(&install_langref.step);
}
@@ -50,6 +62,7 @@ pub fn build(b: *std.Build) !void {
.install_dir = .prefix,
.install_subdir = "doc/std",
});
+ //if (enable_tidy) install_std_docs.step.dependOn(check_autodocs);
if (std_docs) {
b.getInstallStep().dependOn(&install_std_docs.step);
}
@@ -1308,3 +1321,12 @@ fn generateLangRef(b: *std.Build) std.Build.LazyPath {
docgen_cmd.addFileArg(b.path("doc/langref.html.in"));
return docgen_cmd.addOutputFileArg("langref.html");
}
+
+fn tidyCheck(b: *std.Build, html_file: std.Build.LazyPath) *std.Build.Step {
+ const run_tidy = b.addSystemCommand(&.{
+ "tidy", "--drop-empty-elements", "no", "-qe",
+ });
+ run_tidy.addFileArg(html_file);
+ run_tidy.expectExitCode(0);
+ return &run_tidy.step;
+}
diff --git a/ci/aarch64-linux-debug.sh b/ci/aarch64-linux-debug.sh
@@ -61,11 +61,8 @@ stage3-debug/bin/zig build test docs \
-Dstatic-llvm \
-Dtarget=native-native-musl \
--search-prefix "$PREFIX" \
- --zig-lib-dir "$PWD/../lib"
-
-# Look for HTML errors.
-# TODO: move this to a build.zig flag (-Denable-tidy)
-tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html"
+ --zig-lib-dir "$PWD/../lib" \
+ -Denable-tidy
# Ensure that updating the wasm binary from this commit will result in a viable build.
stage3-debug/bin/zig build update-zig1
diff --git a/ci/aarch64-linux-release.sh b/ci/aarch64-linux-release.sh
@@ -61,11 +61,8 @@ stage3-release/bin/zig build test docs \
-Dstatic-llvm \
-Dtarget=native-native-musl \
--search-prefix "$PREFIX" \
- --zig-lib-dir "$PWD/../lib"
-
-# Look for HTML errors.
-# TODO: move this to a build.zig flag (-Denable-tidy)
-tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html"
+ --zig-lib-dir "$PWD/../lib" \
+ -Denable-tidy
# Ensure that updating the wasm binary from this commit will result in a viable build.
stage3-release/bin/zig build update-zig1
diff --git a/ci/x86_64-linux-debug.sh b/ci/x86_64-linux-debug.sh
@@ -69,11 +69,8 @@ stage3-debug/bin/zig build test docs \
-Dstatic-llvm \
-Dtarget=native-native-musl \
--search-prefix "$PREFIX" \
- --zig-lib-dir "$PWD/../lib"
-
-# Look for HTML errors.
-# TODO: move this to a build.zig flag (-Denable-tidy)
-tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html"
+ --zig-lib-dir "$PWD/../lib" \
+ -Denable-tidy
# Ensure that updating the wasm binary from this commit will result in a viable build.
stage3-debug/bin/zig build update-zig1
diff --git a/ci/x86_64-linux-release.sh b/ci/x86_64-linux-release.sh
@@ -69,11 +69,8 @@ stage3-release/bin/zig build test docs \
-Dstatic-llvm \
-Dtarget=native-native-musl \
--search-prefix "$PREFIX" \
- --zig-lib-dir "$PWD/../lib"
-
-# Look for HTML errors.
-# TODO: move this to a build.zig flag (-Denable-tidy)
-tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html"
+ --zig-lib-dir "$PWD/../lib" \
+ -Denable-tidy
# Ensure that stage3 and stage4 are byte-for-byte identical.
stage3-release/bin/zig build \