10 Commits

Author SHA1 Message Date
Philipp d02f44f6c7 fix(monitor): use global console channel and implement shard filtering
Lint / pre-commit Linting (push) Successful in 44s
Test / Run Tests (push) Successful in 1m4s
2026-05-16 20:26:32 +02:00
Philipp 6384addc42 fix: correct typo in package.json and use unique temp dir for logs
Lint / pre-commit Linting (push) Successful in 50s
Test / Run Tests (push) Successful in 1m10s
2026-05-16 19:39:27 +02:00
Philipp f62ac427c2 style: remove redundant section comments
Lint / pre-commit Linting (push) Successful in 45s
Test / Run Tests (push) Successful in 1m4s
2026-05-16 19:09:59 +02:00
Philipp c3d595e2e1 feat: support multiline console output and decode HTML entities
Lint / pre-commit Linting (push) Successful in 56s
Test / Run Tests (push) Successful in 1m14s
2026-05-16 18:55:44 +02:00
Philipp fe7c14540e fix: decode console output to ensure tracebacks are detected even when encoded
Lint / pre-commit Linting (push) Successful in 51s
Test / Run Tests (push) Successful in 1m10s
2026-05-16 18:39:21 +02:00
Philipp b6cef04a9c feat: implement fail-fast monitoring to stop as soon as error/traceback is detected
Lint / pre-commit Linting (push) Successful in 42s
Test / Run Tests (push) Successful in 1m3s
2026-05-16 18:28:54 +02:00
Philipp 55a9fc027d Merge branch 'feature/console-monitor' of git.horstenkamp.eu:Screeps/screeps-deploy-action into feature/console-monitor
Lint / pre-commit Linting (push) Successful in 45s
Test / Run Tests (push) Successful in 1m11s
2026-05-16 17:19:52 +02:00
Philipp 242b03bb29 chore: bump version to 0.2.0 2026-05-16 17:17:29 +02:00
Philipp 84224f3678 Merge branch 'main' into feature/console-monitor
Lint / pre-commit Linting (push) Successful in 1m3s
Test / Run Tests (push) Successful in 1m49s
2026-05-16 17:14:47 +02:00
Philipp 172204508b feat: add Screeps console monitoring with configurable error handling and shard support
Lint / pre-commit Linting (push) Successful in 59s
Test / Run Tests (push) Successful in 1m47s
2026-05-16 16:04:55 +02:00
4 changed files with 39 additions and 16 deletions
+26 -11
View File
@@ -53,20 +53,20 @@ describe("isOfficialServer", () => {
}); });
describe("buildSubscribePath", () => { describe("buildSubscribePath", () => {
it("returns shard0/console for official server (no shard provided)", () => { it("returns console for official server (no shard provided)", () => {
expect(buildSubscribePath("screeps.com")).toBe("shard0/console"); expect(buildSubscribePath("screeps.com")).toBe("console");
}); });
it("returns console for private server (no shard provided)", () => { it("returns console for private server (no shard provided)", () => {
expect(buildSubscribePath("builder64")).toBe("console"); expect(buildSubscribePath("builder64")).toBe("console");
}); });
it("returns <shard>/console when shard is provided (official)", () => { it("returns console when shard is provided (official)", () => {
expect(buildSubscribePath("screeps.com", "shard3")).toBe("shard3/console"); expect(buildSubscribePath("screeps.com", "shard3")).toBe("console");
}); });
it("returns <shard>/console when shard is provided (private)", () => { it("returns console when shard is provided (private)", () => {
expect(buildSubscribePath("builder64", "myshard")).toBe("myshard/console"); expect(buildSubscribePath("builder64", "myshard")).toBe("console");
}); });
}); });
@@ -228,6 +228,21 @@ describe("handleConsoleEvent", () => {
handleConsoleEvent(event, { logToFile: false }, stdoutBuffer, state), handleConsoleEvent(event, { logToFile: false }, stdoutBuffer, state),
).not.toThrow(); ).not.toThrow();
}); });
it("filters messages by shard when targetShard is provided", () => {
const event = { data: { shard: "shard0", messages: { log: ["msg0"] } } };
handleConsoleEvent(event, { shard: "shard1" }, stdoutBuffer, state);
expect(core.info).not.toHaveBeenCalled();
handleConsoleEvent(event, { shard: "shard0" }, stdoutBuffer, state);
expect(core.info).toHaveBeenCalledWith("msg0");
});
it("does not filter when targetShard is undefined", () => {
const event = { data: { shard: "shard0", messages: { log: ["msg0"] } } };
handleConsoleEvent(event, {}, stdoutBuffer, state);
expect(core.info).toHaveBeenCalledWith("msg0");
});
}); });
// ──────────────────────────────────────────────────────────────────────────── // ────────────────────────────────────────────────────────────────────────────
@@ -357,19 +372,19 @@ describe("monitorConsole", () => {
); );
}); });
it("subscribes to 'shard0/console' for the official server (default)", async () => { it("subscribes to 'console' for the official server (default)", async () => {
const api = buildMockApi({ const api = buildMockApi({
hostname: "screeps.com", hostname: "screeps.com",
ticks: [100, 101, 102, 103], ticks: [100, 101, 102, 103],
}); });
await monitorConsole(api, { ...BASE_OPTS, hostname: "screeps.com" }); await monitorConsole(api, { ...BASE_OPTS, hostname: "screeps.com" });
expect(api.socket.subscribe).toHaveBeenCalledWith( expect(api.socket.subscribe).toHaveBeenCalledWith(
"shard0/console", "console",
expect.any(Function), expect.any(Function),
); );
}); });
it("subscribes to custom shard when provided", async () => { it("subscribes to 'console' even when custom shard is provided", async () => {
const api = buildMockApi({ const api = buildMockApi({
hostname: "screeps.com", hostname: "screeps.com",
ticks: [100, 101, 102, 103], ticks: [100, 101, 102, 103],
@@ -380,10 +395,10 @@ describe("monitorConsole", () => {
shard: "shard3", shard: "shard3",
}); });
expect(api.socket.subscribe).toHaveBeenCalledWith( expect(api.socket.subscribe).toHaveBeenCalledWith(
"shard3/console", "console",
expect.any(Function), expect.any(Function),
); );
// Verify polling also uses shard3 // Verify polling still uses shard3 for timing
expect(api.time).toHaveBeenCalledWith("shard3"); expect(api.time).toHaveBeenCalledWith("shard3");
}); });
+1 -1
View File
File diff suppressed because one or more lines are too long
+11 -3
View File
@@ -29,8 +29,9 @@ export function isOfficialServer(hostname) {
* @returns {string} * @returns {string}
*/ */
export function buildSubscribePath(hostname, shard) { export function buildSubscribePath(hostname, shard) {
if (shard) return `${shard}/console`; // The console channel on Screeps official and most private servers is 'console'.
return isOfficialServer(hostname) ? "shard0/console" : "console"; // We subscribe to the aggregate feed and filter by shard in handleConsoleEvent.
return "console";
} }
/** /**
@@ -178,8 +179,15 @@ export async function uploadLogArtifact(
* @param {{ sawTraceback: boolean, sawErrorLog: boolean, sawWarningLog: boolean }} state * @param {{ sawTraceback: boolean, sawErrorLog: boolean, sawWarningLog: boolean }} state
*/ */
export function handleConsoleEvent(event, opts, stdoutBuffer, state) { export function handleConsoleEvent(event, opts, stdoutBuffer, state) {
const { logToFile } = opts; const { logToFile, shard: targetShard } = opts;
const data = event?.data ?? {}; const data = event?.data ?? {};
// Shard filtering: If a shard is specified in opts, only process messages from that shard.
// Official server events include a 'shard' property in event.data.
if (targetShard && data.shard && data.shard !== targetShard) {
return;
}
const logLines = data?.messages?.log ?? []; const logLines = data?.messages?.log ?? [];
const results = data?.messages?.results ?? []; const results = data?.messages?.results ?? [];
const errorText = data?.error ?? null; const errorText = data?.error ?? null;
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "screeps-deploy-action", "name": "screeps-deploy-action",
"version": "0.2.0", "version": "0.2.1",
"description": "Deploys screeps code to the official game or a private server.", "description": "Deploys screeps code to the official game or a private server.",
"type": "module", "type": "module",
"main": "index.js", "main": "index.js",