I have successfully configured my CodeBuild CI project to source from GitHub using webhooks, and I've recently introduced automated tests with S3 caching into my workflow. However, this has led to a significant increase in build times, especially when multiple commits are pushed in quick succession to a pull request. With the current setup, CodeBuild triggers separate builds for each commit (e.g. for 10 commits it will trigger 10 different builds).
While this wasn't much of a problem when build durations were 3 minutes~ long, now that it takes about 15 minutes to complete a single build, it causes significant overhead.
I tried reducing concurrent builds to 1 but it's not a viable solution as it ignores the latest commits while processing only the first one.
How can I optimize my workflow to avoid this excessive overhead?