Skip to content

Commit

Permalink
feat(tests): better cleanup on docker tests (railwayapp#1127)
Browse files Browse the repository at this point in the history
* feat(tests): better cleanup on docker tests

The `docker_run_tests`, tests, do not properly cleanup after itself. The
changes made are as follows:

Remove [anonymous
volumes](https://docs.docker.com/reference/cli/docker/container/rm/#volumes):
    - add `-v` to `docker rm`

Remove generated image:
    - call `docker rmi` after containers all stopped and removed

Remove all containers related to an image and not just the most recent
one

Cleanup images that complete quickly:
    - call `stop_and_remove_container_by_image` on all images, not just
      ones that hang

Convert fake async function to normal function:
    - `get_container_ids_from_image` never awaits anything. It was not a
      real async function. As such, the async syntax was removed for it

* feat(test): gracefully cleanup failed docker build

Some docker `simple_build` (or `build_with_build_time_env_vars`) create
additional resources as part of their process. This is for the dbs, they
create a volume and a network. But if the build itself fails, the
created resources never reach the cleanup logic. This commit defers the
unwrapping of the build results, to the caller; allowing us to inject
cleanup logic where needed

* chore: provide correct clippy command
  • Loading branch information
CoderJoshDK authored Jul 16, 2024
1 parent 6867144 commit de0a093
Show file tree
Hide file tree
Showing 2 changed files with 204 additions and 120 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ PRs are all checked with

- `cargo check`
- `cargo test`
- `cargo clippy`
- `cargo clippy --all-targets --all-features -- -D warnings`

so you can run these locally to ensure CI passes.

Expand Down
Loading

0 comments on commit de0a093

Please sign in to comment.