I will present a study of the proportion of star-forming galaxies at z=0 to 0.8 as a function of galaxy environment. This work is based on 16 clusters, 10 groups and another 250 galaxies in poorer groups and the field at z=0.4-0.8 from the ESO Distant Cluster Survey, and the Sloan Digital Sky Survey as a local comparison. Our high-z observations show that at z=0.4-0.8 the mass of the system seems to largely determine the proportion of galaxies with ongoing star formation. The evolution of the relation between the star-forming fraction and the system velocity dispersion suggests how galaxy star formation histories may be closely related to the growth history of clusters and groups. I will discuss the implications of these results for a possible evolutionary scenario linking galaxy properties and environment.