Skip to content

Commit dc7428e

Browse files
committed
update artifact name
1 parent 3d36b7f commit dc7428e

4 files changed

Lines changed: 18 additions & 13 deletions

File tree

.github/workflows/publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
VERSION=$(npm version "${{ github.event.release.tag_name }}" --no-git-tag-version)
3030
git add package.json package-lock.json
3131
git commit -m "[skip ci] Bump $VERSION"
32+
git pull --rebase origin main
3233
git push origin HEAD:main
3334
3435
# Build and test

plugins/+ciplugins/+github/TestResultsSummaryPlugin.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function reportFinalizedSuite(plugin, pluginData)
1313
end
1414

1515
% If test results artifact exists, update the same file
16-
testArtifactFile = fullfile(getenv("RUNNER_TEMP"), "matlabTestResults" + getenv("GITHUB_RUN_ID") + ".json");
16+
testArtifactFile = fullfile(getenv("RUNNER_TEMP"), "matlabTestResults_" + getenv("GITHUB_RUN_ID") + "_" + getenv("GITHUB_ACTION") + ".json");
1717
if isfile(testArtifactFile)
1818
testResults = {jsondecode(fileread(testArtifactFile))};
1919
else

src/testResultsSummary.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ export function getStatusEmoji(status: MatlabTestStatus): string {
199199
export function getTestResults(
200200
runnerTemp: string,
201201
runId: string,
202+
actionName: string,
202203
workspace: string,
203204
): TestResultsData {
204205
const testResults: MatlabTestFile[][] = [];
@@ -214,7 +215,7 @@ export function getTestResults(
214215
TestResults: testResults,
215216
Stats: stats,
216217
};
217-
const resultsPath = path.join(runnerTemp, `matlabTestResults${runId}.json`);
218+
const resultsPath = path.join(runnerTemp, `matlabTestResults_${runId}_${actionName}.json`);
218219

219220
if (existsSync(resultsPath)) {
220221
try {

src/testResultsSummary.unit.test.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ describe("Artifact Processing Tests", () => {
2727

2828
beforeAll(() => {
2929
const runnerTemp = path.join(__dirname, "..");
30-
const runId = "";
30+
const runId = "123";
31+
const actionName = "run-tests";
3132
const osInfo = getOSInfo();
3233
const workspace = path.join(osInfo.workspaceParent, "workspace");
3334

34-
copyTestDataFile(osInfo.osName, runnerTemp);
35+
copyTestDataFile(osInfo.osName, runnerTemp, runId, actionName);
3536

36-
testResultsData = testResultsSummary.getTestResults(runnerTemp, runId, workspace);
37+
testResultsData = testResultsSummary.getTestResults(runnerTemp, runId, actionName, workspace);
3738
testResults = testResultsData.TestResults;
3839
stats = testResultsData.Stats;
3940
});
@@ -48,7 +49,7 @@ describe("Artifact Processing Tests", () => {
4849
throw new Error(`Unsupported OS: ${os}`);
4950
}
5051

51-
function copyTestDataFile(osName: string, runnerTemp: string) {
52+
function copyTestDataFile(osName: string, runnerTemp: string, runId: string, actionName: string) {
5253
const sourceFilePath = path.join(
5354
__dirname,
5455
"test-data",
@@ -57,7 +58,7 @@ describe("Artifact Processing Tests", () => {
5758
osName,
5859
"matlabTestResults.json",
5960
);
60-
const destinationFilePath = path.join(runnerTemp!, "matlabTestResults.json");
61+
const destinationFilePath = path.join(runnerTemp, "matlabTestResults_" + runId + "_" + actionName + ".json");
6162

6263
try {
6364
fs.copyFileSync(sourceFilePath, destinationFilePath);
@@ -358,14 +359,15 @@ describe("Error Handling Tests", () => {
358359

359360
// Set up environment variables
360361
process.env.RUNNER_TEMP = path.join(__dirname, "..");
361-
process.env.GITHUB_RUN_ID = "";
362+
process.env.GITHUB_RUN_ID = "123";
363+
process.env.GITHUB_ACTION = "run-tests";
362364

363365
// Create a file with invalid JSON
364-
const invalidJsonPath = path.join(process.env.RUNNER_TEMP, "matlabTestResults.json");
366+
const invalidJsonPath = path.join(process.env.RUNNER_TEMP, "matlabTestResults_123_run-tests.json");
365367
fs.writeFileSync(invalidJsonPath, "{ invalid json content");
366368

367369
try {
368-
const result = testResultsSummary.getTestResults(process.env.RUNNER_TEMP!, process.env.GITHUB_RUN_ID!, "");
370+
const result = testResultsSummary.getTestResults(process.env.RUNNER_TEMP, process.env.GITHUB_RUN_ID, process.env.GITHUB_ACTION, "");
369371

370372
// Should return empty results
371373
expect(result.TestResults).toEqual([]);
@@ -407,14 +409,15 @@ describe("Error Handling Tests", () => {
407409

408410
// Set up environment variables
409411
process.env.RUNNER_TEMP = path.join(__dirname, "..");
410-
process.env.GITHUB_RUN_ID = "";
412+
process.env.GITHUB_RUN_ID = "123";
413+
process.env.GITHUB_ACTION = "run-tests";
411414

412415
// Create a valid JSON file
413-
const validJsonPath = path.join(process.env.RUNNER_TEMP, "matlabTestResults.json");
416+
const validJsonPath = path.join(process.env.RUNNER_TEMP, "matlabTestResults_123_run-tests.json");
414417
fs.writeFileSync(validJsonPath, "[]"); // Empty array - valid JSON
415418

416419
try {
417-
const result = testResultsSummary.getTestResults(process.env.RUNNER_TEMP!, process.env.GITHUB_RUN_ID!, "");
420+
const result = testResultsSummary.getTestResults(process.env.RUNNER_TEMP, process.env.GITHUB_RUN_ID, process.env.GITHUB_ACTION, "");
418421

419422
// Should still return results even if deletion fails
420423
expect(result).toBeDefined();

0 commit comments

Comments
 (0)