Preheat the broiler. Melt the butter in a large ovenproof skillet over medium-high heat. Add the onion, garlic and rosemary and cook, stirring often, until the onion is soft and just starts browning, about 6 minutes.
Sprinkle in the flour and cook, stirring, until smooth and bubbling, about 2 minutes. Stir in 2 cups water, the milk, 1/2 teaspoon salt and a few grinds of pepper. Bring to a boil, then reduce the heat to a gentle simmer. Stir in the ravioli and cook, stirring occasionally, until the ravioli are tender and the sauce thickens, 5 to 7 minutes.
Remove from the heat. Discard the rosemary sprigs and stir in the spinach. Sprinkle with the mozzarella and grana padano. Place the skillet under the broiler until golden and bubbling, about 5 minutes.