Skip to content

check-mirrors: update to Zig 0.15.0-dev.1380+e98aeeb73 #516

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/check-mirrors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
# ziglang.org. This is **not** a recommended strategy for most users, but rather a special
# case due to the role this repository plays in maintaining the mirror list.
run: |
curl -L 'https://ziglang.org/builds/zig-x86_64-linux-0.15.0-dev.885+e83776595.tar.xz' | tar -xJ
mv 'zig-x86_64-linux-0.15.0-dev.885+e83776595' zig
curl -L 'https://ziglang.org/builds/zig-x86_64-linux-0.15.0-dev.1380+e98aeeb73.tar.xz' | tar -xJ
mv 'zig-x86_64-linux-0.15.0-dev.1380+e98aeeb73' zig
echo "$PWD/zig" >>"$GITHUB_PATH"

- name: Check Mirrors
Expand Down
4 changes: 2 additions & 2 deletions check-mirrors/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
.minimum_zig_version = "0.14.0",
.dependencies = .{
.ziggy = .{
.url = "git+https://github.com/kristoff-it/ziggy.git#fe3bf9389e7ff213cf3548caaf9c6f3d4bb38647",
.hash = "ziggy-0.1.0-kTg8vwBEBgDFzbstERaPLr5TzM1DhfDza1we_eEXuLDL",
.url = "git+https://github.com/kristoff-it/ziggy#e95c85cb58773c43e9d94c0b9422ae84697e68a1",
.hash = "ziggy-0.1.0-kTg8v0NABgAXpvuVY5f4frwE7xvH44KnARR0q6QB1_1a",
},
},
.paths = .{
Expand Down
48 changes: 23 additions & 25 deletions check-mirrors/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,9 @@ const File = struct {
bad_status: std.http.Status,
fetch_error: GetResult.FetchError,

pub fn format(res: Result, comptime fmt: []const u8, options: std.fmt.FormatOptions, w: anytype) !void {
if (fmt.len != 0) std.fmt.invalidFmtError(fmt, res);
_ = options;
pub fn format(res: Result, w: *std.Io.Writer) std.Io.Writer.Error!void {
switch (res) {
.ok => |query_ns| try w.print("{}", .{std.fmt.fmtDuration(query_ns)}),
.ok => |query_ns| try w.print("{D}", .{query_ns}),
.content_mismatch => try w.writeAll(":warning: incorrect contents"),
.fetch_error => |fe| try w.print(":warning: error: {s}", .{@errorName(fe.err)}),
.bad_status => |s| try w.print(":warning: bad status: {d} {s}", .{ @intFromEnum(s), s.phrase() orelse "?" }),
Expand Down Expand Up @@ -102,7 +100,7 @@ const Mirror = struct {
}
};

pub fn main() Allocator.Error!u8 {
pub fn main() error{ OutOfMemory, WriteFailed }!u8 {
const gpa = std.heap.smp_allocator;

var arena_state: std.heap.ArenaAllocator = .init(gpa);
Expand Down Expand Up @@ -199,12 +197,12 @@ pub fn main() Allocator.Error!u8 {

var any_failures = false;

var out_al: std.ArrayListUnmanaged(u8) = .empty;
defer out_al.deinit(gpa);
const out = out_al.writer(gpa);
var out_aw: std.Io.Writer.Allocating = .init(gpa);
defer out_aw.deinit();
const out = &out_aw.writer;

var error_traces_out: std.ArrayListUnmanaged(u8) = .empty;
defer error_traces_out.deinit(gpa);
var error_traces_out: std.Io.Writer.Allocating = .init(gpa);
defer error_traces_out.deinit();

try out.writeAll("## Tarballs\n\n");

Expand All @@ -223,7 +221,7 @@ pub fn main() Allocator.Error!u8 {
try out.print("\n| `{s}` | {s} |", .{ file.name, file.version orelse "master" });
for (mirrors) |m| {
if (m.file_result != .ok) any_failures = true;
try out.print(" {} |", .{m.file_result});
try out.print(" {f} |", .{m.file_result});
trace: {
if (builtin.strip_debug_info) break :trace;
const fe = switch (m.file_result) {
Expand All @@ -232,26 +230,26 @@ pub fn main() Allocator.Error!u8 {
};
const ert = fe.ert orelse break :trace;
const self_info = std.debug.getSelfDebugInfo() catch break :trace;
try error_traces_out.append(gpa, '\n');
std.debug.writeStackTrace(ert, error_traces_out.writer(gpa), self_info, .no_color) catch |err| switch (err) {
try error_traces_out.writer.writeByte('\n');
std.debug.writeStackTrace(ert, &error_traces_out.writer, self_info, .no_color) catch |err| switch (err) {
error.OutOfMemory => |e| return e,
else => {},
};
try error_traces_out.append(gpa, '\n');
try error_traces_out.writer.writeByte('\n');
}
}
}
try out.writeAll("\n| **Avg. time** | |");
for (mirrors) |*m| {
const avg_ns: u64 = if (m.ns_div == 0) 0 else m.total_ns / m.ns_div;
try out.print(" {} |", .{std.fmt.fmtDuration(avg_ns)});
try out.print(" {D} |", .{avg_ns});
// Reset for below
m.total_ns = 0;
m.ns_div = 0;
}

if (error_traces_out.items.len > 0) {
try out.print("\n\n### Error Traces\n\n```{s}```", .{error_traces_out.items});
if (error_traces_out.getWritten().len > 0) {
try out.print("\n\n### Error Traces\n\n```{s}```", .{error_traces_out.getWritten()});
error_traces_out.clearRetainingCapacity();
}

Expand All @@ -270,7 +268,7 @@ pub fn main() Allocator.Error!u8 {
try out.print("\n| `{s}` | {s} |", .{ file.name, file.version orelse "master" });
for (mirrors) |m| {
if (m.file_result != .ok) any_failures = true;
try out.print(" {} |", .{m.file_result});
try out.print(" {f} |", .{m.file_result});
trace: {
if (builtin.strip_debug_info) break :trace;
const fe = switch (m.file_result) {
Expand All @@ -279,24 +277,24 @@ pub fn main() Allocator.Error!u8 {
};
const ert = fe.ert orelse break :trace;
const self_info = std.debug.getSelfDebugInfo() catch break :trace;
try error_traces_out.append(gpa, '\n');
std.debug.writeStackTrace(ert, error_traces_out.writer(gpa), self_info, .no_color) catch |err| switch (err) {
try error_traces_out.writer.writeByte('\n');
std.debug.writeStackTrace(ert, &error_traces_out.writer, self_info, .no_color) catch |err| switch (err) {
error.OutOfMemory => |e| return e,
else => {},
};
try error_traces_out.append(gpa, '\n');
try error_traces_out.writer.writeByte('\n');
}
}
}
try out.writeAll("\n| **Avg. time** | |");
for (mirrors) |*m| {
const avg_ns: u64 = if (m.ns_div == 0) 0 else m.total_ns / m.ns_div;
try out.print(" {} |", .{std.fmt.fmtDuration(avg_ns)});
try out.print(" {D} |", .{avg_ns});
// No need to reset, we're not doing any more checks
}

if (error_traces_out.items.len > 0) {
try out.print("\n\n### Error Traces\n\n```{s}```", .{error_traces_out.items});
if (error_traces_out.getWritten().len > 0) {
try out.print("\n\n### Error Traces\n\n```{s}```", .{error_traces_out.getWritten()});
error_traces_out.clearRetainingCapacity();
}

Expand All @@ -308,7 +306,7 @@ pub fn main() Allocator.Error!u8 {
};
defer out_file.close();

out_file.writeAll(out_al.items) catch |err| {
out_file.writeAll(out_aw.getWritten()) catch |err| {
std.debug.panic("failed to write output: {s}", .{@errorName(err)});
};
}
Expand Down
Loading