aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authorFrancois Kritzinger <francois@codesynthesis.com>2024-04-17 08:24:02 +0200
committerFrancois Kritzinger <francois@codesynthesis.com>2024-06-05 09:12:46 +0200
commit6fbae58d89bdd4bf50e29da7ba7b7ec6df030823 (patch)
tree0e7dda681b9b95c00ad8d455eaac4ae76cf3800f /mod
parent0ae041737670b3959e9012dc73f0518133c131bf (diff)
Add conversion between build_state and GitHub check run status
Diffstat (limited to 'mod')
-rw-r--r--mod/mod-ci-github.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx
index 9541c73..631ffbd 100644
--- a/mod/mod-ci-github.cxx
+++ b/mod/mod-ci-github.cxx
@@ -585,6 +585,30 @@ namespace brep
return r;
}
+ // Return the GitHub check run status corresponding to a build_state.
+ //
+ static const string&
+ to_string_gh (build_state st)
+ {
+ static const string sts[] {"QUEUED", "IN_PROGRESS", "COMPLETED"};
+
+ return sts[static_cast<size_t> (st)];
+ }
+
+ // Return the build_state corresponding to a GitHub check run status
+ // string. Throw invalid_argument if the passed status was invalid.
+ //
+ static build_state
+ from_string_gh (const string& s)
+ {
+ if (s == "QUEUED") return build_state::queued;
+ else if (s == "IN_PROGRESS") return build_state::building;
+ else if (s == "COMPLETED") return build_state::built;
+ else
+ throw invalid_argument ("invalid GitHub check run status: '" + s +
+ '\'');
+ }
+
// Serialize `createCheckRun` mutations for one or more builds to GraphQL.
//
static string