How to make sure a Dynamo Graph can run in different version of Revit?

Not really - as Python, Dynamo, Revit, .NET and even Windows updates over time you need to build to that environment.

You can make it easier on yourself though. First set up your environments for each release you plan on supporting. Graphs don’t support ‘one package version’ across all environments in general, but you need the ‘right package version’ for your environment. That is a different Revit build will require a different Archi-Lab version, so set those up first.

Next develop to the oldest environment you want to support, test that, then do a save as to the deployment folder for users in that environment. Then copy the deployed version to a new folder and text the next environment. When it works save it to the deployment folder, and continue to repeat the process until all builds are done and move onto the next graph you want to develop.

Then every time you get a ‘new environment’ (i.e. a new Revit version is released) you copy the most similar environment to the new build’s testing directory, and do the test/deploy.

All of this testing can be difficult, but it is the only way to validate things. You can certainly speed some stuff up using playable journals. Towards that end I have a collection of Dynamo graphs to put properties into your graphs and build playable journals posted here which can help in the larger development process.