medic / cht-core

The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.
https://communityhealthtoolkit.org
GNU Affero General Public License v3.0
469 stars 217 forks source link

`default-docs` build cache not cleared when running `build-dev` - causes zombie forms šŸ§Ÿ #9624

Closed jkuester closed 1 week ago

jkuester commented 2 weeks ago

Describe the issue

The npm build-dev script calls the build-prepare script which calls the build-config script. That script uses cht-conf to "archive" the forms from config/default into the api/build/default-docs directory. Those archived forms are then included with the api server when it is packaged in a docker container.

All of this works fine for a one-off build on CI. However, things can get weird when developing locally. If you happen to have a custom form in config/default when you run build-dev that form will be included in api/build/default-docs (as expected). The problem is that when you remove that form from config/default and re-run build-dev, the archived version of the custom form does not get removed from api/build/default-docs. Instead it just lives on in there forever. šŸ§Ÿ

The main issue this can cause is that this cache is what gets used when building local CHT docker images for the e2e tests. So, it is possible for custom forms to end up in an e2e test run (even when they no longer exist in config/default). This could cause tests to behave differently when run locally vs on CI...

Describe the improvement you'd like

Perhaps we can start the build-dev command by just removing the whole api/build directory. I believe it all gets re-built by the rest of the command and this way we can ensure that everything is fresh.

Describe alternatives you've considered

We can leave things like they are and 2 years from now when I have forgotten this, I will waste another 2hrs thinking I am going completely insane.... šŸ¤¦