ci: format ./twitch-eventsub-ws (#6647)

This commit is contained in:
pajlada
2025-12-14 15:00:57 +01:00
committed by GitHub
parent 7657d7f679
commit b9cf385a40
24 changed files with 53 additions and 26 deletions
+1 -1
View File
@@ -75,7 +75,7 @@ def main():
log.debug(f"{header_path}: definition={def_path}, implementation={source_path}")
(definition, implementation) = generate(header_path, args.includes)
(definition, implementation) = generate(header_path, source_path, args.includes)
# ensure directories are created
Path(def_path).parent.mkdir(parents=True, exist_ok=True)
+4 -2
View File
@@ -4,8 +4,10 @@ import subprocess
log = logging.getLogger(__name__)
def format_code(code: str) -> str:
proc = subprocess.Popen(["clang-format", "-"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
def format_code(filename: str, code: str) -> str:
proc = subprocess.Popen(
["clang-format", "--assume-filename", filename, "-"], stdin=subprocess.PIPE, stdout=subprocess.PIPE
)
outs, errs = proc.communicate(input=code.encode(), timeout=2)
if errs is not None:
log.warning(f"Error formatting code: {errs.decode()}")
+5 -3
View File
@@ -44,14 +44,16 @@ def _get_relative_header_path(header_path: str) -> str:
return Path(header_path).relative_to(root_path).as_posix()
def generate(header_path: str, additional_includes: list[str] = []) -> Tuple[str, str]:
def generate(header_path: str, source_path: str, additional_includes: list[str] = []) -> Tuple[str, str]:
structs = build_structs(header_path, additional_includes)
rel_header_path = _get_relative_header_path(header_path)
log.debug("Generate & format definitions")
definitions = format_code("\n\n".join([struct.try_value_to_definition(env) for struct in structs]))
# Technically the definitions we save will be saved in an .inc file, but for the purpose of formatting the code we can assume it's the real header file
definitions = format_code(header_path, "\n\n".join([struct.try_value_to_definition(env) for struct in structs]))
log.debug("Generate & format implementations")
implementations = format_code(_generate_implementation(rel_header_path, structs))
implementations = format_code(source_path, _generate_implementation(rel_header_path, structs))
return (definitions, implementations)
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/messages/metadata.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/messages/metadata.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/automod-message-hold-v2.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/automod-message-hold-v2.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/automod-message-update-v2.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/automod-message-update-v2.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/automod-message.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/automod-message.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/channel-ban-v1.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/channel-ban-v1.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/channel-chat-message-v1.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/channel-chat-message-v1.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/channel-chat-notification-v1.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/channel-chat-notification-v1.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/channel-chat-user-message-hold-v1.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/channel-chat-user-message-hold-v1.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/channel-chat-user-message-update-v1.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/channel-chat-user-message-update-v1.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/channel-moderate-v2.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/channel-moderate-v2.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/channel-suspicious-user-message-v1.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/channel-suspicious-user-message-v1.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/channel-suspicious-user-update-v1.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/channel-suspicious-user-update-v1.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/channel-update-v1.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/channel-update-v1.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/session-welcome.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/session-welcome.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/stream-offline-v1.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/stream-offline-v1.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/stream-online-v1.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/stream-online-v1.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/structured-message.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/structured-message.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/subscription.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/subscription.hpp"
#include <boost/json.hpp>
@@ -1,8 +1,9 @@
// WARNING: This file is automatically generated. Any changes will be lost.
#include "twitch-eventsub-ws/payloads/suspicious-users.hpp"
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/detail/errors.hpp"
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
#include "twitch-eventsub-ws/payloads/suspicious-users.hpp"
#include <boost/json.hpp>