tmforum-oda / oda-canvas

Apache License 2.0
19 stars 52 forks source link

Support unit tests in automated docker builds #338

Closed ferenc-hechler closed 1 month ago

ferenc-hechler commented 1 month ago

Description

The automated docker build process should be improved, so that unit tests can be executed as part of the build. Only for successful tests the docker image should be pushed to the repository.

ferenc-hechler commented 1 month ago

The Service-Inventroy-Client used in the #289 contains unit tests. Those are executed in an own docker image built from DockerfileTest. The report is stored in junit xml format. The report is published using the action-junit-report GitHub action: https://github.com/tmforum-oda/oda-canvas/actions/runs/10893394963

image

ferenc-hechler commented 1 month ago

Documentation How-To work with Dockerimages has to be updated.

ferenc-hechler commented 1 month ago

Resource for testing before pushing: https://docs.docker.com/build/ci/github-actions/test-before-push/

ferenc-hechler commented 1 month ago

Resource for testing before pushing: https://docs.docker.com/build/ci/github-actions/test-before-push/

There is an issue with this. When using buildx, the locally exportet image is not used in the FROM of DockerfileTest, instead of the latest pushed image is used, which leads to failing tests.

Details can be found here: https://github.com/docker/build-push-action/issues/1015

I solved this by pushing the :latest image, but not the version in the first build and then run the tests. the scond build (with arm64) uses the already cached amd64 build.