(name string)
| 238 | const JOB_NAME_MAX_LENGTH = 90 |
| 239 | |
| 240 | func getJobNameForLogFilename(name string) string { |
| 241 | // As described in https://github.com/cli/cli/issues/5011#issuecomment-1570713070, there are a number of steps |
| 242 | // the server can take when producing the downloaded zip file that can result in a mismatch between the job name |
| 243 | // and the filename in the zip including: |
| 244 | // * Removing characters in the job name that aren't allowed in file paths |
| 245 | // * Truncating names that are too long for zip files |
| 246 | // * Adding collision deduplicating numbers for jobs with the same name |
| 247 | // |
| 248 | // We are hesitant to duplicate all the server logic due to the fragility but it may be unavoidable. Currently, we: |
| 249 | // * Strip `/` which occur when composite action job names are constructed of the form `<JOB_NAME`> / <ACTION_NAME>` |
| 250 | // * Truncate long job names |
| 251 | // |
| 252 | sanitizedJobName := strings.ReplaceAll(name, "/", "") |
| 253 | sanitizedJobName = strings.ReplaceAll(sanitizedJobName, ":", "") |
| 254 | sanitizedJobName = truncateAsUTF16(sanitizedJobName, JOB_NAME_MAX_LENGTH) |
| 255 | return sanitizedJobName |
| 256 | } |
| 257 | |
| 258 | // A job run log file is a top-level .txt file whose name starts with an ordinal |
| 259 | // number; e.g., "0_jobname.txt". |
no test coverage detected