Skip to content

Commit

Permalink
Pass public run ID to artifacts service.
Browse files Browse the repository at this point in the history
Public run IDs are shared across re-runs.
  • Loading branch information
nichtverstehen committed Mar 12, 2024
1 parent 216dce9 commit 1a0a67e
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 33 deletions.
51 changes: 35 additions & 16 deletions dist/merge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 })
Expand All @@ -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
Expand Down Expand Up @@ -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() })
Expand All @@ -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
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -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
};
Expand Down Expand Up @@ -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}`);
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Loading

0 comments on commit 1a0a67e

Please sign in to comment.