Gmail ignoring SPF record

Solution 1:

The behavior on SPF mismatch is entirely up to the receiving end, and considering how frequently SPF is configured incorrectly (or out of date) a lot of providers won't reject based on a mismatch (even with -all instead of ~all). It is common to see the spam score bumped because of a mismatch, and maybe even a match receiving a spam score decrease, but even these aren't always the case either. While the behavior of the receiving end may not always be reliable, it's definitely worth having there in case the receiving end does respect SPF in some way.

Solution 2:

To the original question: Gmail is DMARC compliant, and so if you want to enforce policy, you should publish a DMARC record with p=reject or p=quarantine and Gmail will then apply your policy when SPF and DKIM fail.