fix: downgrade @actions/artifact to v1 for Gitea compatibility
This commit is contained in:
+14
-24
@@ -12,19 +12,19 @@ vi.mock("@actions/core", () => ({
|
||||
}));
|
||||
|
||||
import * as artifact from "@actions/artifact";
|
||||
vi.mock("@actions/artifact", () => ({
|
||||
DefaultArtifactClient: class {
|
||||
uploadArtifact() {
|
||||
return Promise.resolve({});
|
||||
}
|
||||
},
|
||||
}));
|
||||
vi.mock("@actions/artifact", () => {
|
||||
const mockClient = {
|
||||
uploadArtifact: vi.fn().mockResolvedValue({}),
|
||||
};
|
||||
return {
|
||||
create: vi.fn(() => mockClient),
|
||||
};
|
||||
});
|
||||
|
||||
import * as core from "@actions/core";
|
||||
import fs from "fs";
|
||||
import os from "os";
|
||||
import path from "path";
|
||||
import { DefaultArtifactClient } from "@actions/artifact";
|
||||
|
||||
import {
|
||||
isOfficialServer,
|
||||
@@ -178,29 +178,22 @@ describe("uploadLogArtifacts", () => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("instantiates DefaultArtifactClient and calls uploadArtifact", async () => {
|
||||
const spy = vi.spyOn(
|
||||
artifact.DefaultArtifactClient.prototype,
|
||||
"uploadArtifact",
|
||||
);
|
||||
it("instantiates client and calls uploadArtifact", async () => {
|
||||
await uploadLogArtifacts(
|
||||
["/path/to/shard0_console_log.txt"],
|
||||
"custom-name",
|
||||
);
|
||||
expect(spy).toHaveBeenCalledWith(
|
||||
expect(artifact.create().uploadArtifact).toHaveBeenCalledWith(
|
||||
"custom-name",
|
||||
["/path/to/shard0_console_log.txt"],
|
||||
"/path/to",
|
||||
{ continueOnError: true },
|
||||
);
|
||||
});
|
||||
|
||||
it("does nothing if filePaths is empty", async () => {
|
||||
const spy = vi.spyOn(
|
||||
artifact.DefaultArtifactClient.prototype,
|
||||
"uploadArtifact",
|
||||
);
|
||||
await uploadLogArtifacts([]);
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
expect(artifact.create().uploadArtifact).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -622,22 +615,19 @@ describe("monitorConsole", () => {
|
||||
}, 50);
|
||||
|
||||
// Verify uploadArtifact was called with two files
|
||||
const spy = vi.spyOn(
|
||||
artifact.DefaultArtifactClient.prototype,
|
||||
"uploadArtifact",
|
||||
);
|
||||
await monitorConsole(api, {
|
||||
...BASE_OPTS,
|
||||
logToFile: true,
|
||||
});
|
||||
|
||||
expect(spy).toHaveBeenCalledWith(
|
||||
expect(artifact.create().uploadArtifact).toHaveBeenCalledWith(
|
||||
"screeps-console-log",
|
||||
expect.arrayContaining([
|
||||
expect.stringContaining("shard0_console_log.txt"),
|
||||
expect.stringContaining("shard1_console_log.txt"),
|
||||
]),
|
||||
expect.any(String),
|
||||
{ continueOnError: true },
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Vendored
+11
-84
File diff suppressed because one or more lines are too long
+5
-3
@@ -1,5 +1,5 @@
|
||||
import * as core from "@actions/core";
|
||||
import { DefaultArtifactClient } from "@actions/artifact";
|
||||
import { create } from "@actions/artifact";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
@@ -143,9 +143,11 @@ export async function uploadLogArtifacts(
|
||||
) {
|
||||
if (!filePaths || filePaths.length === 0) return;
|
||||
try {
|
||||
const client = new DefaultArtifactClient();
|
||||
const client = create();
|
||||
const rootDir = path.dirname(filePaths[0]);
|
||||
await client.uploadArtifact(artifactName, filePaths, rootDir);
|
||||
await client.uploadArtifact(artifactName, filePaths, rootDir, {
|
||||
continueOnError: true,
|
||||
});
|
||||
core.info(`[Monitor] Console logs uploaded as artifact '${artifactName}'.`);
|
||||
} catch (err) {
|
||||
core.warning(
|
||||
|
||||
Generated
+28
-1816
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,7 @@
|
||||
"build": "ncc build index.js -o dist -m --external utf-8-validate --external bufferutil"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/artifact": "^1.1.2",
|
||||
"@actions/core": "^3.0.0",
|
||||
"glob": "^13.0.0",
|
||||
"screeps-api": "^1.7.2"
|
||||
|
||||
Reference in New Issue
Block a user