I answered this question for Classical Greece here. The short version is that while there were laws against desertion and even cowardice, these were practically never enforced out of fear that the punishment of a large section of the citizen body would cause civic unrest. Units that fled from battle normally faced no consequences, and only their commanders might find themselves taken to trial.