Skip to content

Commit

Permalink
log resource path instead of own format
Browse files Browse the repository at this point in the history
  • Loading branch information
dermetfan committed Apr 23, 2024
1 parent 5cbc5f2 commit 1a47135
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
4 changes: 4 additions & 0 deletions src/api/types.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ pub const ID = []const u8;

pub const PullRequest = struct {
id: ID,
resourcePath: []const u8,

number: usize,
title: []const u8,
};

pub const Commit = struct {
id: ID,
resourcePath: []const u8,

oid: []const u8,
messageHeadline: []const u8,
Expand Down Expand Up @@ -52,6 +54,7 @@ pub const CheckStatusState = enum {

pub const CheckSuite = struct {
id: ID,
resourcePath: []const u8,

app: App,
branch: ?Ref = null,
Expand All @@ -64,6 +67,7 @@ pub const CheckSuite = struct {

pub const CheckRun = struct {
id: ID,
resourcePath: []const u8,

name: []const u8,
startedAt: []const u8,
Expand Down
30 changes: 7 additions & 23 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -50,52 +50,36 @@ pub fn main() !void {
break :repo .{ owner, name };
};

const repo_fmt = "{s}/{s}";
const repo_fmt_args = .{ repo_owner, repo_name };

std.log.info(repo_fmt ++ ": scanning for pull requests…", repo_fmt_args);
std.log.info("/{s}/{s}: scanning for pull requests…", .{ repo_owner, repo_name });

const prs = try api.queries.fetchPullRequestsByRepo(&client, allocator, repo_owner, repo_name);
defer prs.deinit(allocator);

for (prs.value) |pr| {
const pr_fmt = repo_fmt ++ "#{d}";
const pr_fmt_args = repo_fmt_args ++ .{pr.number};

std.log.info(pr_fmt ++ ": scanning for commits…", pr_fmt_args);
std.log.info("{s}: scanning for commits…", .{pr.resourcePath});

const commits = try api.queries.fetchCommitsByPullRequestId(&client, allocator, pr.id);
defer commits.deinit(allocator);

for (commits.value) |commit| {
const commit_fmt = pr_fmt ++ "@{s}";
const commit_fmt_args = pr_fmt_args ++ .{commit.oid};

std.log.info(commit_fmt ++ ": scanning for check suites…", commit_fmt_args);
std.log.info("{s}: scanning for check suites…", .{commit.resourcePath});

const check_suites = try api.queries.fetchCheckSuitesByCommitId(&client, allocator, commit.id);
defer check_suites.deinit(allocator);

for (check_suites.value) |check_suite| {
const check_suite_fmt = commit_fmt ++ "!{s}";
const check_suite_fmt_args = commit_fmt_args ++ .{check_suite.app.name};

if (check_suite.status != .COMPLETED) {
std.log.info(check_suite_fmt ++ ": skipping (not completed)", check_suite_fmt_args);
std.log.info("{s}: skipping (not completed)", .{check_suite.resourcePath});
continue;
}

std.log.info(check_suite_fmt ++ ": scanning for check runs…", check_suite_fmt_args);
std.log.info("{s}: scanning for check runs…", .{check_suite.resourcePath});

const check_runs = try api.queries.fetchCheckRunsByCheckSuiteId(&client, allocator, check_suite.id);
defer check_runs.deinit(allocator);

for (check_runs.value) |check_run| {
const check_run_fmt = check_suite_fmt ++ "?{s}";
const check_run_fmt_args = check_suite_fmt_args ++ .{check_run.name};

std.log.info(check_run_fmt ++ ": found.", check_run_fmt_args);
}
for (check_runs.value) |check_run|
std.log.info("{s}: found.", .{check_run.resourcePath});
}
}
}
Expand Down

0 comments on commit 1a47135

Please sign in to comment.