[ci] Only upload test stats when the test step actually runs (#78960)
If a job fails in an earlier stage or is cancelled, the test step may never run.
In cases like that, don't try to upload test stats.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78960
Approved by: https://github.com/janeyx99, https://github.com/seemethere