Skip to content

Commit 708ba00

Browse files
committed
Revise os log collection.
1 parent a4f9f4f commit 708ba00

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

.github/workflows/common.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,18 @@ jobs:
6868
mv bin/${{ env.BUILD_CONFIGURATION }}/container-installer-unsigned.pkg outputs
6969
mv bin/${{ env.BUILD_CONFIGURATION }}/bundle/container-dSYM.zip outputs
7070
71-
- name: Start OS log collection
71+
- name: Test the container project
7272
run: |
73+
# Start OS log collection in background
7374
log stream --debug --info --predicate 'subsystem == "com.apple.container" or subsystem == "com.apple.NetworkSharing" or process == "com.apple.Virtualization.VirtualMachine"' > container-test.log 2>&1 &
74-
echo $! > log_stream_pid.txt
75-
echo "Started log collection with PID $(cat log_stream_pid.txt)"
75+
LOG_PID=$!
76+
echo "Started log collection with PID ${LOG_PID}"
77+
78+
# Ensure log collection is stopped on exit
79+
trap "kill ${LOG_PID} 2>/dev/null || true; echo 'Stopped log collection'" EXIT
7680
77-
- name: Test the container project
78-
run: |
7981
APP_ROOT=$(mktemp -d -p "${RUNNER_TEMP}")
80-
trap 'rm -rf "${APP_ROOT}"; echo Removing data directory ${APP_ROOT}' EXIT
82+
trap 'kill '"${LOG_PID}"' 2>/dev/null || true; rm -rf "${APP_ROOT}"; echo Removing data directory ${APP_ROOT}' EXIT
8183
echo "created data directory: ${APP_ROOT}"
8284
echo "hostname: $(hostname)"
8385
export NO_PROXY="${NO_PROXY},192.168.0.0/16,fe80::/10"
@@ -88,16 +90,6 @@ jobs:
8890
env:
8991
DEVELOPER_DIR: "/Applications/Xcode-latest.app/Contents/Developer"
9092

91-
- name: Stop OS log collection
92-
if: always()
93-
run: |
94-
if [ -f log_stream_pid.txt ]; then
95-
LOG_PID=$(cat log_stream_pid.txt)
96-
echo "Stopping log collection (PID: ${LOG_PID})"
97-
kill ${LOG_PID} || true
98-
rm log_stream_pid.txt
99-
fi
100-
10193
- name: Upload OS logs on failure
10294
if: failure()
10395
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6

0 commit comments

Comments
 (0)