Skip to content

Commit c0b8db3

Browse files
committed
Introduce CI workflow to check mirrors
Every 24 hours, fetch a bunch of tarballs from ziglang.org and every mirror, to check that they are all working as intended. A summary is emitted in a Markdown table which GitHub will render on the workflow run page. If any mirror fails to serve a tarball or serves one which differs from the one on ziglang.org, the workflow sends me (@mlugg) a push notification so I see the issue and can address it. As well as running on a cron schedule, this workflow can also be manually triggered and runs when the mirror list file is edited.
1 parent d3c8c74 commit c0b8db3

File tree

7 files changed

+581
-0
lines changed

7 files changed

+581
-0
lines changed

.github/workflows/check-mirrors.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check Mirrors
2+
on:
3+
schedule: [{ cron: "0 22 * * *" }]
4+
workflow_dispatch: null
5+
pull_request: { paths: ["assets/community-mirrors.ziggy"] }
6+
jobs:
7+
check:
8+
runs-on: [self-hosted, website]
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Check Mirrors
12+
run: |
13+
cd check-mirrors
14+
/home/ci/deps/zig-linux-x86_64-0.14.0/zig build run -- ../assets/community-mirrors.ziggy "$GITHUB_STEP_SUMMARY"
15+
notify-failure:
16+
runs-on: [self-hosted, website]
17+
needs: [check]
18+
if: ${{ always() && (needs.check.result == 'failure' || needs.check.result == 'timed_out') }}
19+
steps:
20+
- name: Send Notification
21+
env:
22+
PUSHOVER_USER: ${{ secrets.MIRROR_CHECK_PUSHOVER_USER }}
23+
PUSHOVER_TOKEN: ${{ secrets.MIRROR_CHECK_PUSHOVER_TOKEN }}
24+
run: curl -s
25+
-F user="$PUSHOVER_USER"
26+
-F token="$PUSHOVER_TOKEN"
27+
-F message="Zig download mirror validation failed"
28+
https://api.pushover.net/1/messages.json

check-mirrors/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# check-mirrors
2+
3+
This is a small utility which checks the functionality of all listed community mirrors. It does this
4+
by fetching a subset of available tarballs and signatures from each mirror, and checking that the
5+
returned files exactly match the corresponding files served by ziglang.org.
6+
7+
This check is automatically run once per day by the 'check-mirrors' workflow. It also runs when a PR
8+
modifies the mirror list.

check-mirrors/build.zig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
pub fn build(b: *std.Build) void {
2+
const target = b.standardTargetOptions(.{});
3+
const optimize = b.standardOptimizeOption(.{});
4+
5+
const ziggy = b.dependency("ziggy", .{
6+
.target = target,
7+
.optimize = optimize,
8+
});
9+
10+
const exe = b.addExecutable(.{
11+
.name = "check-mirrors",
12+
.root_module = b.createModule(.{
13+
.root_source_file = b.path("main.zig"),
14+
.target = target,
15+
.optimize = optimize,
16+
.imports = &.{
17+
.{ .name = "ziggy", .module = ziggy.module("ziggy") },
18+
},
19+
}),
20+
});
21+
b.installArtifact(exe);
22+
23+
const run = b.addRunArtifact(exe);
24+
if (b.args) |args| run.addArgs(args);
25+
b.step("run", "Run check-mirrors").dependOn(&run.step);
26+
}
27+
28+
const std = @import("std");

check-mirrors/build.zig.zon

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.{
2+
.name = .check_mirrors,
3+
.version = "0.0.0",
4+
.fingerprint = 0xcb408e1ecbee16fd, // Changing this has security and trust implications.
5+
.minimum_zig_version = "0.14.0",
6+
.dependencies = .{
7+
.ziggy = .{
8+
.url = "git+https://github.com/kristoff-it/ziggy.git#fe3bf9389e7ff213cf3548caaf9c6f3d4bb38647",
9+
.hash = "ziggy-0.1.0-kTg8vwBEBgDFzbstERaPLr5TzM1DhfDza1we_eEXuLDL",
10+
},
11+
},
12+
.paths = .{
13+
"build.zig",
14+
"build.zig.zon",
15+
"src",
16+
},
17+
}

0 commit comments

Comments
 (0)