aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois Kritzinger <francois@codesynthesis.com>2025-01-17 17:04:20 +0200
committerFrancois Kritzinger <francois@codesynthesis.com>2025-01-20 11:29:19 +0200
commitb1f1ae8a10596199e130637eecf2611afdd57cb1 (patch)
tree094a80ec0fc6080f4f755ca770f6a76d1fd70a3f
parent92ef110bb927db685f4b7740d7e20e67eabe7e8d (diff)
ci-github: Check run details_url related updates/fixes
- Add details_url() overload which returns URL for tenant - Add brep-root path to details_url - Parse brep-root path in check_run details_url
-rw-r--r--mod/mod-ci-github.cxx33
-rw-r--r--mod/mod-ci-github.hxx5
2 files changed, 31 insertions, 7 deletions
diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx
index 67ab2a7..579b96b 100644
--- a/mod/mod-ci-github.cxx
+++ b/mod/mod-ci-github.cxx
@@ -3008,8 +3008,9 @@ namespace brep
{
// This code is based on build_force_url() in mod/build.cxx.
//
- return options_->host () +
- "/@" + b.tenant +
+ return
+ options_->host () +
+ tenant_dir (options_->root (), b.tenant).string () +
"?builds=" + mime_url_encode (b.package_name.string ()) +
"&pv=" + b.package_version.string () +
"&tg=" + mime_url_encode (b.target.string ()) +
@@ -3019,6 +3020,15 @@ namespace brep
b.toolchain_version.string ();
}
+ string ci_github::
+ details_url (const string& t) const
+ {
+ return
+ options_->host () +
+ tenant_dir (options_->root (), t).string () +
+ "?builds";
+ }
+
static optional<build_id>
parse_details_url (const string& details_url)
try
@@ -3031,12 +3041,21 @@ namespace brep
// Extract the tenant from the URL path.
//
- // Example path: @d2586f57-21dc-40b7-beb2-6517ad7917dd
+ // Example paths:
//
- if (!u.path || u.path->size () != 37 || (*u.path)[0] != '@')
+ // @d2586f57-21dc-40b7-beb2-6517ad7917dd (37 characters)
+ // <brep-root>/@d2586f57-21dc-40b7-beb2-6517ad7917dd
+ //
+ if (!u.path)
return nullopt;
- r.package.tenant = u.path->substr (1);
+ {
+ size_t p (u.path->find ('@'));
+ if (p == string::npos || u.path->size () - p != 37)
+ return nullopt; // Tenant not found or too short.
+
+ r.package.tenant = u.path->substr (p + 1);
+ }
// Extract the rest of the build_id members from the URL query.
//
@@ -3091,8 +3110,8 @@ namespace brep
// Note: parsing code based on mod/mod-builds.cxx.
//
- size_t p (v.find_first_of ('-'));
- if (p >= v.size () - 1)
+ size_t p (v.find ('-'));
+ if (p == string::npos || p >= v.size () - 1)
return nullopt; // Invalid format.
r.toolchain_name = v.substr (0, p);
diff --git a/mod/mod-ci-github.hxx b/mod/mod-ci-github.hxx
index 1e5f24f..c21d3db 100644
--- a/mod/mod-ci-github.hxx
+++ b/mod/mod-ci-github.hxx
@@ -127,6 +127,11 @@ namespace brep
string
details_url (const build&) const;
+ // Build a check run details_url for a tenant.
+ //
+ string
+ details_url (const string& tenant) const;
+
optional<string>
generate_jwt (const string& app_id,
const basic_mark& trace,