mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
Merge pull request #20322 from ziglang/ci-tidy
add -Denable-tidy flag and use it in the CI
This commit is contained in:
commit
455899668b
5 changed files with 30 additions and 20 deletions
22
build.zig
22
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 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 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 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 langref_file = generateLangRef(b);
|
||||||
const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");
|
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) {
|
if (!skip_install_langref) {
|
||||||
b.getInstallStep().dependOn(&install_langref.step);
|
b.getInstallStep().dependOn(&install_langref.step);
|
||||||
}
|
}
|
||||||
|
|
@ -50,6 +62,7 @@ pub fn build(b: *std.Build) !void {
|
||||||
.install_dir = .prefix,
|
.install_dir = .prefix,
|
||||||
.install_subdir = "doc/std",
|
.install_subdir = "doc/std",
|
||||||
});
|
});
|
||||||
|
//if (enable_tidy) install_std_docs.step.dependOn(check_autodocs);
|
||||||
if (std_docs) {
|
if (std_docs) {
|
||||||
b.getInstallStep().dependOn(&install_std_docs.step);
|
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"));
|
docgen_cmd.addFileArg(b.path("doc/langref.html.in"));
|
||||||
return docgen_cmd.addOutputFileArg("langref.html");
|
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;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,11 +61,8 @@ stage3-debug/bin/zig build test docs \
|
||||||
-Dstatic-llvm \
|
-Dstatic-llvm \
|
||||||
-Dtarget=native-native-musl \
|
-Dtarget=native-native-musl \
|
||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib"
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
|
-Denable-tidy
|
||||||
# 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"
|
|
||||||
|
|
||||||
# Ensure that updating the wasm binary from this commit will result in a viable build.
|
# Ensure that updating the wasm binary from this commit will result in a viable build.
|
||||||
stage3-debug/bin/zig build update-zig1
|
stage3-debug/bin/zig build update-zig1
|
||||||
|
|
|
||||||
|
|
@ -61,11 +61,8 @@ stage3-release/bin/zig build test docs \
|
||||||
-Dstatic-llvm \
|
-Dstatic-llvm \
|
||||||
-Dtarget=native-native-musl \
|
-Dtarget=native-native-musl \
|
||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib"
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
|
-Denable-tidy
|
||||||
# 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"
|
|
||||||
|
|
||||||
# Ensure that updating the wasm binary from this commit will result in a viable build.
|
# Ensure that updating the wasm binary from this commit will result in a viable build.
|
||||||
stage3-release/bin/zig build update-zig1
|
stage3-release/bin/zig build update-zig1
|
||||||
|
|
|
||||||
|
|
@ -69,11 +69,8 @@ stage3-debug/bin/zig build test docs \
|
||||||
-Dstatic-llvm \
|
-Dstatic-llvm \
|
||||||
-Dtarget=native-native-musl \
|
-Dtarget=native-native-musl \
|
||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib"
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
|
-Denable-tidy
|
||||||
# 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"
|
|
||||||
|
|
||||||
# Ensure that updating the wasm binary from this commit will result in a viable build.
|
# Ensure that updating the wasm binary from this commit will result in a viable build.
|
||||||
stage3-debug/bin/zig build update-zig1
|
stage3-debug/bin/zig build update-zig1
|
||||||
|
|
|
||||||
|
|
@ -69,11 +69,8 @@ stage3-release/bin/zig build test docs \
|
||||||
-Dstatic-llvm \
|
-Dstatic-llvm \
|
||||||
-Dtarget=native-native-musl \
|
-Dtarget=native-native-musl \
|
||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib"
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
|
-Denable-tidy
|
||||||
# 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"
|
|
||||||
|
|
||||||
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
||||||
stage3-release/bin/zig build \
|
stage3-release/bin/zig build \
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue