Skip to content

Commit 297c266

Browse files
committed
check-mirrors: update to Zig 0.15.1
1 parent fdfb0cc commit 297c266

File tree

3 files changed

+32
-35
lines changed

3 files changed

+32
-35
lines changed

.github/workflows/check-mirrors.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
# ziglang.org. This is **not** a recommended strategy for most users, but rather a special
1717
# case due to the role this repository plays in maintaining the mirror list.
1818
run: |
19-
curl -L 'https://ziglang.org/builds/zig-x86_64-linux-0.15.0-dev.885+e83776595.tar.xz' | tar -xJ
20-
mv 'zig-x86_64-linux-0.15.0-dev.885+e83776595' zig
19+
curl -L 'https://ziglang.org/download/0.15.1/zig-x86_64-linux-0.15.1.tar.xz' | tar -xJ
20+
mv 'zig-x86_64-linux-0.15.1' zig
2121
echo "$PWD/zig" >>"$GITHUB_PATH"
2222
2323
- name: Check Mirrors

check-mirrors/build.zig.zon

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
.name = .check_mirrors,
33
.version = "0.0.0",
44
.fingerprint = 0xcb408e1ecbee16fd, // Changing this has security and trust implications.
5-
.minimum_zig_version = "0.14.0",
5+
.minimum_zig_version = "0.15.1",
66
.dependencies = .{
77
.ziggy = .{
8-
.url = "git+https://github.com/kristoff-it/ziggy.git#fe3bf9389e7ff213cf3548caaf9c6f3d4bb38647",
9-
.hash = "ziggy-0.1.0-kTg8vwBEBgDFzbstERaPLr5TzM1DhfDza1we_eEXuLDL",
8+
.url = "git+https://github.com/kristoff-it/ziggy#4353b20ef2ac750e35c6d68e4eb2a07c2d7cf901",
9+
.hash = "ziggy-0.1.0-kTg8v5pABgDztlefWHceH-Sh8tVveguFC61QkmLkIRaA",
1010
},
1111
},
1212
.paths = .{

check-mirrors/main.zig

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,9 @@ const File = struct {
6262
bad_status: std.http.Status,
6363
fetch_error: GetResult.FetchError,
6464

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

105-
pub fn main() Allocator.Error!u8 {
103+
pub fn main() error{ OutOfMemory, WriteFailed }!u8 {
106104
const gpa = std.heap.smp_allocator;
107105

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

200198
var any_failures = false;
201199

202-
var out_al: std.ArrayListUnmanaged(u8) = .empty;
203-
defer out_al.deinit(gpa);
204-
const out = out_al.writer(gpa);
200+
var out_aw: std.Io.Writer.Allocating = .init(gpa);
201+
defer out_aw.deinit();
202+
const out = &out_aw.writer;
205203

206-
var error_traces_out: std.ArrayListUnmanaged(u8) = .empty;
207-
defer error_traces_out.deinit(gpa);
204+
var error_traces_out: std.Io.Writer.Allocating = .init(gpa);
205+
defer error_traces_out.deinit();
208206

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

@@ -223,7 +221,7 @@ pub fn main() Allocator.Error!u8 {
223221
try out.print("\n| `{s}` | {s} |", .{ file.name, file.version orelse "master" });
224222
for (mirrors) |m| {
225223
if (m.file_result != .ok) any_failures = true;
226-
try out.print(" {} |", .{m.file_result});
224+
try out.print(" {f} |", .{m.file_result});
227225
trace: {
228226
if (builtin.strip_debug_info) break :trace;
229227
const fe = switch (m.file_result) {
@@ -232,26 +230,26 @@ pub fn main() Allocator.Error!u8 {
232230
};
233231
const ert = fe.ert orelse break :trace;
234232
const self_info = std.debug.getSelfDebugInfo() catch break :trace;
235-
try error_traces_out.append(gpa, '\n');
236-
std.debug.writeStackTrace(ert, error_traces_out.writer(gpa), self_info, .no_color) catch |err| switch (err) {
233+
try error_traces_out.writer.writeByte('\n');
234+
std.debug.writeStackTrace(ert, &error_traces_out.writer, self_info, .no_color) catch |err| switch (err) {
237235
error.OutOfMemory => |e| return e,
238236
else => {},
239237
};
240-
try error_traces_out.append(gpa, '\n');
238+
try error_traces_out.writer.writeByte('\n');
241239
}
242240
}
243241
}
244242
try out.writeAll("\n| **Avg. time** | |");
245243
for (mirrors) |*m| {
246244
const avg_ns: u64 = if (m.ns_div == 0) 0 else m.total_ns / m.ns_div;
247-
try out.print(" {} |", .{std.fmt.fmtDuration(avg_ns)});
245+
try out.print(" {D} |", .{avg_ns});
248246
// Reset for below
249247
m.total_ns = 0;
250248
m.ns_div = 0;
251249
}
252250

253-
if (error_traces_out.items.len > 0) {
254-
try out.print("\n\n### Error Traces\n\n```{s}```", .{error_traces_out.items});
251+
if (error_traces_out.written().len > 0) {
252+
try out.print("\n\n### Error Traces\n\n```{s}```", .{error_traces_out.written()});
255253
error_traces_out.clearRetainingCapacity();
256254
}
257255

@@ -270,7 +268,7 @@ pub fn main() Allocator.Error!u8 {
270268
try out.print("\n| `{s}` | {s} |", .{ file.name, file.version orelse "master" });
271269
for (mirrors) |m| {
272270
if (m.file_result != .ok) any_failures = true;
273-
try out.print(" {} |", .{m.file_result});
271+
try out.print(" {f} |", .{m.file_result});
274272
trace: {
275273
if (builtin.strip_debug_info) break :trace;
276274
const fe = switch (m.file_result) {
@@ -279,24 +277,24 @@ pub fn main() Allocator.Error!u8 {
279277
};
280278
const ert = fe.ert orelse break :trace;
281279
const self_info = std.debug.getSelfDebugInfo() catch break :trace;
282-
try error_traces_out.append(gpa, '\n');
283-
std.debug.writeStackTrace(ert, error_traces_out.writer(gpa), self_info, .no_color) catch |err| switch (err) {
280+
try error_traces_out.writer.writeByte('\n');
281+
std.debug.writeStackTrace(ert, &error_traces_out.writer, self_info, .no_color) catch |err| switch (err) {
284282
error.OutOfMemory => |e| return e,
285283
else => {},
286284
};
287-
try error_traces_out.append(gpa, '\n');
285+
try error_traces_out.writer.writeByte('\n');
288286
}
289287
}
290288
}
291289
try out.writeAll("\n| **Avg. time** | |");
292290
for (mirrors) |*m| {
293291
const avg_ns: u64 = if (m.ns_div == 0) 0 else m.total_ns / m.ns_div;
294-
try out.print(" {} |", .{std.fmt.fmtDuration(avg_ns)});
292+
try out.print(" {D} |", .{avg_ns});
295293
// No need to reset, we're not doing any more checks
296294
}
297295

298-
if (error_traces_out.items.len > 0) {
299-
try out.print("\n\n### Error Traces\n\n```{s}```", .{error_traces_out.items});
296+
if (error_traces_out.written().len > 0) {
297+
try out.print("\n\n### Error Traces\n\n```{s}```", .{error_traces_out.written()});
300298
error_traces_out.clearRetainingCapacity();
301299
}
302300

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

311-
out_file.writeAll(out_al.items) catch |err| {
309+
out_file.writeAll(out_aw.written()) catch |err| {
312310
std.debug.panic("failed to write output: {s}", .{@errorName(err)});
313311
};
314312
}
@@ -406,14 +404,13 @@ fn httpGet(
406404
http_client: *std.http.Client,
407405
url: []const u8,
408406
) Allocator.Error!GetResult {
409-
var buf: std.ArrayList(u8) = .init(gpa);
410-
defer buf.deinit();
407+
var response: std.Io.Writer.Allocating = .init(gpa);
408+
defer response.deinit();
411409
var timer = std.time.Timer.start() catch @panic("std.time.Timer not supported");
412410
const res = http_client.fetch(.{
413411
.method = .GET,
414412
.location = .{ .url = url },
415-
.response_storage = .{ .dynamic = &buf },
416-
.max_append_size = 512 * 1024 * 1024,
413+
.response_writer = &response.writer,
417414
}) catch |err| {
418415
const ert: ?std.builtin.StackTrace = if (@errorReturnTrace()) |ert| ert: {
419416
const new_addrs = try arena.dupe(usize, ert.instruction_addresses);
@@ -428,7 +425,7 @@ fn httpGet(
428425
return .{ .bad_status = res.status };
429426
}
430427
return .{ .success = .{
431-
.data = try buf.toOwnedSlice(),
428+
.data = try response.toOwnedSlice(),
432429
.query_ns = timer.read(),
433430
} };
434431
}

0 commit comments

Comments
 (0)