From 1a0a67e1ac808fbca3936ed9b6407ce393ca8f0c Mon Sep 17 00:00:00 2001 From: Kirill Nikolaev Date: Tue, 12 Mar 2024 16:12:43 +0100 Subject: [PATCH] Pass public run ID to artifacts service. Public run IDs are shared across re-runs. --- actions-toolkit | 2 +- dist/merge/index.js | 51 ++++++++++++++++++++++++++++++-------------- dist/upload/index.js | 51 ++++++++++++++++++++++++++++++-------------- 3 files changed, 71 insertions(+), 33 deletions(-) diff --git a/actions-toolkit b/actions-toolkit index 6a19ca16..b6d2f51d 160000 --- a/actions-toolkit +++ b/actions-toolkit @@ -1 +1 @@ -Subproject commit 6a19ca16f7cd95203752dc13bd4708836a79d3b9 +Subproject commit b6d2f51da3ee3aee51e8779a5dc31b661c92121d diff --git a/dist/merge/index.js b/dist/merge/index.js index e924e7e0..a9de91bb 100644 --- a/dist/merge/index.js +++ b/dist/merge/index.js @@ -845,11 +845,12 @@ class CreateArtifactRequest$Type extends runtime_5.MessageType { { no: 2, name: "workflow_job_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 3, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 4, name: "expires_at", kind: "message", T: () => timestamp_1.Timestamp }, - { no: 5, name: "version", kind: "scalar", T: 5 /*ScalarType.INT32*/ } + { no: 5, name: "version", kind: "scalar", T: 5 /*ScalarType.INT32*/ }, + { no: 6, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, ]); } create(value) { - const message = { workflowRunBackendId: "", workflowJobRunBackendId: "", name: "", version: 0 }; + const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", name: "", version: 0 }; globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) (0, runtime_3.reflectionMergePartial)(this, message, value); @@ -978,10 +979,11 @@ class FinalizeArtifactRequest$Type extends runtime_5.MessageType { { no: 5, name: "hash", kind: "message", T: () => wrappers_2.StringValue }, { no: 6, name: "etag", kind: "scalar", T: 9 }, { no: 6, name: "upload_id", kind: "scalar", T: 9 }, + { no: 8, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, ]); } create(value) { - const message = { workflowRunBackendId: "", workflowJobRunBackendId: "", name: "", size: "0", etag: "", uploadId: "" }; + const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", name: "", size: "0", etag: "", uploadId: "" }; globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) (0, runtime_3.reflectionMergePartial)(this, message, value); @@ -1106,11 +1108,12 @@ class ListArtifactsRequest$Type extends runtime_5.MessageType { { no: 1, name: "workflow_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 2, name: "workflow_job_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 3, name: "name_filter", kind: "message", T: () => wrappers_2.StringValue }, - { no: 4, name: "id_filter", kind: "message", T: () => wrappers_1.Int64Value } + { no: 4, name: "id_filter", kind: "message", T: () => wrappers_1.Int64Value }, + { no: 5, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, ]); } create(value) { - const message = { workflowRunBackendId: "", workflowJobRunBackendId: "" }; + const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "" }; globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) (0, runtime_3.reflectionMergePartial)(this, message, value); @@ -1223,11 +1226,12 @@ class ListArtifactsResponse_MonolithArtifact$Type extends runtime_5.MessageType { no: 3, name: "database_id", kind: "scalar", T: 3 /*ScalarType.INT64*/ }, { no: 4, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 5, name: "size", kind: "scalar", T: 3 /*ScalarType.INT64*/ }, - { no: 6, name: "created_at", kind: "message", T: () => timestamp_1.Timestamp } + { no: 6, name: "created_at", kind: "message", T: () => timestamp_1.Timestamp }, + { no: 7, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, ]); } create(value) { - const message = { workflowRunBackendId: "", workflowJobRunBackendId: "", databaseId: "0", name: "", size: "0" }; + const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", databaseId: "0", name: "", size: "0" }; globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) (0, runtime_3.reflectionMergePartial)(this, message, value); @@ -1302,11 +1306,12 @@ class GetSignedArtifactURLRequest$Type extends runtime_5.MessageType { super("github.actions.results.api.v1.GetSignedArtifactURLRequest", [ { no: 1, name: "workflow_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 2, name: "workflow_job_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, - { no: 3, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ } + { no: 3, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, + { no: 4, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, ]); } create(value) { - const message = { workflowRunBackendId: "", workflowJobRunBackendId: "", name: "" }; + const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", name: "" }; globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) (0, runtime_3.reflectionMergePartial)(this, message, value); @@ -1410,11 +1415,12 @@ class DeleteArtifactRequest$Type extends runtime_5.MessageType { super("github.actions.results.api.v1.DeleteArtifactRequest", [ { no: 1, name: "workflow_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 2, name: "workflow_job_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, - { no: 3, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ } + { no: 3, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, + { no: 4, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, ]); } create(value) { - const message = { workflowRunBackendId: "", workflowJobRunBackendId: "", name: "" }; + const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", name: "" }; globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) (0, runtime_3.reflectionMergePartial)(this, message, value); @@ -2257,8 +2263,9 @@ exports.deleteArtifactPublic = deleteArtifactPublic; function deleteArtifactInternal(artifactName) { return __awaiter(this, void 0, void 0, function* () { const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)(); - const { workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)(); + const { publicRunId, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)(); const listReq = { + runId: publicRunId, workflowRunBackendId, workflowJobRunBackendId, nameFilter: generated_1.StringValue.create({ value: artifactName }) @@ -2273,6 +2280,7 @@ function deleteArtifactInternal(artifactName) { (0, core_1.debug)(`More than one artifact found for a single name, returning newest (id: ${artifact.databaseId})`); } const req = { + runId: publicRunId, workflowRunBackendId: artifact.workflowRunBackendId, workflowJobRunBackendId: artifact.workflowJobRunBackendId, name: artifact.name @@ -2500,8 +2508,9 @@ function downloadArtifactInternal(artifactId, options) { return __awaiter(this, void 0, void 0, function* () { const downloadPath = yield resolveOrCreateDirectory(options === null || options === void 0 ? void 0 : options.path); const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)(); - const { workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)(); + const { publicRunId, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)(); const listReq = { + runId: publicRunId, workflowRunBackendId, workflowJobRunBackendId, idFilter: generated_1.Int64Value.create({ value: artifactId.toString() }) @@ -2514,6 +2523,7 @@ function downloadArtifactInternal(artifactId, options) { core.warning('Multiple artifacts found, defaulting to first.'); } const signedReq = { + runId: artifacts[0].runId, workflowRunBackendId: artifacts[0].workflowRunBackendId, workflowJobRunBackendId: artifacts[0].workflowJobRunBackendId, name: artifacts[0].name @@ -2643,8 +2653,9 @@ exports.getArtifactPublic = getArtifactPublic; function getArtifactInternal(artifactName) { return __awaiter(this, void 0, void 0, function* () { const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)(); - const { workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)(); + const { publicRunId, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)(); const req = { + runId: publicRunId, workflowRunBackendId, workflowJobRunBackendId, nameFilter: generated_1.StringValue.create({ value: artifactName }) @@ -2778,8 +2789,9 @@ exports.listArtifactsPublic = listArtifactsPublic; function listArtifactsInternal(latest = false) { return __awaiter(this, void 0, void 0, function* () { const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)(); - const { workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)(); + const { publicRunId, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)(); const req = { + runId: publicRunId, workflowRunBackendId, workflowJobRunBackendId }; @@ -3345,9 +3357,14 @@ function getBackendIdsFromToken() { // missing expected number of claims throw InvalidJwtError; } + const publicRunId = process.env["GITHUB_JOB"]; + if (publicRunId == null) { + throw new Error("failed to get GITHUB_JOB environment variable"); + } const ids = { workflowRunBackendId: scopeParts[1], - workflowJobRunBackendId: scopeParts[2] + workflowJobRunBackendId: scopeParts[2], + publicRunId: publicRunId, }; core.debug(`Workflow Run Backend ID: ${ids.workflowRunBackendId}`); core.debug(`Workflow Job Run Backend ID: ${ids.workflowJobRunBackendId}`); @@ -3682,6 +3699,7 @@ function uploadArtifact(name, files, rootDirectory, options) { const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)(); // create the artifact const createArtifactReq = { + runId: backendIds.publicRunId, workflowRunBackendId: backendIds.workflowRunBackendId, workflowJobRunBackendId: backendIds.workflowJobRunBackendId, name, @@ -3701,6 +3719,7 @@ function uploadArtifact(name, files, rootDirectory, options) { const uploadResult = yield (0, blob_upload_1.uploadZipToBlobStorage)(createArtifactResp.signedUploadUrl, zipUploadStream); // finalize the artifact const finalizeArtifactReq = { + runId: backendIds.publicRunId, workflowRunBackendId: backendIds.workflowRunBackendId, workflowJobRunBackendId: backendIds.workflowJobRunBackendId, name, diff --git a/dist/upload/index.js b/dist/upload/index.js index 2df6cccf..de3d4c9f 100644 --- a/dist/upload/index.js +++ b/dist/upload/index.js @@ -845,11 +845,12 @@ class CreateArtifactRequest$Type extends runtime_5.MessageType { { no: 2, name: "workflow_job_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 3, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 4, name: "expires_at", kind: "message", T: () => timestamp_1.Timestamp }, - { no: 5, name: "version", kind: "scalar", T: 5 /*ScalarType.INT32*/ } + { no: 5, name: "version", kind: "scalar", T: 5 /*ScalarType.INT32*/ }, + { no: 6, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, ]); } create(value) { - const message = { workflowRunBackendId: "", workflowJobRunBackendId: "", name: "", version: 0 }; + const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", name: "", version: 0 }; globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) (0, runtime_3.reflectionMergePartial)(this, message, value); @@ -978,10 +979,11 @@ class FinalizeArtifactRequest$Type extends runtime_5.MessageType { { no: 5, name: "hash", kind: "message", T: () => wrappers_2.StringValue }, { no: 6, name: "etag", kind: "scalar", T: 9 }, { no: 6, name: "upload_id", kind: "scalar", T: 9 }, + { no: 8, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, ]); } create(value) { - const message = { workflowRunBackendId: "", workflowJobRunBackendId: "", name: "", size: "0", etag: "", uploadId: "" }; + const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", name: "", size: "0", etag: "", uploadId: "" }; globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) (0, runtime_3.reflectionMergePartial)(this, message, value); @@ -1106,11 +1108,12 @@ class ListArtifactsRequest$Type extends runtime_5.MessageType { { no: 1, name: "workflow_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 2, name: "workflow_job_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 3, name: "name_filter", kind: "message", T: () => wrappers_2.StringValue }, - { no: 4, name: "id_filter", kind: "message", T: () => wrappers_1.Int64Value } + { no: 4, name: "id_filter", kind: "message", T: () => wrappers_1.Int64Value }, + { no: 5, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, ]); } create(value) { - const message = { workflowRunBackendId: "", workflowJobRunBackendId: "" }; + const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "" }; globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) (0, runtime_3.reflectionMergePartial)(this, message, value); @@ -1223,11 +1226,12 @@ class ListArtifactsResponse_MonolithArtifact$Type extends runtime_5.MessageType { no: 3, name: "database_id", kind: "scalar", T: 3 /*ScalarType.INT64*/ }, { no: 4, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 5, name: "size", kind: "scalar", T: 3 /*ScalarType.INT64*/ }, - { no: 6, name: "created_at", kind: "message", T: () => timestamp_1.Timestamp } + { no: 6, name: "created_at", kind: "message", T: () => timestamp_1.Timestamp }, + { no: 7, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, ]); } create(value) { - const message = { workflowRunBackendId: "", workflowJobRunBackendId: "", databaseId: "0", name: "", size: "0" }; + const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", databaseId: "0", name: "", size: "0" }; globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) (0, runtime_3.reflectionMergePartial)(this, message, value); @@ -1302,11 +1306,12 @@ class GetSignedArtifactURLRequest$Type extends runtime_5.MessageType { super("github.actions.results.api.v1.GetSignedArtifactURLRequest", [ { no: 1, name: "workflow_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 2, name: "workflow_job_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, - { no: 3, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ } + { no: 3, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, + { no: 4, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, ]); } create(value) { - const message = { workflowRunBackendId: "", workflowJobRunBackendId: "", name: "" }; + const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", name: "" }; globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) (0, runtime_3.reflectionMergePartial)(this, message, value); @@ -1410,11 +1415,12 @@ class DeleteArtifactRequest$Type extends runtime_5.MessageType { super("github.actions.results.api.v1.DeleteArtifactRequest", [ { no: 1, name: "workflow_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 2, name: "workflow_job_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, - { no: 3, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ } + { no: 3, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, + { no: 4, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, ]); } create(value) { - const message = { workflowRunBackendId: "", workflowJobRunBackendId: "", name: "" }; + const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", name: "" }; globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) (0, runtime_3.reflectionMergePartial)(this, message, value); @@ -2257,8 +2263,9 @@ exports.deleteArtifactPublic = deleteArtifactPublic; function deleteArtifactInternal(artifactName) { return __awaiter(this, void 0, void 0, function* () { const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)(); - const { workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)(); + const { publicRunId, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)(); const listReq = { + runId: publicRunId, workflowRunBackendId, workflowJobRunBackendId, nameFilter: generated_1.StringValue.create({ value: artifactName }) @@ -2273,6 +2280,7 @@ function deleteArtifactInternal(artifactName) { (0, core_1.debug)(`More than one artifact found for a single name, returning newest (id: ${artifact.databaseId})`); } const req = { + runId: publicRunId, workflowRunBackendId: artifact.workflowRunBackendId, workflowJobRunBackendId: artifact.workflowJobRunBackendId, name: artifact.name @@ -2500,8 +2508,9 @@ function downloadArtifactInternal(artifactId, options) { return __awaiter(this, void 0, void 0, function* () { const downloadPath = yield resolveOrCreateDirectory(options === null || options === void 0 ? void 0 : options.path); const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)(); - const { workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)(); + const { publicRunId, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)(); const listReq = { + runId: publicRunId, workflowRunBackendId, workflowJobRunBackendId, idFilter: generated_1.Int64Value.create({ value: artifactId.toString() }) @@ -2514,6 +2523,7 @@ function downloadArtifactInternal(artifactId, options) { core.warning('Multiple artifacts found, defaulting to first.'); } const signedReq = { + runId: artifacts[0].runId, workflowRunBackendId: artifacts[0].workflowRunBackendId, workflowJobRunBackendId: artifacts[0].workflowJobRunBackendId, name: artifacts[0].name @@ -2643,8 +2653,9 @@ exports.getArtifactPublic = getArtifactPublic; function getArtifactInternal(artifactName) { return __awaiter(this, void 0, void 0, function* () { const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)(); - const { workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)(); + const { publicRunId, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)(); const req = { + runId: publicRunId, workflowRunBackendId, workflowJobRunBackendId, nameFilter: generated_1.StringValue.create({ value: artifactName }) @@ -2778,8 +2789,9 @@ exports.listArtifactsPublic = listArtifactsPublic; function listArtifactsInternal(latest = false) { return __awaiter(this, void 0, void 0, function* () { const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)(); - const { workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)(); + const { publicRunId, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)(); const req = { + runId: publicRunId, workflowRunBackendId, workflowJobRunBackendId }; @@ -3345,9 +3357,14 @@ function getBackendIdsFromToken() { // missing expected number of claims throw InvalidJwtError; } + const publicRunId = process.env["GITHUB_JOB"]; + if (publicRunId == null) { + throw new Error("failed to get GITHUB_JOB environment variable"); + } const ids = { workflowRunBackendId: scopeParts[1], - workflowJobRunBackendId: scopeParts[2] + workflowJobRunBackendId: scopeParts[2], + publicRunId: publicRunId, }; core.debug(`Workflow Run Backend ID: ${ids.workflowRunBackendId}`); core.debug(`Workflow Job Run Backend ID: ${ids.workflowJobRunBackendId}`); @@ -3682,6 +3699,7 @@ function uploadArtifact(name, files, rootDirectory, options) { const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)(); // create the artifact const createArtifactReq = { + runId: backendIds.publicRunId, workflowRunBackendId: backendIds.workflowRunBackendId, workflowJobRunBackendId: backendIds.workflowJobRunBackendId, name, @@ -3701,6 +3719,7 @@ function uploadArtifact(name, files, rootDirectory, options) { const uploadResult = yield (0, blob_upload_1.uploadZipToBlobStorage)(createArtifactResp.signedUploadUrl, zipUploadStream); // finalize the artifact const finalizeArtifactReq = { + runId: backendIds.publicRunId, workflowRunBackendId: backendIds.workflowRunBackendId, workflowJobRunBackendId: backendIds.workflowJobRunBackendId, name,