A contractor shall not discriminate in the employment of persons upon public works on any basis listed in subdivision (a) of Section 12940 of the Government Code, as those bases are defined in Sections 12926 and 12926.1 of the Government Code, except as otherwise provided in Section 12940 of the Government Code. Every contractor for public works who violates this section is subject to all the penalties imposed for a violation of this chapter.