alphagov / notifications-manuals

Documentations for Notify
9 stars 4 forks source link

Running tests / flask / celery is inconsistent between repos #9

Closed benthorner closed 3 years ago

benthorner commented 3 years ago

Problem

Each repo has a different set of often overlapping ways to run its code, only some of which are documented in its README.

Having multiple ways to do the same thing is confusing for new starters, and an unnecessary maintenance overhead. Some observations about the way these are used in practice:

Aside from running code, there is a similarly spectrum of how to setup each app: ./scripts/bootstrap.sh, make build, and manual commands, all of which differ depending on the repo, and in CI.

Proposal

We should change all READMEs to refer to a single, standard way of running code (tests / flask / celery). This should be make because it's a standard automation tool, and because it supports a variety of other tasks.

We should remove *-with-docker tasks from all Makefiles unless they are necessary due to dependency issues. This is because using Docker is slower and more abstract than running native code.

We should switch CI to use make test instead of ./scripts/run_tests.sh (or manual commands). This is because the way we build a project locally should match the way CI does it, to avoid unnecessary surprises.

[Stretch] We should investigate moving ./scripts/* into the Makefile where practical (example of practical), so that these are more clearly defined as providing some kind of complex functionality.

[Stretch] We should investigate moving ./scripts/bootstrap.sh into the Makefile, as a standard make bootstrap task. This is for consistency with the way we (now) recommend running code.

Roadmap

This will take some time to implement, as it affects all repos and there will doubtless be subtleties not captured here. We should aim to apply the change incrementally. I'd suggest dividing the work into stages:

  1. Do as much as we can without affecting CI. This includes: updating the repo README, removing redundant *-with-docker tasks, moving some ./scripts/* into Makefile (except./scripts/run_tests.sh`, which will still be used by CI).

  2. Update CI to use the Makefile for running tests, and potentially bootstrapping.

1. Do as much as we can without affecting CI

2 Update CI to use the Makefile for running tests

3 Ideas for follow-up issues

quis commented 3 years ago

When I worked on migrating the admin app to use piptools in the Christmas lull one of the things I wanted to do but didn’t (for the sake of keeping a small diff) was:

[tidy] up some of our bash scripts which would be better in the Makefile

So I’d support this proposal.

leohemsted commented 3 years ago

seems good and I'm in favour, only thing I have to note is that the -with-docker commands aren't just for antivirus/template-preview - they're also useful for all our client libraries so we dont need to install ruby, node, dot net, java etc to run integration or unit tests.

idavidmcdonald commented 3 years ago

Thanks Ben. I support your proposals.

Some things to look into when we do them:

Seems like Leo, Chris and I generally support this so unless we hear any objections I think we can assume consensus. Feel free to do this stuff Ben, whether that be now or in 3 weeks time or just sporadically whenever you have a free 5 minutes. It doesn't just have to be you either, all devs should be making these little changes when they have a spare 5 minutes.

klssmith commented 3 years ago

Making things consistent sounds good to me.

In notifications-antivirus I always forget which of the commands (make run-app-with-docker and make run-with-docker) is for the Flask app and which is for the Celery app, so it would be useful to have a general pattern we follow.

benthorner commented 3 years ago

Thanks for the comments so far everyone! I'll try and briefly summarise where we are:

I've also appended a rough "roadmap" section to the description, based on @idavidmcdonald's comment - part of the reason for writing this up was realising it might take some time / thought.

leohemsted commented 3 years ago

agreed around the celery vs flask naming conventions being lacking.

think i'd quite like run-celery-with-docker and run-web-with-docker just to be super explicit and unambiguous.

benthorner commented 3 years ago

That makes sense, although I'm not fussed either way myself: as long as it's consistent I think people can get used to it. This would also apply to non-Docker rules i.e. run-celery and run-web (maybe run-flask is clearer?).

Does anyone else have opinions here? Otherwise, we could just go with this.

CrystalPea commented 3 years ago

I think either run-celery and run-flask, or run-async and run-web, as in, it would be nice to have consistent names either after frameworks we use or after functions they perform.

benthorner commented 3 years ago

Closing as all tasks are completed following the merge of https://github.com/alphagov/notifications-python-client/pull/202.* πŸŽ‰ πŸŽ‰ πŸŽ‰

I think it's worth recapping what the work on this issue has achieved:

I applied many of these changes myself and it's been a learning experience πŸ€“. Although we had to change direction one or two times, I've already benefited from the changes and have had some feedback saying the same ✊. As the newest dev on Notify, I also believe these changes will make the future setup experience significantly simpler βœ…. Thanks to everyone who took time to review the many PRs along the way πŸ™.

*There is one repo - notifications-certificate-management - that was missed in the original scope and is still inconsistent with all other repos. I think enough work has been done against this issue that it's still reasonable to close it. Since the repo is specific to emergency alerts and quite separate to all the other Notify codebases, it's unlikely anyone new will encounter it - so far existing team members rarely work on it.