Oscar Piastri will leave Alpine for McLaren at the end of the current season, replacing Daniel Ricciardo.