Fix extract_coverage log timestamp handling
What does this MR do and why?
When FF_TIMESTAMPS
feature flag is enabled, Runner logs have timestamps.
This MR fixes the code coverage extraction regex, which is now matched against log lines with the timestamps stripped.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Run the following jobs:
image: alpine:latest
exchange-coverage-without-timestamps:
variables:
FF_TIMESTAMPS: "false"
script:
- 'echo "Code coverage: 67.89% of lines covered"'
coverage: '/^Code coverage: \d+(?:\.\d+)?/'
exchange-coverage-with-timestamps:
variables:
FF_TIMESTAMPS: "true"
script:
- 'echo "Code coverage: 67.89% of lines covered"'
coverage: '/^Code coverage: \d+(?:\.\d+)?/'
exchange-coverage-without-timestamps-edge-case:
variables:
FF_TIMESTAMPS: "false"
script:
- "echo \"echo -n \"prefix\r\"\" >> script"
- "echo 'sleep 2' >> script"
- "echo 'echo \"Code coverage: 67.89% of lines covered\"' >> script"
- sh ./script
coverage: '/^Code coverage: \d+(?:\.\d+)?/'
exchange-coverage-with-timestamps-edge-case:
variables:
FF_TIMESTAMPS: "true"
script:
- "echo \"echo -n \"prefix\r\"\" >> script"
- "echo 'sleep 2' >> script"
- "echo 'echo \"Code coverage: 67.89% of lines covered\"' >> script"
- sh ./script
coverage: '/^Code coverage: \d+(?:\.\d+)?/'
Before MR:
-
exchange-coverage-without-timestamps
✅ -
exchange-coverage-with-timestamps
❌ -
exchange-coverage-without-timestamps-edge-case
❌ -
exchange-coverage-with-timestamps-edge-case
❌
After MR:
-
exchange-coverage-without-timestamps
✅ -
exchange-coverage-with-timestamps
✅ -
exchange-coverage-without-timestamps-edge-case
❌ -
exchange-coverage-with-timestamps-edge-case
✅
edge-case
refers to the use of \r
, where when timestamps are enabled, the coverage would get "flushed" with a new-line. Visually in the log renderer, this always appears to be the case. It also means that existing regex for coverage that tries to match on \r
would likely break, however, it's probably very unlikely anybody has this. If they did, the fix would be to update the regex pattern slightly.
Related to #470131