Handling Distribution Shifts on Graphs: An Invariance Perspective