I've been struggling with long CI/CD waits in my workflow. After pushing a commit, I often find myself waiting up to 8 minutes for the pipeline to finish, only to be met with failures caused by flaky tests or simple YAML indentation errors. This can turn into a frustrating cycle of fixing and pushing multiple times just to get it right, which wastes a lot of time and causes me to lose focus on my tasks.
To combat this, I've started running CI checks locally before committing, which has helped catch most of the issues early. I've also been experimenting with a tool that simulates the CI pipeline locally, providing real-time feedback instead of waiting for the full process to complete. I'm curious if anyone else has developed strategies or tools to mitigate these CI/CD delays, or if it's just something we all have to endure as part of the job.
4 Answers
One effective approach is to run all your checks locally before committing. This way, you catch issues early on, and your CI process becomes less of a bottleneck. You can set up pre-commit hooks for linting and basic tests that only take a few seconds to run.
Pre-commit hooks can be a lifesaver! They can handle linting and run basic unit tests very quickly, which helps ensure you're not pushing unnecessary errors into CI. I recommend using `prek`, which is a fast alternative to the usual `pre-commit` framework and can speed up your check process significantly.
Keep in mind that flaky tests can be a major issue. It's best to fix them quickly or exclude them from your CI runs. If something's consistently causing failures, it's worth re-evaluating those tests to ensure reliability. A well-structured pipeline generally shouldn't take longer than 10 minutes.
Make sure your local development environment mirrors the CI environment as closely as possible. If you can run a mock API or have access to the same databases locally, it'll speed up your development process significantly. This means you can test things out before pushing to the CI.

That sounds interesting! But how do you handle really slow tools like golangci-lint that take ages to run?