From fefb33454f54a0e89a399ef88801d3071640a7ac Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Wed, 28 Apr 2021 16:16:55 -0700 Subject: [PATCH] do that too --- code/__DEFINES/tgs.dm | 38 ++++++++++++++------------ code/datums/helper_datums/getrev.dm | 8 +++--- code/modules/tgs/core/core.dm | 6 ++-- code/modules/tgs/v3210/api.dm | 10 +++---- code/modules/tgs/v4/api.dm | 10 +++---- code/modules/tgs/v5/_defines.dm | 1 + code/modules/tgs/v5/api.dm | 23 ++++++++++------ code/modules/tgs/v5/interop_version.dm | 1 + code/modules/tgs/v5/undefs.dm | 1 + 9 files changed, 56 insertions(+), 42 deletions(-) create mode 100644 code/modules/tgs/v5/interop_version.dm diff --git a/code/__DEFINES/tgs.dm b/code/__DEFINES/tgs.dm index 2562bfe4d3..af09ab6711 100644 --- a/code/__DEFINES/tgs.dm +++ b/code/__DEFINES/tgs.dm @@ -1,6 +1,6 @@ // tgstation-server DMAPI -#define TGS_DMAPI_VERSION "5.2.9" +#define TGS_DMAPI_VERSION "6.0.3" // All functions and datums outside this document are subject to change with any version and should not be relied on. @@ -67,7 +67,7 @@ #define TGS_EVENT_REPO_CHECKOUT 1 /// When the repository performs a fetch operation. No parameters #define TGS_EVENT_REPO_FETCH 2 -/// When the repository merges a pull request. Parameters: PR Number, PR Sha, (Nullable) Comment made by TGS user +/// When the repository test merges. Parameters: PR Number, PR Sha, (Nullable) Comment made by TGS user #define TGS_EVENT_REPO_MERGE_PULL_REQUEST 3 /// Before the repository makes a sychronize operation. Parameters: Absolute repostiory path #define TGS_EVENT_REPO_PRE_SYNCHRONIZE 4 @@ -95,8 +95,13 @@ #define TGS_EVENT_WATCHDOG_SHUTDOWN 15 /// Before the watchdog detaches for a TGS update/restart. No parameters. #define TGS_EVENT_WATCHDOG_DETACH 16 -// We don't actually implement this value as the DMAPI can never receive it +// We don't actually implement these 4 events as the DMAPI can never receive them. // #define TGS_EVENT_WATCHDOG_LAUNCH 17 +// #define TGS_EVENT_WATCHDOG_CRASH 18 +// #define TGS_EVENT_WORLD_END_PROCESS 19 +// #define TGS_EVENT_WORLD_REBOOT 20 +/// Watchdog event when TgsInitializationComplete() is called. No parameters. +#define TGS_EVENT_WORLD_PRIME 21 // OTHER ENUMS @@ -130,7 +135,6 @@ * * This may use [/world/var/sleep_offline] to make this happen so ensure no changes are made to it while this call is running. * Afterwards, consider explicitly setting it to what you want to avoid this BYOND bug: http://www.byond.com/forum/post/2575184 - * Before this point, note that any static files or directories may be in use by another server. Your code should account for this. * This function should not be called before ..() in [/world/proc/New]. */ /world/proc/TgsInitializationComplete() @@ -140,7 +144,7 @@ #define TGS_TOPIC var/tgs_topic_return = TgsTopic(args[1]); if(tgs_topic_return) return tgs_topic_return /** - * Call this at the beginning of [world/proc/Reboot]. + * Call this as late as possible in [world/proc/Reboot]. */ /world/proc/TgsReboot() return @@ -152,6 +156,8 @@ /datum/tgs_revision_information /// Full SHA of the commit. var/commit + /// ISO 8601 timestamp of when the commit was created + var/timestamp /// Full sha of last known remote commit. This may be null if the TGS repository is not currently tracking a remote branch. var/origin_commit @@ -190,21 +196,19 @@ /// Represents a merge of a GitHub pull request. /datum/tgs_revision_information/test_merge - /// The pull request number. + /// The test merge number. var/number - /// The pull request title when it was merged. + /// The test merge source's title when it was merged. var/title - /// The pull request body when it was merged. + /// The test merge source's body when it was merged. var/body - /// The GitHub username of the pull request's author. + /// The Username of the test merge source's author. var/author - /// An http URL to the pull request. + /// An http URL to the test merge source. var/url - /// The SHA of the pull request when that was merged. - var/pull_request_commit - /// ISO 8601 timestamp of when the pull request was merged. - var/time_merged - /// (Nullable) Comment left by the TGS user who initiated the merge.. + /// The SHA of the test merge when that was merged. + var/head_commit + /// Optional comment left by the TGS user who initiated the merge. var/comment /// Represents a connected chat channel. @@ -263,11 +267,11 @@ // API FUNCTIONS /// Returns the maximum supported [/datum/tgs_version] of the DMAPI. -/world/proc/TgsMaximumAPIVersion() +/world/proc/TgsMaximumApiVersion() return /// Returns the minimum supported [/datum/tgs_version] of the DMAPI. -/world/proc/TgsMinimumAPIVersion() +/world/proc/TgsMinimumApiVersion() return /** diff --git a/code/datums/helper_datums/getrev.dm b/code/datums/helper_datums/getrev.dm index 91b8e32566..824b0551e1 100644 --- a/code/datums/helper_datums/getrev.dm +++ b/code/datums/helper_datums/getrev.dm @@ -16,7 +16,7 @@ if(revinfo) commit = revinfo.commit originmastercommit = revinfo.origin_commit - date = rustg_git_commit_date(commit) + date = revinfo.timestamp || rustg_git_commit_date(commit) // goes to DD log and config_error.txt log_world(get_log_message()) @@ -29,8 +29,8 @@ for(var/line in testmerge) var/datum/tgs_revision_information/test_merge/tm = line - msg += "Test merge active of PR #[tm.number] commit [tm.pull_request_commit]" - SSblackbox.record_feedback("associative", "testmerged_prs", 1, list("number" = "[tm.number]", "commit" = "[tm.pull_request_commit]", "title" = "[tm.title]", "author" = "[tm.author]")) + msg += "Test merge active of PR #[tm.number] commit [tm.head_commit]" + SSblackbox.record_feedback("associative", "testmerged_prs", 1, list("number" = "[tm.number]", "commit" = "[tm.head_commit]", "title" = "[tm.title]", "author" = "[tm.author]")) if(commit && commit != originmastercommit) msg += "HEAD: [commit]" @@ -45,7 +45,7 @@ . = header ? "The following pull requests are currently test merged:
" : "" for(var/line in testmerge) var/datum/tgs_revision_information/test_merge/tm = line - var/cm = tm.pull_request_commit + var/cm = tm.head_commit var/details = ": '" + html_encode(tm.title) + "' by " + html_encode(tm.author) + " at commit " + html_encode(copytext_char(cm, 1, 11)) if(details && findtext(details, "\[s\]") && (!usr || !usr.client.holder)) continue diff --git a/code/modules/tgs/core/core.dm b/code/modules/tgs/core/core.dm index f75e7837af..41a0473394 100644 --- a/code/modules/tgs/core/core.dm +++ b/code/modules/tgs/core/core.dm @@ -40,7 +40,7 @@ if(5) api_datum = /datum/tgs_api/v5 - var/datum/tgs_version/max_api_version = TgsMaximumAPIVersion(); + var/datum/tgs_version/max_api_version = TgsMaximumApiVersion(); if(version.suite != null && version.minor != null && version.patch != null && version.deprecated_patch != null && version.deprefixed_parameter > max_api_version.deprefixed_parameter) TGS_ERROR_LOG("Detected unknown API version! Defaulting to latest. Update the DMAPI to fix this problem.") api_datum = /datum/tgs_api/latest @@ -64,10 +64,10 @@ TGS_WRITE_GLOBAL(tgs, null) TGS_ERROR_LOG("Failed to activate API!") -/world/TgsMaximumAPIVersion() +/world/TgsMaximumApiVersion() return new /datum/tgs_version("5.x.x") -/world/TgsMinimumAPIVersion() +/world/TgsMinimumApiVersion() return new /datum/tgs_version("3.2.x") /world/TgsInitializationComplete() diff --git a/code/modules/tgs/v3210/api.dm b/code/modules/tgs/v3210/api.dm index 5b41e6a89d..6382325100 100644 --- a/code/modules/tgs/v3210/api.dm +++ b/code/modules/tgs/v3210/api.dm @@ -62,7 +62,7 @@ comms_key = world.params[SERVICE_WORLD_PARAM] instance_name = world.params[SERVICE_INSTANCE_PARAM] if(!instance_name) - instance_name = "TG Station Server" //maybe just upgraded + instance_name = "TG Station Server" //maybe just upgraded var/list/logs = file2list(".git/logs/HEAD") if(logs.len) @@ -92,14 +92,14 @@ if(skip_compat_check && !fexists(SERVICE_INTERFACE_DLL)) TGS_ERROR_LOG("Service parameter present but no interface DLL detected. This is symptomatic of running a service less than version 3.1! Please upgrade.") return - call(SERVICE_INTERFACE_DLL, SERVICE_INTERFACE_FUNCTION)(instance_name, command) //trust no retval + call(SERVICE_INTERFACE_DLL, SERVICE_INTERFACE_FUNCTION)(instance_name, command) //trust no retval return TRUE /datum/tgs_api/v3210/OnTopic(T) var/list/params = params2list(T) var/their_sCK = params[SERVICE_CMD_PARAM_KEY] if(!their_sCK) - return FALSE //continue world/Topic + return FALSE //continue world/Topic if(their_sCK != comms_key) return "Invalid comms key!"; @@ -160,7 +160,7 @@ var/datum/tgs_revision_information/test_merge/tm = new tm.number = text2num(I) var/list/entry = json[I] - tm.pull_request_commit = entry["commit"] + tm.head_commit = entry["commit"] tm.author = entry["author"] tm.title = entry["title"] . += tm @@ -176,7 +176,7 @@ return ri /datum/tgs_api/v3210/EndProcess() - sleep(world.tick_lag) //flush the buffers + sleep(world.tick_lag) //flush the buffers ExportService(SERVICE_REQUEST_KILL_PROCESS) /datum/tgs_api/v3210/ChatChannelInfo() diff --git a/code/modules/tgs/v4/api.dm b/code/modules/tgs/v4/api.dm index 081543828e..0e37a7aa24 100644 --- a/code/modules/tgs/v4/api.dm +++ b/code/modules/tgs/v4/api.dm @@ -92,7 +92,7 @@ var/list/json = cached_json["testMerges"] for(var/entry in json) var/datum/tgs_revision_information/test_merge/tm = new - tm.time_merged = text2num(entry["timeMerged"]) + tm.timestamp = text2num(entry["timeMerged"]) var/list/revInfo = entry["revision"] if(revInfo) @@ -104,7 +104,7 @@ tm.url = entry["url"] tm.author = entry["author"] tm.number = entry["number"] - tm.pull_request_commit = entry["pullRequestRevision"] + tm.head_commit = entry["pullRequestRevision"] tm.comment = entry["comment"] cached_test_merges += tm @@ -118,7 +118,7 @@ var/list/params = params2list(T) var/their_sCK = params[TGS4_INTEROP_ACCESS_IDENTIFIER] if(!their_sCK) - return FALSE //continue world/Topic + return FALSE //continue world/Topic if(their_sCK != access_identifier) return "Invalid comms key!"; @@ -192,7 +192,7 @@ //request a new port export_lock = FALSE - var/list/new_port_json = Export(TGS4_COMM_NEW_PORT, list(TGS4_PARAMETER_DATA = "[world.port]"), TRUE) //stringify this on purpose + var/list/new_port_json = Export(TGS4_COMM_NEW_PORT, list(TGS4_PARAMETER_DATA = "[world.port]"), TRUE) //stringify this on purpose if(!new_port_json) TGS_ERROR_LOG("No new port response from server![TGS4_PORT_CRITFAIL_MESSAGE]") @@ -235,7 +235,7 @@ var/port = result[TGS4_PARAMETER_DATA] if(!isnum(port)) - return //this is valid, server may just want use to reboot + return //this is valid, server may just want use to reboot if(port == 0) //to byond 0 means any port and "none" means close vOv diff --git a/code/modules/tgs/v5/_defines.dm b/code/modules/tgs/v5/_defines.dm index 8fd84e19fa..10bc4cbe40 100644 --- a/code/modules/tgs/v5/_defines.dm +++ b/code/modules/tgs/v5/_defines.dm @@ -79,6 +79,7 @@ #define DMAPI5_TOPIC_RESPONSE_CHAT_RESPONSES "chatResponses" #define DMAPI5_REVISION_INFORMATION_COMMIT_SHA "commitSha" +#define DMAPI5_REVISION_INFORMATION_TIMESTAMP "timestamp" #define DMAPI5_REVISION_INFORMATION_ORIGIN_COMMIT_SHA "originCommitSha" #define DMAPI5_CHAT_USER_ID "id" diff --git a/code/modules/tgs/v5/api.dm b/code/modules/tgs/v5/api.dm index 466a986237..704ff873c0 100644 --- a/code/modules/tgs/v5/api.dm +++ b/code/modules/tgs/v5/api.dm @@ -18,7 +18,9 @@ var/initialized = FALSE /datum/tgs_api/v5/ApiVersion() - return new /datum/tgs_version(TGS_DMAPI_VERSION) + return new /datum/tgs_version( + #include "interop_version.dm" + ) /datum/tgs_api/v5/OnWorldNew(minimum_required_security_level) server_port = world.params[DMAPI5_PARAM_SERVER_PORT] @@ -48,6 +50,7 @@ if(istype(revisionData)) revision = new revision.commit = revisionData[DMAPI5_REVISION_INFORMATION_COMMIT_SHA] + revision.timestamp = revisionData[DMAPI5_REVISION_INFORMATION_TIMESTAMP] revision.origin_commit = revisionData[DMAPI5_REVISION_INFORMATION_ORIGIN_COMMIT_SHA] else TGS_ERROR_LOG("Failed to decode [DMAPI5_RUNTIME_INFORMATION_REVISION] from runtime information!") @@ -63,15 +66,18 @@ if(revInfo) tm.commit = revisionData[DMAPI5_REVISION_INFORMATION_COMMIT_SHA] tm.origin_commit = revisionData[DMAPI5_REVISION_INFORMATION_ORIGIN_COMMIT_SHA] + tm.timestamp = entry[DMAPI5_REVISION_INFORMATION_TIMESTAMP] else TGS_WARNING_LOG("Failed to decode [DMAPI5_TEST_MERGE_REVISION] from test merge #[tm.number]!") - tm.time_merged = text2num(entry[DMAPI5_TEST_MERGE_TIME_MERGED]) + if(!tm.timestamp) + tm.timestamp = entry[DMAPI5_TEST_MERGE_TIME_MERGED] + tm.title = entry[DMAPI5_TEST_MERGE_TITLE_AT_MERGE] tm.body = entry[DMAPI5_TEST_MERGE_BODY_AT_MERGE] tm.url = entry[DMAPI5_TEST_MERGE_URL] tm.author = entry[DMAPI5_TEST_MERGE_AUTHOR] - tm.pull_request_commit = entry[DMAPI5_TEST_MERGE_PULL_REQUEST_REVISION] + tm.head_commit = entry[DMAPI5_TEST_MERGE_PULL_REQUEST_REVISION] tm.comment = entry[DMAPI5_TEST_MERGE_COMMENT] test_merges += tm @@ -98,18 +104,19 @@ return json_encode(response) /datum/tgs_api/v5/OnTopic(T) - if(!initialized) - return FALSE //continue world/Topic - var/list/params = params2list(T) var/json = params[DMAPI5_TOPIC_DATA] if(!json) - return FALSE + return FALSE // continue to /world/Topic var/list/topic_parameters = json_decode(json) if(!topic_parameters) return TopicResponse("Invalid topic parameters json!"); + if(!initialized) + TGS_WARNING_LOG("Missed topic due to not being initialized: [T]") + return TRUE // too early to handle, but it's still our responsibility + var/their_sCK = topic_parameters[DMAPI5_PARAMETER_ACCESS_IDENTIFIER] if(their_sCK != access_identifier) return TopicResponse("Failed to decode [DMAPI5_PARAMETER_ACCESS_IDENTIFIER] from: [json]!"); @@ -266,7 +273,7 @@ var/port = result[DMAPI5_BRIDGE_RESPONSE_NEW_PORT] if(!isnum(port)) - return //this is valid, server may just want use to reboot + return //this is valid, server may just want use to reboot if(port == 0) //to byond 0 means any port and "none" means close vOv diff --git a/code/modules/tgs/v5/interop_version.dm b/code/modules/tgs/v5/interop_version.dm new file mode 100644 index 0000000000..c7bf62ecae --- /dev/null +++ b/code/modules/tgs/v5/interop_version.dm @@ -0,0 +1 @@ +"5.3.0" diff --git a/code/modules/tgs/v5/undefs.dm b/code/modules/tgs/v5/undefs.dm index 34fc481d36..5885a60e75 100644 --- a/code/modules/tgs/v5/undefs.dm +++ b/code/modules/tgs/v5/undefs.dm @@ -79,6 +79,7 @@ #undef DMAPI5_TOPIC_RESPONSE_CHAT_RESPONSES #undef DMAPI5_REVISION_INFORMATION_COMMIT_SHA +#undef DMAPI5_REVISION_INFORMATION_TIMESTAMP #undef DMAPI5_REVISION_INFORMATION_ORIGIN_COMMIT_SHA #undef DMAPI5_CHAT_USER_ID