From 7f78b006dd2d62afb78ea960661588ff54d5893f Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 30 Jul 2024 23:10:14 +0100 Subject: [PATCH] Add daily email for 2024-07-29 Don't run code formatting in your CI pipeline --- source/_daily_emails/2024-07-29.md | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 source/_daily_emails/2024-07-29.md diff --git a/source/_daily_emails/2024-07-29.md b/source/_daily_emails/2024-07-29.md new file mode 100644 index 000000000..53692518a --- /dev/null +++ b/source/_daily_emails/2024-07-29.md @@ -0,0 +1,37 @@ +--- +title: Don't run code formatting in your CI pipeline +date: 2024-07-29 +permalink: daily/2024/07/29/dont-run-code-formatting-in-your-ci-pipeline +tags: + - software-development + - continuous-integration + - pipelines + - git +cta: ~ +snippet: | + Why I don't run code formatting tools in my CI pipelines. +--- + +Something I commonly used to see, and did myself, was running code formatting tools, such as PHP CS Fixer or prettier, automatically their CI pipeline. + +And not using it as a check to fail the pipeline if your code isn't formatted correctly. + +Running it, fixing any code and committing any updates. + +It wasn't long before I stopped doing this. + +Firstly, I wasn't comfortable with a CI pipeline have write access to my codebase. It's fine to be able to clone it and run checks against it, but making changes to my code and pushing it makes me nervous. + +Particularly if you're doing trunk-based development and everyone works on the same branch. + +This also causes additional upstream commits, because the pipeline has committed a change. If you don't remember to pull those commits, you can [end up in a tricky situation][0]. + +I'm also not a fan of having a lot of `php-cs-fixer fixes` or `prettier fixes` commits. I'd prefer the commits be correct when they're pushed, if possible, which is why I usually do micro commits locally and tidy things before pushing them. + +If you're working on a topic branch and creating a pull or merge request, you can squash commits when merging, but [I'm not a fan of squashing commits][1], either. + +Instead of relying on a CI pipeline to run code formatting, [make it easy to run those tasks locally][2]. + +[0]: {{site.url}}/daily/2024/07/25/only-have-one-url-per-git-remote +[1]: {{site.url}}/daily/2024/05/11/don-t-delete-my-commit-messages +[2]: {{site.url}}/daily/2022/08/15/using-run-file-simplify-project-tasks