-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Description
Describe the bug
This is a spinoff from #5011
Given two jobs in a workflow that have the same name, gh run view --log will incorrectly show the same log twice rather than the actual log for each independent job.
Steps to reproduce the behavior
Here is a workflow definition that produces the same job name twice.
Running gh run view 5415196651 --log produces the same log twice, as we can see by the random number produced (output snipped for readability):
duplicate Set up job 2023-06-29T18:16:44.1239045Z Complete job name: duplicate
duplicate Run echo "Random number: ${RANDOM}" 2023-06-29T18:16:44.2623378Z ##[group]Run echo "Random number: ${RANDOM}"
duplicate Run echo "Random number: ${RANDOM}" 2023-06-29T18:16:44.2624075Z echo "Random number: ${RANDOM}"
duplicate Run echo "Random number: ${RANDOM}" 2023-06-29T18:16:44.3460078Z shell: /usr/bin/bash -e {0}
duplicate Run echo "Random number: ${RANDOM}" 2023-06-29T18:16:44.3460624Z ##[endgroup]
duplicate Run echo "Random number: ${RANDOM}" 2023-06-29T18:16:44.4148078Z Random number: 10677
duplicate Complete job 2023-06-29T18:16:44.4479521Z Cleaning up orphan processes
...
duplicate Run echo "Random number: ${RANDOM}" 2023-06-29T18:16:44.2623378Z ##[group]Run echo "Random number: ${RANDOM}"
duplicate Run echo "Random number: ${RANDOM}" 2023-06-29T18:16:44.2624075Z echo "Random number: ${RANDOM}"
duplicate Run echo "Random number: ${RANDOM}" 2023-06-29T18:16:44.3460078Z shell: /usr/bin/bash -e {0}
duplicate Run echo "Random number: ${RANDOM}" 2023-06-29T18:16:44.3460624Z ##[endgroup]
duplicate Run echo "Random number: ${RANDOM}" 2023-06-29T18:16:44.4148078Z Random number: 10677
duplicate Complete job 2023-06-29T18:16:44.4479521Z Cleaning up orphan processes
Expected vs actual behavior
As seen in the web job logs, the random number produced for the second job was different. I would expect it to show the same logs as the web UI.
Why does this happen?
As described in my comment when the .zip file is produced, there is an attempt to make file names unique because job name uniqueness is not guaranteed. This is done by appending a counter to the end of the filepath inside the .zip as seen in the shell output below. Our regexp matching logic does not apply the same behaviour, resulting in us not matching file names to their jobs.
➜ run-log-5415196651-1688062594 ls -lah
total 32
-rw-r--r-- 1 williammartin staff 2.1K Jun 29 18:17 1_duplicate (1).txt
-rw-r--r-- 1 williammartin staff 2.1K Jun 29 18:17 1_duplicate (2).txt
-rw-r--r-- 1 williammartin staff 448B Jun 29 18:17 1_duplicate.txt
-rw-r--r-- 1 williammartin staff 450B Jun 29 18:17 2_duplicate.txt
drwxr-xr-x 5 williammartin staff 160B Jun 29 20:18 duplicate
drwxr-xr-x 5 williammartin staff 160B Jun 29 20:18 duplicate (1)