add zeit to project/integrate with atom.zig
This commit is contained in:
parent
d6fe57b11b
commit
eb16d2396a
3 changed files with 40 additions and 3 deletions
16
build.zig
16
build.zig
|
@ -6,6 +6,12 @@ pub fn build(b: *std.Build) void {
|
||||||
const integration = b.option(bool, "integration", "Run integration tests") orelse false;
|
const integration = b.option(bool, "integration", "Run integration tests") orelse false;
|
||||||
const provider = b.option([]const u8, "provider", "Test specific provider (github, gitlab, codeberg, sourcehut)");
|
const provider = b.option([]const u8, "provider", "Test specific provider (github, gitlab, codeberg, sourcehut)");
|
||||||
|
|
||||||
|
// Add Zeit dependency
|
||||||
|
const zeit_dep = b.dependency("zeit", .{
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = "release-tracker",
|
.name = "release-tracker",
|
||||||
.root_source_file = b.path("src/main.zig"),
|
.root_source_file = b.path("src/main.zig"),
|
||||||
|
@ -13,6 +19,8 @@ pub fn build(b: *std.Build) void {
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
exe.root_module.addImport("zeit", zeit_dep.module("zeit"));
|
||||||
|
|
||||||
b.installArtifact(exe);
|
b.installArtifact(exe);
|
||||||
|
|
||||||
const run_cmd = b.addRunArtifact(exe);
|
const run_cmd = b.addRunArtifact(exe);
|
||||||
|
@ -31,6 +39,8 @@ pub fn build(b: *std.Build) void {
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
unit_tests.root_module.addImport("zeit", zeit_dep.module("zeit"));
|
||||||
|
|
||||||
const run_unit_tests = b.addRunArtifact(unit_tests);
|
const run_unit_tests = b.addRunArtifact(unit_tests);
|
||||||
|
|
||||||
const test_step = b.step("test", "Run unit tests");
|
const test_step = b.step("test", "Run unit tests");
|
||||||
|
@ -45,6 +55,8 @@ pub fn build(b: *std.Build) void {
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
integration_tests.root_module.addImport("zeit", zeit_dep.module("zeit"));
|
||||||
|
|
||||||
// Add filter for specific provider if specified
|
// Add filter for specific provider if specified
|
||||||
if (provider) |p| {
|
if (provider) |p| {
|
||||||
const filter = std.fmt.allocPrint(b.allocator, "{s} provider", .{p}) catch @panic("OOM");
|
const filter = std.fmt.allocPrint(b.allocator, "{s} provider", .{p}) catch @panic("OOM");
|
||||||
|
@ -68,6 +80,7 @@ pub fn build(b: *std.Build) void {
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.filters = &[_][]const u8{"GitHub provider"},
|
.filters = &[_][]const u8{"GitHub provider"},
|
||||||
});
|
});
|
||||||
|
github_tests.root_module.addImport("zeit", zeit_dep.module("zeit"));
|
||||||
|
|
||||||
const gitlab_tests = b.addTest(.{
|
const gitlab_tests = b.addTest(.{
|
||||||
.name = "gitlab-tests",
|
.name = "gitlab-tests",
|
||||||
|
@ -76,6 +89,7 @@ pub fn build(b: *std.Build) void {
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.filters = &[_][]const u8{"GitLab provider"},
|
.filters = &[_][]const u8{"GitLab provider"},
|
||||||
});
|
});
|
||||||
|
gitlab_tests.root_module.addImport("zeit", zeit_dep.module("zeit"));
|
||||||
|
|
||||||
const codeberg_tests = b.addTest(.{
|
const codeberg_tests = b.addTest(.{
|
||||||
.name = "codeberg-tests",
|
.name = "codeberg-tests",
|
||||||
|
@ -84,6 +98,7 @@ pub fn build(b: *std.Build) void {
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.filters = &[_][]const u8{"Codeberg provider"},
|
.filters = &[_][]const u8{"Codeberg provider"},
|
||||||
});
|
});
|
||||||
|
codeberg_tests.root_module.addImport("zeit", zeit_dep.module("zeit"));
|
||||||
|
|
||||||
const sourcehut_tests = b.addTest(.{
|
const sourcehut_tests = b.addTest(.{
|
||||||
.name = "sourcehut-tests",
|
.name = "sourcehut-tests",
|
||||||
|
@ -92,6 +107,7 @@ pub fn build(b: *std.Build) void {
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.filters = &[_][]const u8{"SourceHut provider"},
|
.filters = &[_][]const u8{"SourceHut provider"},
|
||||||
});
|
});
|
||||||
|
sourcehut_tests.root_module.addImport("zeit", zeit_dep.module("zeit"));
|
||||||
|
|
||||||
github_step.dependOn(&b.addRunArtifact(github_tests).step);
|
github_step.dependOn(&b.addRunArtifact(github_tests).step);
|
||||||
gitlab_step.dependOn(&b.addRunArtifact(gitlab_tests).step);
|
gitlab_step.dependOn(&b.addRunArtifact(gitlab_tests).step);
|
||||||
|
|
18
build.zig.zon
Normal file
18
build.zig.zon
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
.{
|
||||||
|
.name = .release_tracker,
|
||||||
|
.version = "0.1.0",
|
||||||
|
.fingerprint = 0x72165610c81e9c00,
|
||||||
|
.dependencies = .{
|
||||||
|
.zeit = .{
|
||||||
|
.url = "https://github.com/rockorager/zeit/archive/refs/tags/v0.6.0.tar.gz",
|
||||||
|
.hash = "zeit-0.0.0-5I6bk_pZAgB03N1p1GmVOZ--gOFwwQSRKj1UXb5tnaKS",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.paths = .{
|
||||||
|
"build.zig",
|
||||||
|
"build.zig.zon",
|
||||||
|
"src",
|
||||||
|
"README.md",
|
||||||
|
"LICENSE",
|
||||||
|
},
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const ArrayList = std.ArrayList;
|
const ArrayList = std.ArrayList;
|
||||||
|
const zeit = @import("zeit");
|
||||||
|
|
||||||
const Release = @import("main.zig").Release;
|
const Release = @import("main.zig").Release;
|
||||||
|
|
||||||
|
@ -22,9 +23,11 @@ pub fn generateFeed(allocator: Allocator, releases: []const Release) ![]u8 {
|
||||||
\\
|
\\
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add current timestamp in ISO 8601 format
|
// Add current timestamp in proper ISO 8601 format using zeit
|
||||||
const timestamp = std.time.timestamp();
|
const now = zeit.instant(.{}) catch zeit.instant(.{ .source = .now }) catch unreachable;
|
||||||
try writer.print("<updated>{d}-01-01T00:00:00Z</updated>\n", .{1970 + @divTrunc(timestamp, 31536000)});
|
const updated_str = try std.fmt.allocPrint(allocator, "{}", .{now});
|
||||||
|
defer allocator.free(updated_str);
|
||||||
|
try writer.print("<updated>{s}</updated>\n", .{updated_str});
|
||||||
|
|
||||||
// Add entries
|
// Add entries
|
||||||
for (releases) |release| {
|
for (releases) |release| {
|
||||||
|
|
Loading…
Add table
Reference in a new issue