@actions/artifact 1.1.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/README.md +111 -174
  2. package/lib/artifact.d.ts +6 -0
  3. package/lib/artifact.js +23 -0
  4. package/lib/artifact.js.map +1 -0
  5. package/lib/generated/google/protobuf/timestamp.d.ts +145 -0
  6. package/lib/generated/google/protobuf/timestamp.js +136 -0
  7. package/lib/generated/google/protobuf/timestamp.js.map +1 -0
  8. package/lib/generated/google/protobuf/wrappers.d.ts +307 -0
  9. package/lib/generated/google/protobuf/wrappers.js +609 -0
  10. package/lib/generated/google/protobuf/wrappers.js.map +1 -0
  11. package/lib/generated/index.d.ts +4 -0
  12. package/lib/generated/index.js +21 -0
  13. package/lib/generated/index.js.map +1 -0
  14. package/lib/generated/results/api/v1/artifact.d.ts +286 -0
  15. package/lib/generated/results/api/v1/artifact.js +588 -0
  16. package/lib/generated/results/api/v1/artifact.js.map +1 -0
  17. package/lib/generated/results/api/v1/artifact.twirp.d.ts +43 -0
  18. package/lib/generated/results/api/v1/artifact.twirp.js +416 -0
  19. package/lib/generated/results/api/v1/artifact.twirp.js.map +1 -0
  20. package/lib/internal/client.d.ts +61 -0
  21. package/lib/internal/client.js +121 -0
  22. package/lib/internal/client.js.map +1 -0
  23. package/lib/internal/download/download-artifact.d.ts +3 -0
  24. package/lib/internal/download/download-artifact.js +168 -0
  25. package/lib/internal/download/download-artifact.js.map +1 -0
  26. package/lib/internal/find/get-artifact.d.ts +3 -0
  27. package/lib/internal/find/get-artifact.js +118 -0
  28. package/lib/internal/find/get-artifact.js.map +1 -0
  29. package/lib/internal/find/list-artifacts.d.ts +3 -0
  30. package/lib/internal/find/list-artifacts.js +139 -0
  31. package/lib/internal/find/list-artifacts.js.map +1 -0
  32. package/lib/internal/find/retry-options.d.ts +7 -0
  33. package/lib/internal/find/retry-options.js +50 -0
  34. package/lib/internal/find/retry-options.js.map +1 -0
  35. package/lib/internal/shared/artifact-twirp-client.d.ts +6 -0
  36. package/lib/internal/shared/artifact-twirp-client.js +153 -0
  37. package/lib/internal/shared/artifact-twirp-client.js.map +1 -0
  38. package/lib/internal/shared/config.d.ts +6 -0
  39. package/lib/internal/shared/config.js +55 -0
  40. package/lib/internal/shared/config.js.map +1 -0
  41. package/lib/internal/shared/errors.d.ts +22 -0
  42. package/lib/internal/shared/errors.js +70 -0
  43. package/lib/internal/shared/errors.js.map +1 -0
  44. package/lib/internal/shared/interfaces.d.ts +136 -0
  45. package/lib/internal/{contracts.js → shared/interfaces.js} +1 -1
  46. package/lib/internal/shared/interfaces.js.map +1 -0
  47. package/lib/internal/shared/user-agent.d.ts +4 -0
  48. package/lib/internal/shared/user-agent.js +13 -0
  49. package/lib/internal/shared/user-agent.js.map +1 -0
  50. package/lib/internal/shared/util.d.ts +5 -0
  51. package/lib/internal/shared/util.js +81 -0
  52. package/lib/internal/shared/util.js.map +1 -0
  53. package/lib/internal/upload/blob-upload.d.ts +12 -0
  54. package/lib/internal/upload/blob-upload.js +87 -0
  55. package/lib/internal/upload/blob-upload.js.map +1 -0
  56. package/lib/internal/upload/path-and-artifact-name-validation.d.ts +8 -0
  57. package/lib/internal/{path-and-artifact-name-validation.js → upload/path-and-artifact-name-validation.js} +12 -12
  58. package/lib/internal/upload/path-and-artifact-name-validation.js.map +1 -0
  59. package/lib/internal/upload/retention.d.ts +2 -0
  60. package/lib/internal/upload/retention.js +54 -0
  61. package/lib/internal/upload/retention.js.map +1 -0
  62. package/lib/internal/upload/upload-artifact.d.ts +2 -0
  63. package/lib/internal/upload/upload-artifact.js +103 -0
  64. package/lib/internal/upload/upload-artifact.js.map +1 -0
  65. package/lib/internal/upload/upload-zip-specification.d.ts +21 -0
  66. package/lib/internal/upload/upload-zip-specification.js +113 -0
  67. package/lib/internal/upload/upload-zip-specification.js.map +1 -0
  68. package/lib/internal/upload/zip.d.ts +9 -0
  69. package/lib/internal/upload/zip.js +113 -0
  70. package/lib/internal/upload/zip.js.map +1 -0
  71. package/package.json +27 -11
  72. package/lib/artifact-client.d.ts +0 -10
  73. package/lib/artifact-client.js +0 -12
  74. package/lib/artifact-client.js.map +0 -1
  75. package/lib/internal/artifact-client.d.ts +0 -41
  76. package/lib/internal/artifact-client.js +0 -178
  77. package/lib/internal/artifact-client.js.map +0 -1
  78. package/lib/internal/config-variables.d.ts +0 -11
  79. package/lib/internal/config-variables.js +0 -72
  80. package/lib/internal/config-variables.js.map +0 -1
  81. package/lib/internal/contracts.d.ts +0 -67
  82. package/lib/internal/contracts.js.map +0 -1
  83. package/lib/internal/crc64.d.ts +0 -21
  84. package/lib/internal/crc64.js +0 -303
  85. package/lib/internal/crc64.js.map +0 -1
  86. package/lib/internal/download-http-client.d.ts +0 -39
  87. package/lib/internal/download-http-client.js +0 -292
  88. package/lib/internal/download-http-client.js.map +0 -1
  89. package/lib/internal/download-options.d.ts +0 -7
  90. package/lib/internal/download-options.js +0 -3
  91. package/lib/internal/download-options.js.map +0 -1
  92. package/lib/internal/download-response.d.ts +0 -10
  93. package/lib/internal/download-response.js +0 -3
  94. package/lib/internal/download-response.js.map +0 -1
  95. package/lib/internal/download-specification.d.ts +0 -19
  96. package/lib/internal/download-specification.js +0 -74
  97. package/lib/internal/download-specification.js.map +0 -1
  98. package/lib/internal/http-manager.d.ts +0 -12
  99. package/lib/internal/http-manager.js +0 -32
  100. package/lib/internal/http-manager.js.map +0 -1
  101. package/lib/internal/path-and-artifact-name-validation.d.ts +0 -8
  102. package/lib/internal/path-and-artifact-name-validation.js.map +0 -1
  103. package/lib/internal/requestUtils.d.ts +0 -3
  104. package/lib/internal/requestUtils.js +0 -88
  105. package/lib/internal/requestUtils.js.map +0 -1
  106. package/lib/internal/status-reporter.d.ts +0 -21
  107. package/lib/internal/status-reporter.js +0 -52
  108. package/lib/internal/status-reporter.js.map +0 -1
  109. package/lib/internal/upload-gzip.d.ts +0 -14
  110. package/lib/internal/upload-gzip.js +0 -121
  111. package/lib/internal/upload-gzip.js.map +0 -1
  112. package/lib/internal/upload-http-client.d.ts +0 -48
  113. package/lib/internal/upload-http-client.js +0 -409
  114. package/lib/internal/upload-http-client.js.map +0 -1
  115. package/lib/internal/upload-options.d.ts +0 -34
  116. package/lib/internal/upload-options.js +0 -3
  117. package/lib/internal/upload-options.js.map +0 -1
  118. package/lib/internal/upload-response.d.ts +0 -19
  119. package/lib/internal/upload-response.js +0 -3
  120. package/lib/internal/upload-response.js.map +0 -1
  121. package/lib/internal/upload-specification.d.ts +0 -11
  122. package/lib/internal/upload-specification.js +0 -101
  123. package/lib/internal/upload-specification.js.map +0 -1
  124. package/lib/internal/utils.d.ts +0 -70
  125. package/lib/internal/utils.js +0 -292
  126. package/lib/internal/utils.js.map +0 -1
@@ -1,409 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
- return new (P || (P = Promise))(function (resolve, reject) {
24
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.UploadHttpClient = void 0;
32
- const fs = __importStar(require("fs"));
33
- const core = __importStar(require("@actions/core"));
34
- const tmp = __importStar(require("tmp-promise"));
35
- const stream = __importStar(require("stream"));
36
- const utils_1 = require("./utils");
37
- const config_variables_1 = require("./config-variables");
38
- const util_1 = require("util");
39
- const url_1 = require("url");
40
- const perf_hooks_1 = require("perf_hooks");
41
- const status_reporter_1 = require("./status-reporter");
42
- const http_client_1 = require("@actions/http-client");
43
- const http_manager_1 = require("./http-manager");
44
- const upload_gzip_1 = require("./upload-gzip");
45
- const requestUtils_1 = require("./requestUtils");
46
- const stat = util_1.promisify(fs.stat);
47
- class UploadHttpClient {
48
- constructor() {
49
- this.uploadHttpManager = new http_manager_1.HttpManager(config_variables_1.getUploadFileConcurrency(), '@actions/artifact-upload');
50
- this.statusReporter = new status_reporter_1.StatusReporter(10000);
51
- }
52
- /**
53
- * Creates a file container for the new artifact in the remote blob storage/file service
54
- * @param {string} artifactName Name of the artifact being created
55
- * @returns The response from the Artifact Service if the file container was successfully created
56
- */
57
- createArtifactInFileContainer(artifactName, options) {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- const parameters = {
60
- Type: 'actions_storage',
61
- Name: artifactName
62
- };
63
- // calculate retention period
64
- if (options && options.retentionDays) {
65
- const maxRetentionStr = config_variables_1.getRetentionDays();
66
- parameters.RetentionDays = utils_1.getProperRetention(options.retentionDays, maxRetentionStr);
67
- }
68
- const data = JSON.stringify(parameters, null, 2);
69
- const artifactUrl = utils_1.getArtifactUrl();
70
- // use the first client from the httpManager, `keep-alive` is not used so the connection will close immediately
71
- const client = this.uploadHttpManager.getClient(0);
72
- const headers = utils_1.getUploadHeaders('application/json', false);
73
- // Extra information to display when a particular HTTP code is returned
74
- // If a 403 is returned when trying to create a file container, the customer has exceeded
75
- // their storage quota so no new artifact containers can be created
76
- const customErrorMessages = new Map([
77
- [
78
- http_client_1.HttpCodes.Forbidden,
79
- 'Artifact storage quota has been hit. Unable to upload any new artifacts'
80
- ],
81
- [
82
- http_client_1.HttpCodes.BadRequest,
83
- `The artifact name ${artifactName} is not valid. Request URL ${artifactUrl}`
84
- ]
85
- ]);
86
- const response = yield requestUtils_1.retryHttpClientRequest('Create Artifact Container', () => __awaiter(this, void 0, void 0, function* () { return client.post(artifactUrl, data, headers); }), customErrorMessages);
87
- const body = yield response.readBody();
88
- return JSON.parse(body);
89
- });
90
- }
91
- /**
92
- * Concurrently upload all of the files in chunks
93
- * @param {string} uploadUrl Base Url for the artifact that was created
94
- * @param {SearchResult[]} filesToUpload A list of information about the files being uploaded
95
- * @returns The size of all the files uploaded in bytes
96
- */
97
- uploadArtifactToFileContainer(uploadUrl, filesToUpload, options) {
98
- return __awaiter(this, void 0, void 0, function* () {
99
- const FILE_CONCURRENCY = config_variables_1.getUploadFileConcurrency();
100
- const MAX_CHUNK_SIZE = config_variables_1.getUploadChunkSize();
101
- core.debug(`File Concurrency: ${FILE_CONCURRENCY}, and Chunk Size: ${MAX_CHUNK_SIZE}`);
102
- const parameters = [];
103
- // by default, file uploads will continue if there is an error unless specified differently in the options
104
- let continueOnError = true;
105
- if (options) {
106
- if (options.continueOnError === false) {
107
- continueOnError = false;
108
- }
109
- }
110
- // prepare the necessary parameters to upload all the files
111
- for (const file of filesToUpload) {
112
- const resourceUrl = new url_1.URL(uploadUrl);
113
- resourceUrl.searchParams.append('itemPath', file.uploadFilePath);
114
- parameters.push({
115
- file: file.absoluteFilePath,
116
- resourceUrl: resourceUrl.toString(),
117
- maxChunkSize: MAX_CHUNK_SIZE,
118
- continueOnError
119
- });
120
- }
121
- const parallelUploads = [...new Array(FILE_CONCURRENCY).keys()];
122
- const failedItemsToReport = [];
123
- let currentFile = 0;
124
- let completedFiles = 0;
125
- let uploadFileSize = 0;
126
- let totalFileSize = 0;
127
- let abortPendingFileUploads = false;
128
- this.statusReporter.setTotalNumberOfFilesToProcess(filesToUpload.length);
129
- this.statusReporter.start();
130
- // only allow a certain amount of files to be uploaded at once, this is done to reduce potential errors
131
- yield Promise.all(parallelUploads.map((index) => __awaiter(this, void 0, void 0, function* () {
132
- while (currentFile < filesToUpload.length) {
133
- const currentFileParameters = parameters[currentFile];
134
- currentFile += 1;
135
- if (abortPendingFileUploads) {
136
- failedItemsToReport.push(currentFileParameters.file);
137
- continue;
138
- }
139
- const startTime = perf_hooks_1.performance.now();
140
- const uploadFileResult = yield this.uploadFileAsync(index, currentFileParameters);
141
- if (core.isDebug()) {
142
- core.debug(`File: ${++completedFiles}/${filesToUpload.length}. ${currentFileParameters.file} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish upload`);
143
- }
144
- uploadFileSize += uploadFileResult.successfulUploadSize;
145
- totalFileSize += uploadFileResult.totalSize;
146
- if (uploadFileResult.isSuccess === false) {
147
- failedItemsToReport.push(currentFileParameters.file);
148
- if (!continueOnError) {
149
- // fail fast
150
- core.error(`aborting artifact upload`);
151
- abortPendingFileUploads = true;
152
- }
153
- }
154
- this.statusReporter.incrementProcessedCount();
155
- }
156
- })));
157
- this.statusReporter.stop();
158
- // done uploading, safety dispose all connections
159
- this.uploadHttpManager.disposeAndReplaceAllClients();
160
- core.info(`Total size of all the files uploaded is ${uploadFileSize} bytes`);
161
- return {
162
- uploadSize: uploadFileSize,
163
- totalSize: totalFileSize,
164
- failedItems: failedItemsToReport
165
- };
166
- });
167
- }
168
- /**
169
- * Asynchronously uploads a file. The file is compressed and uploaded using GZip if it is determined to save space.
170
- * If the upload file is bigger than the max chunk size it will be uploaded via multiple calls
171
- * @param {number} httpClientIndex The index of the httpClient that is being used to make all of the calls
172
- * @param {UploadFileParameters} parameters Information about the file that needs to be uploaded
173
- * @returns The size of the file that was uploaded in bytes along with any failed uploads
174
- */
175
- uploadFileAsync(httpClientIndex, parameters) {
176
- return __awaiter(this, void 0, void 0, function* () {
177
- const fileStat = yield stat(parameters.file);
178
- const totalFileSize = fileStat.size;
179
- const isFIFO = fileStat.isFIFO();
180
- let offset = 0;
181
- let isUploadSuccessful = true;
182
- let failedChunkSizes = 0;
183
- let uploadFileSize = 0;
184
- let isGzip = true;
185
- // the file that is being uploaded is less than 64k in size to increase throughput and to minimize disk I/O
186
- // for creating a new GZip file, an in-memory buffer is used for compression
187
- // with named pipes the file size is reported as zero in that case don't read the file in memory
188
- if (!isFIFO && totalFileSize < 65536) {
189
- core.debug(`${parameters.file} is less than 64k in size. Creating a gzip file in-memory to potentially reduce the upload size`);
190
- const buffer = yield upload_gzip_1.createGZipFileInBuffer(parameters.file);
191
- // An open stream is needed in the event of a failure and we need to retry. If a NodeJS.ReadableStream is directly passed in,
192
- // it will not properly get reset to the start of the stream if a chunk upload needs to be retried
193
- let openUploadStream;
194
- if (totalFileSize < buffer.byteLength) {
195
- // compression did not help with reducing the size, use a readable stream from the original file for upload
196
- core.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`);
197
- openUploadStream = () => fs.createReadStream(parameters.file);
198
- isGzip = false;
199
- uploadFileSize = totalFileSize;
200
- }
201
- else {
202
- // create a readable stream using a PassThrough stream that is both readable and writable
203
- core.debug(`A gzip file created for ${parameters.file} helped with reducing the size of the original file. The file will be uploaded using gzip.`);
204
- openUploadStream = () => {
205
- const passThrough = new stream.PassThrough();
206
- passThrough.end(buffer);
207
- return passThrough;
208
- };
209
- uploadFileSize = buffer.byteLength;
210
- }
211
- const result = yield this.uploadChunk(httpClientIndex, parameters.resourceUrl, openUploadStream, 0, uploadFileSize - 1, uploadFileSize, isGzip, totalFileSize);
212
- if (!result) {
213
- // chunk failed to upload
214
- isUploadSuccessful = false;
215
- failedChunkSizes += uploadFileSize;
216
- core.warning(`Aborting upload for ${parameters.file} due to failure`);
217
- }
218
- return {
219
- isSuccess: isUploadSuccessful,
220
- successfulUploadSize: uploadFileSize - failedChunkSizes,
221
- totalSize: totalFileSize
222
- };
223
- }
224
- else {
225
- // the file that is being uploaded is greater than 64k in size, a temporary file gets created on disk using the
226
- // npm tmp-promise package and this file gets used to create a GZipped file
227
- const tempFile = yield tmp.file();
228
- core.debug(`${parameters.file} is greater than 64k in size. Creating a gzip file on-disk ${tempFile.path} to potentially reduce the upload size`);
229
- // create a GZip file of the original file being uploaded, the original file should not be modified in any way
230
- uploadFileSize = yield upload_gzip_1.createGZipFileOnDisk(parameters.file, tempFile.path);
231
- let uploadFilePath = tempFile.path;
232
- // compression did not help with size reduction, use the original file for upload and delete the temp GZip file
233
- // for named pipes totalFileSize is zero, this assumes compression did help
234
- if (!isFIFO && totalFileSize < uploadFileSize) {
235
- core.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`);
236
- uploadFileSize = totalFileSize;
237
- uploadFilePath = parameters.file;
238
- isGzip = false;
239
- }
240
- else {
241
- core.debug(`The gzip file created for ${parameters.file} is smaller than the original file. The file will be uploaded using gzip.`);
242
- }
243
- let abortFileUpload = false;
244
- // upload only a single chunk at a time
245
- while (offset < uploadFileSize) {
246
- const chunkSize = Math.min(uploadFileSize - offset, parameters.maxChunkSize);
247
- const startChunkIndex = offset;
248
- const endChunkIndex = offset + chunkSize - 1;
249
- offset += parameters.maxChunkSize;
250
- if (abortFileUpload) {
251
- // if we don't want to continue in the event of an error, any pending upload chunks will be marked as failed
252
- failedChunkSizes += chunkSize;
253
- continue;
254
- }
255
- const result = yield this.uploadChunk(httpClientIndex, parameters.resourceUrl, () => fs.createReadStream(uploadFilePath, {
256
- start: startChunkIndex,
257
- end: endChunkIndex,
258
- autoClose: false
259
- }), startChunkIndex, endChunkIndex, uploadFileSize, isGzip, totalFileSize);
260
- if (!result) {
261
- // Chunk failed to upload, report as failed and do not continue uploading any more chunks for the file. It is possible that part of a chunk was
262
- // successfully uploaded so the server may report a different size for what was uploaded
263
- isUploadSuccessful = false;
264
- failedChunkSizes += chunkSize;
265
- core.warning(`Aborting upload for ${parameters.file} due to failure`);
266
- abortFileUpload = true;
267
- }
268
- else {
269
- // if an individual file is greater than 8MB (1024*1024*8) in size, display extra information about the upload status
270
- if (uploadFileSize > 8388608) {
271
- this.statusReporter.updateLargeFileStatus(parameters.file, startChunkIndex, endChunkIndex, uploadFileSize);
272
- }
273
- }
274
- }
275
- // Delete the temporary file that was created as part of the upload. If the temp file does not get manually deleted by
276
- // calling cleanup, it gets removed when the node process exits. For more info see: https://www.npmjs.com/package/tmp-promise#about
277
- core.debug(`deleting temporary gzip file ${tempFile.path}`);
278
- yield tempFile.cleanup();
279
- return {
280
- isSuccess: isUploadSuccessful,
281
- successfulUploadSize: uploadFileSize - failedChunkSizes,
282
- totalSize: totalFileSize
283
- };
284
- }
285
- });
286
- }
287
- /**
288
- * Uploads a chunk of an individual file to the specified resourceUrl. If the upload fails and the status code
289
- * indicates a retryable status, we try to upload the chunk as well
290
- * @param {number} httpClientIndex The index of the httpClient being used to make all the necessary calls
291
- * @param {string} resourceUrl Url of the resource that the chunk will be uploaded to
292
- * @param {NodeJS.ReadableStream} openStream Stream of the file that will be uploaded
293
- * @param {number} start Starting byte index of file that the chunk belongs to
294
- * @param {number} end Ending byte index of file that the chunk belongs to
295
- * @param {number} uploadFileSize Total size of the file in bytes that is being uploaded
296
- * @param {boolean} isGzip Denotes if we are uploading a Gzip compressed stream
297
- * @param {number} totalFileSize Original total size of the file that is being uploaded
298
- * @returns if the chunk was successfully uploaded
299
- */
300
- uploadChunk(httpClientIndex, resourceUrl, openStream, start, end, uploadFileSize, isGzip, totalFileSize) {
301
- return __awaiter(this, void 0, void 0, function* () {
302
- // open a new stream and read it to compute the digest
303
- const digest = yield utils_1.digestForStream(openStream());
304
- // prepare all the necessary headers before making any http call
305
- const headers = utils_1.getUploadHeaders('application/octet-stream', true, isGzip, totalFileSize, end - start + 1, utils_1.getContentRange(start, end, uploadFileSize), digest);
306
- const uploadChunkRequest = () => __awaiter(this, void 0, void 0, function* () {
307
- const client = this.uploadHttpManager.getClient(httpClientIndex);
308
- return yield client.sendStream('PUT', resourceUrl, openStream(), headers);
309
- });
310
- let retryCount = 0;
311
- const retryLimit = config_variables_1.getRetryLimit();
312
- // Increments the current retry count and then checks if the retry limit has been reached
313
- // If there have been too many retries, fail so the download stops
314
- const incrementAndCheckRetryLimit = (response) => {
315
- retryCount++;
316
- if (retryCount > retryLimit) {
317
- if (response) {
318
- utils_1.displayHttpDiagnostics(response);
319
- }
320
- core.info(`Retry limit has been reached for chunk at offset ${start} to ${resourceUrl}`);
321
- return true;
322
- }
323
- return false;
324
- };
325
- const backOff = (retryAfterValue) => __awaiter(this, void 0, void 0, function* () {
326
- this.uploadHttpManager.disposeAndReplaceClient(httpClientIndex);
327
- if (retryAfterValue) {
328
- core.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the upload`);
329
- yield utils_1.sleep(retryAfterValue);
330
- }
331
- else {
332
- const backoffTime = utils_1.getExponentialRetryTimeInMilliseconds(retryCount);
333
- core.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the upload at offset ${start}`);
334
- yield utils_1.sleep(backoffTime);
335
- }
336
- core.info(`Finished backoff for retry #${retryCount}, continuing with upload`);
337
- return;
338
- });
339
- // allow for failed chunks to be retried multiple times
340
- while (retryCount <= retryLimit) {
341
- let response;
342
- try {
343
- response = yield uploadChunkRequest();
344
- }
345
- catch (error) {
346
- // if an error is caught, it is usually indicative of a timeout so retry the upload
347
- core.info(`An error has been caught http-client index ${httpClientIndex}, retrying the upload`);
348
- // eslint-disable-next-line no-console
349
- console.log(error);
350
- if (incrementAndCheckRetryLimit()) {
351
- return false;
352
- }
353
- yield backOff();
354
- continue;
355
- }
356
- // Always read the body of the response. There is potential for a resource leak if the body is not read which will
357
- // result in the connection remaining open along with unintended consequences when trying to dispose of the client
358
- yield response.readBody();
359
- if (utils_1.isSuccessStatusCode(response.message.statusCode)) {
360
- return true;
361
- }
362
- else if (utils_1.isRetryableStatusCode(response.message.statusCode)) {
363
- core.info(`A ${response.message.statusCode} status code has been received, will attempt to retry the upload`);
364
- if (incrementAndCheckRetryLimit(response)) {
365
- return false;
366
- }
367
- utils_1.isThrottledStatusCode(response.message.statusCode)
368
- ? yield backOff(utils_1.tryGetRetryAfterValueTimeInMilliseconds(response.message.headers))
369
- : yield backOff();
370
- }
371
- else {
372
- core.error(`Unexpected response. Unable to upload chunk to ${resourceUrl}`);
373
- utils_1.displayHttpDiagnostics(response);
374
- return false;
375
- }
376
- }
377
- return false;
378
- });
379
- }
380
- /**
381
- * Updates the size of the artifact from -1 which was initially set when the container was first created for the artifact.
382
- * Updating the size indicates that we are done uploading all the contents of the artifact
383
- */
384
- patchArtifactSize(size, artifactName) {
385
- return __awaiter(this, void 0, void 0, function* () {
386
- const resourceUrl = new url_1.URL(utils_1.getArtifactUrl());
387
- resourceUrl.searchParams.append('artifactName', artifactName);
388
- const parameters = { Size: size };
389
- const data = JSON.stringify(parameters, null, 2);
390
- core.debug(`URL is ${resourceUrl.toString()}`);
391
- // use the first client from the httpManager, `keep-alive` is not used so the connection will close immediately
392
- const client = this.uploadHttpManager.getClient(0);
393
- const headers = utils_1.getUploadHeaders('application/json', false);
394
- // Extra information to display when a particular HTTP code is returned
395
- const customErrorMessages = new Map([
396
- [
397
- http_client_1.HttpCodes.NotFound,
398
- `An Artifact with the name ${artifactName} was not found`
399
- ]
400
- ]);
401
- // TODO retry for all possible response codes, the artifact upload is pretty much complete so it at all costs we should try to finish this
402
- const response = yield requestUtils_1.retryHttpClientRequest('Finalize artifact upload', () => __awaiter(this, void 0, void 0, function* () { return client.patch(resourceUrl.toString(), data, headers); }), customErrorMessages);
403
- yield response.readBody();
404
- core.debug(`Artifact ${artifactName} has been successfully uploaded, total size in bytes: ${size}`);
405
- });
406
- }
407
- }
408
- exports.UploadHttpClient = UploadHttpClient;
409
- //# sourceMappingURL=upload-http-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"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F,0IAA0I;YAC1I,MAAM,QAAQ,GAAG,MAAM,qCAAsB,CAC3C,0BAA0B,EAC1B,GAAS,EAAE,gDAAC,OAAA,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA,GAAA,EAC/D,mBAAmB,CACpB,CAAA;YACD,MAAM,QAAQ,CAAC,QAAQ,EAAE,CAAA;YACzB,IAAI,CAAC,KAAK,CACR,YAAY,YAAY,yDAAyD,IAAI,EAAE,CACxF,CAAA;QACH,CAAC;KAAA;CACF;AA/fD,4CA+fC"}
@@ -1,34 +0,0 @@
1
- export interface UploadOptions {
2
- /**
3
- * Indicates if the artifact upload should continue if file or chunk fails to upload from any error.
4
- * If there is a error during upload, a partial artifact will always be associated and available for
5
- * download at the end. The size reported will be the amount of storage that the user or org will be
6
- * charged for the partial artifact. Defaults to true if not specified
7
- *
8
- * If set to false, and an error is encountered, all other uploads will stop and any files or chunks
9
- * that were queued will not be attempted to be uploaded. The partial artifact available will only
10
- * include files and chunks up until the failure
11
- *
12
- * If set to true and an error is encountered, the failed file will be skipped and ignored and all
13
- * other queued files will be attempted to be uploaded. The partial artifact at the end will have all
14
- * files with the exception of the problematic files(s)/chunks(s) that failed to upload
15
- *
16
- */
17
- continueOnError?: boolean;
18
- /**
19
- * Duration after which artifact will expire in days.
20
- *
21
- * By default artifact expires after 90 days:
22
- * https://docs.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts#downloading-and-deleting-artifacts-after-a-workflow-run-is-complete
23
- *
24
- * Use this option to override the default expiry.
25
- *
26
- * Min value: 1
27
- * Max value: 90 unless changed by repository setting
28
- *
29
- * If this is set to a greater value than the retention settings allowed, the retention on artifacts
30
- * will be reduced to match the max value allowed on server, and the upload process will continue. An
31
- * input of 0 assumes default retention setting.
32
- */
33
- retentionDays?: number;
34
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=upload-options.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload-options.js","sourceRoot":"","sources":["../../src/internal/upload-options.ts"],"names":[],"mappings":""}
@@ -1,19 +0,0 @@
1
- export interface UploadResponse {
2
- /**
3
- * The name of the artifact that was uploaded
4
- */
5
- artifactName: string;
6
- /**
7
- * A list of all items that are meant to be uploaded as part of the artifact
8
- */
9
- artifactItems: string[];
10
- /**
11
- * Total size of the artifact in bytes that was uploaded
12
- */
13
- size: number;
14
- /**
15
- * A list of items that were not uploaded as part of the artifact (includes queued items that were not uploaded if
16
- * continueOnError is set to false). This is a subset of artifactItems.
17
- */
18
- failedItems: string[];
19
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=upload-response.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload-response.js","sourceRoot":"","sources":["../../src/internal/upload-response.ts"],"names":[],"mappings":""}
@@ -1,11 +0,0 @@
1
- export interface UploadSpecification {
2
- absoluteFilePath: string;
3
- uploadFilePath: string;
4
- }
5
- /**
6
- * Creates a specification that describes how each file that is part of the artifact will be uploaded
7
- * @param artifactName the name of the artifact being uploaded. Used during upload to denote where the artifact is stored on the server
8
- * @param rootDirectory an absolute file path that denotes the path that should be removed from the beginning of each artifact file
9
- * @param artifactFiles a list of absolute file paths that denote what should be uploaded as part of the artifact
10
- */
11
- export declare function getUploadSpecification(artifactName: string, rootDirectory: string, artifactFiles: string[]): UploadSpecification[];
@@ -1,101 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.getUploadSpecification = void 0;
23
- const fs = __importStar(require("fs"));
24
- const core_1 = require("@actions/core");
25
- const path_1 = require("path");
26
- const path_and_artifact_name_validation_1 = require("./path-and-artifact-name-validation");
27
- /**
28
- * Creates a specification that describes how each file that is part of the artifact will be uploaded
29
- * @param artifactName the name of the artifact being uploaded. Used during upload to denote where the artifact is stored on the server
30
- * @param rootDirectory an absolute file path that denotes the path that should be removed from the beginning of each artifact file
31
- * @param artifactFiles a list of absolute file paths that denote what should be uploaded as part of the artifact
32
- */
33
- function getUploadSpecification(artifactName, rootDirectory, artifactFiles) {
34
- // artifact name was checked earlier on, no need to check again
35
- const specifications = [];
36
- if (!fs.existsSync(rootDirectory)) {
37
- throw new Error(`Provided rootDirectory ${rootDirectory} does not exist`);
38
- }
39
- if (!fs.lstatSync(rootDirectory).isDirectory()) {
40
- throw new Error(`Provided rootDirectory ${rootDirectory} is not a valid directory`);
41
- }
42
- // Normalize and resolve, this allows for either absolute or relative paths to be used
43
- rootDirectory = path_1.normalize(rootDirectory);
44
- rootDirectory = path_1.resolve(rootDirectory);
45
- /*
46
- Example to demonstrate behavior
47
-
48
- Input:
49
- artifactName: my-artifact
50
- rootDirectory: '/home/user/files/plz-upload'
51
- artifactFiles: [
52
- '/home/user/files/plz-upload/file1.txt',
53
- '/home/user/files/plz-upload/file2.txt',
54
- '/home/user/files/plz-upload/dir/file3.txt'
55
- ]
56
-
57
- Output:
58
- specifications: [
59
- ['/home/user/files/plz-upload/file1.txt', 'my-artifact/file1.txt'],
60
- ['/home/user/files/plz-upload/file1.txt', 'my-artifact/file2.txt'],
61
- ['/home/user/files/plz-upload/file1.txt', 'my-artifact/dir/file3.txt']
62
- ]
63
- */
64
- for (let file of artifactFiles) {
65
- if (!fs.existsSync(file)) {
66
- throw new Error(`File ${file} does not exist`);
67
- }
68
- if (!fs.lstatSync(file).isDirectory()) {
69
- // Normalize and resolve, this allows for either absolute or relative paths to be used
70
- file = path_1.normalize(file);
71
- file = path_1.resolve(file);
72
- if (!file.startsWith(rootDirectory)) {
73
- throw new Error(`The rootDirectory: ${rootDirectory} is not a parent directory of the file: ${file}`);
74
- }
75
- // Check for forbidden characters in file paths that will be rejected during upload
76
- const uploadPath = file.replace(rootDirectory, '');
77
- path_and_artifact_name_validation_1.checkArtifactFilePath(uploadPath);
78
- /*
79
- uploadFilePath denotes where the file will be uploaded in the file container on the server. During a run, if multiple artifacts are uploaded, they will all
80
- be saved in the same container. The artifact name is used as the root directory in the container to separate and distinguish uploaded artifacts
81
-
82
- path.join handles all the following cases and would return 'artifact-name/file-to-upload.txt
83
- join('artifact-name/', 'file-to-upload.txt')
84
- join('artifact-name/', '/file-to-upload.txt')
85
- join('artifact-name', 'file-to-upload.txt')
86
- join('artifact-name', '/file-to-upload.txt')
87
- */
88
- specifications.push({
89
- absoluteFilePath: file,
90
- uploadFilePath: path_1.join(artifactName, uploadPath)
91
- });
92
- }
93
- else {
94
- // Directories are rejected by the server during upload
95
- core_1.debug(`Removing ${file} from rawSearchResults because it is a directory`);
96
- }
97
- }
98
- return specifications;
99
- }
100
- exports.getUploadSpecification = getUploadSpecification;
101
- //# sourceMappingURL=upload-specification.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload-specification.js","sourceRoot":"","sources":["../../src/internal/upload-specification.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,wCAAmC;AACnC,+BAA6C;AAC7C,2FAAyE;AAOzE;;;;;GAKG;AACH,SAAgB,sBAAsB,CACpC,YAAoB,EAC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