AkrosAG / Akros-Marketplace

Apache License 2.0
3 stars 5 forks source link

Use Github Actions Cache to make workflows faster #124

Open stefanleminh opened 2 years ago

stefanleminh commented 2 years ago

Currently neither Docker-Containers, no mvn or npm dependencies get cached. This results in relatively long build-times in Github Actions, especially with Cypress building the entire docker-compose infrastructure and the UI building the UI and the webcomponents.

Fortunately, Github Actions provide a way to cache these artifacts. This should be implemented in this ticket.

ghost commented 2 years ago

We might not need additional caching libraries for this - because we have a multistage building process for the docker images we may use the caching functionality of Docker itself, to skip the steps of downloading the dependencies each time we execute a build, by simply modifying the Dockerfiles.

A reference for maven: https://www.baeldung.com/ops/docker-cache-maven-dependencies

ghost commented 2 years ago

Quick note - although the solution works locally, because of the caching of the locally ran instance of Docker, it doesn't for github. Most probably they don't leave any dangling artefacts after completion of each build so they could save space(or creating a temporary vm for the build only, which is destroyed after completion). Carrying on with trying the original idea of using caching of artifacts from Stefan.

ghost commented 2 years ago

Adding changes with caching of Docker layers on github actions + local caching. Some results:

Cypress Worst case scenario(changes in poms for marketplace service, admin-ui and authentication service) - 9:43 Non-dependency changes for marketplace service, admin-ui and authentication service + cache - 8:50 - Times are actually most dependent on admin-ui. There Vaadin library is at fault, because it needs the compiled java project to decide which dependencies to download No changes for marketplace service, admin-ui or authentication service + cache - 5:50

Frontend + deploy: Worst-case scenario(changes to package.json of main project or any webcomponent + deployment) - 10:00 Non dependency changes + cache - 8:20

Marketplace service + deploy: Worse case scenario(changes in pom.xml + deployment) - 4:47 Non dependency changes + cache - 2:00

Quick notes for Github caching as of time of writing:

Some links for future docs when wiki is up:

fingeririna commented 2 years ago

Dokumentation in wiki will be done as soon as wiki is available.

ghost commented 2 years ago

Link to technical document on akros wiki: https://wiki.akros.ch/display/TO/Docker+layers+and+Github+Actions+caching