{"id":16679810,"url":"https://github.com/tsloughter/docker_compose_cth","last_synced_at":"2025-04-09T22:33:40.851Z","repository":{"id":40387582,"uuid":"204227701","full_name":"tsloughter/docker_compose_cth","owner":"tsloughter","description":"Erlang Common Test Hook for starting docker-compose services before running test suites","archived":false,"fork":false,"pushed_at":"2022-05-11T11:37:31.000Z","size":14,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-01T19:08:47.970Z","etag":null,"topics":["common-test","docker","docker-compose","erlang","erlang-common-test"],"latest_commit_sha":null,"homepage":null,"language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tsloughter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-25T00:32:05.000Z","updated_at":"2024-05-04T21:49:47.000Z","dependencies_parsed_at":"2022-08-09T19:01:02.604Z","dependency_job_id":null,"html_url":"https://github.com/tsloughter/docker_compose_cth","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsloughter%2Fdocker_compose_cth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsloughter%2Fdocker_compose_cth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsloughter%2Fdocker_compose_cth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsloughter%2Fdocker_compose_cth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsloughter","download_url":"https://codeload.github.com/tsloughter/docker_compose_cth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248124002,"owners_count":21051575,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["common-test","docker","docker-compose","erlang","erlang-common-test"],"created_at":"2024-10-12T13:37:38.370Z","updated_at":"2025-04-09T22:33:40.828Z","avatar_url":"https://github.com/tsloughter.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"Common Test Docker Compose Hook\n=====\n\nA [Common Test](http://erlang.org/doc/apps/common_test/) hook for starting and stopping [docker-compose](https://docs.docker.com/compose/) services.\n\nTo use this hook simply place a `docker-compose.yml` file in the [suite's `data_dir`](http://erlang.org/doc/apps/common_test/write_test_chapter.html#data-and-private-directories), the top level of the project or declare the path explicitly with `docker_compose_file` -- see the configuration section below for more on how the compose file is found.\n\nThen hooks must be declared in the `ct_opts`, the config returned by a function in the test suite or in a [test spec](http://erlang.org/doc/apps/common_test/run_test_chapter.html#test_specifications). Some examples of enabling the hook are in the next section.\n\nShutdown of the services happens in the hook's `terminate` function which is called depending on when the hook was installed: [CTH Scope](http://erlang.org/doc/apps/common_test/ct_hooks_chapter.html#cth-scope). But the configuration for the hook can include `#{stop =\u003e never}` and the hook will not shutdown the services during `terminate`.\n\n## Examples\n\nFirst, the hook must be included as a dependency of the rebar3 project. Since the hook is only used by Common Test it can be put in the `test` profile:\n\n``` erlang\n{profiles, [{test, [{deps, [docker_compose_cth]}]}]}.\n```\n\nHooks can be declared in `rebar.config` with `ct_opts`:\n\n``` erlang\n{ct_opts, [{ct_hooks, [docker_compose_cth]}]}.\n```\n\nIt can be added on a per-suite either with the `suite/0` function in the suite module:\n\n``` erlang\nsuite() -\u003e\n    [{ct_hooks, [docker_compose_cth]}].\n```\n\nor in the return of `init_per_suite/1`:\n\n``` erlang\ninit_per_suite(Config) -\u003e\n    [{ct_hooks, [docker_compose_cth]} | Config].\n```\n\nFor groups it can be added per-group in the return of `init_per_group/2` function in the suite module:\n\n``` erlang\ninit_per_group(Group, Config) -\u003e\n    [{ct_hooks, [docker_compose_cth]} | Config].\n```\n\n## Configuration\n\n* `docker_compose_file`: The path to a `docker-compose.yml` file to use. If it isn't an absolute path then it is relative to what will be the current working directory during the test run which is `_build/test/logs/ct_run.\u003cnode\u003e.\u003ctimestamp\u003e`. If no path is given then the hook first checks the suite's `data_dir`, see `test/post_group_SUITE_data/docker-compose.yml` as an example. If no compose file is found in the suite's `data_dir` it will pass no `-f ...` argument to `docker-compose`, this results in `docker-compose` searching up the directory tree (starting at the cwd which in this case is that `ct_run.\u003cnode\u003e.\u003ctimestamp\u003e` directory mentioned above) until it finds a compile file.\n* `executable_search_paths`: Path to search for the `docker-compose` executable. If it is not set the regular path is searched as described in the [docs for os:find_executable/1](http://erlang.org/doc/man/os.html#find_executable-1).\n* `check_if_running`: A string that is the name of the service to check for before running `docker-compose up`. If defined the hook will check if a service is already up and not call `docker-compose up` if it is. By default this is done by attempting `exec ls` in the service's container, but the command can be set to anything by passing a tuple `{Service, Command}`\n* `skip_or_fail`: The atom `skip` or `fail` (default is `fail`). If the hook is unable to bring up the service with docker-compose then the suite will either skip or fail, depending on this configuration.\n* `stop`: Boolean value that if `false` means the services with not be shutdown when the hook terminates.\n* `remove_volumes`: Boolean value. If `true`, the flag `-v` will be passed to `docker-compose down` which deletes volumes not specifically defined as `external` in the compose file.\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsloughter%2Fdocker_compose_cth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsloughter%2Fdocker_compose_cth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsloughter%2Fdocker_compose_cth/lists"}