diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1032147704..17a44661f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,20 +38,16 @@ jobs: steps: - name: "Check out repository code" uses: "actions/checkout@v4" + - name: "Setup git credentials" + run: "git config --global user.name 'Infrahub' && \ + git config --global user.email 'infrahub@opsmill.com' && \ + git config --global --add safe.directory '*' && \ + git config --global credential.usehttppath true && \ + git config --global credential.helper /usr/local/bin/infrahub-git-credential" - name: "Setup Python environment" run: "pip install toml invoke" - - name: "Set environment variables" - run: echo INFRAHUB_BUILD_NAME=infrahub-${{ runner.name }} >> $GITHUB_ENV - - name: "Set environment variables" - run: echo INFRAHUB_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }} >> $GITHUB_ENV - - name: "Clear docker environment" - run: docker compose -p $INFRAHUB_BUILD_NAME down -v --remove-orphans --rmi local - - name: "Build Test Image" - run: "invoke dev.build" - - name: "Pull External Docker Images" - run: "invoke dev.pull" - - name: "ls -l /var/run/docker.sock on host machine" - run: "ls -l /var/run/docker.sock" + - name: "Install dependencies" + run: "poetry install --no-interaction --no-ansi" - name: "Integration Tests" run: "invoke backend.test-integration" - name: "Coveralls : Integration Tests" diff --git a/backend/tests/conftest.py b/backend/tests/conftest.py index 5d07ef810f..69245e9cd3 100644 --- a/backend/tests/conftest.py +++ b/backend/tests/conftest.py @@ -142,8 +142,6 @@ async def register_core_models_schema(default_branch: Branch, register_internal_ @pytest.fixture(scope="session") def neo4j(request: pytest.FixtureRequest) -> DockerContainer: - #if not START_DOCKER_DEPENDENCIES: - return container = ( DockerContainer(image="neo4j:5.19.0-enterprise") @@ -167,8 +165,6 @@ def cleanup(): @pytest.fixture(scope="session") def rabbitmq(request: pytest.FixtureRequest) -> DockerContainer: - #if not START_DOCKER_DEPENDENCIES: - return container = ( DockerContainer(image="rabbitmq:latest") @@ -189,8 +185,6 @@ def cleanup(): @pytest.fixture(scope="session") def redis(request: pytest.FixtureRequest) -> DockerContainer: - if not START_DOCKER_DEPENDENCIES: - return container = DockerContainer(image="redis:latest").with_exposed_ports(6379) @@ -212,9 +206,10 @@ def load_settings_before_any_test(worker_id, tmpdir_factory, rabbitmq: DockerContainer, redis: DockerContainer): config.load_and_exit() + print(f"{config.SETTINGS=}") if START_DOCKER_DEPENDENCIES: - # config.SETTINGS.database.port = neo4j.get_exposed_port(7687) + config.SETTINGS.database.port = neo4j.get_exposed_port(7687) config.SETTINGS.broker.port = rabbitmq.get_exposed_port(5672) config.SETTINGS.cache.port = redis.get_exposed_port(6379) @@ -227,14 +222,15 @@ def load_settings_before_any_test(worker_id, tmpdir_factory, except (ValueError, IndexError): db_id = 1 - config.SETTINGS.cache.address = "localhost" if not START_DOCKER_DEPENDENCIES else "172.17.0.1" + config.SETTINGS.cache.address = "localhost" + # if not START_DOCKER_DEPENDENCIES else "172.17.0.1" if config.SETTINGS.cache.driver == config.CacheDriver.NATS: raise ValueError("Just making sure this path is unused during testing phase.") config.SETTINGS.cache.address = f"{BUILD_NAME}-message-queue-{db_id}" - config.SETTINGS.database.address = f"{BUILD_NAME}-database-{db_id}" - config.SETTINGS.broker.address = f"{BUILD_NAME}-message-queue-{db_id}" + config.SETTINGS.database.address = "localhost" + config.SETTINGS.broker.address = f"localhost" config.SETTINGS.storage.local = config.FileSystemStorageSettings(path="/opt/infrahub/storage") else: storage_dir = tmpdir_factory.mktemp("storage") diff --git a/tasks/backend.py b/tasks/backend.py index d9bf5a19fc..53b0a0b6d4 100644 --- a/tasks/backend.py +++ b/tasks/backend.py @@ -132,15 +132,11 @@ def test_core(context: Context, database: str = INFRAHUB_DATABASE): @task(optional=["database"]) def test_integration(context: Context, database: str = INFRAHUB_DATABASE): + # TODO handle database with context.cd(ESCAPED_REPO_PATH): - compose_files_cmd = build_test_compose_files_cmd(database=database) - # Ryuk is a container mainly allowing to clean-up other containers. Not sure why it does not work within CI ("Connection refused"), disabling for now. - base_cmd = f"{get_env_vars(context)} docker compose {compose_files_cmd} -p {BUILD_NAME} run {build_test_envs()} -e TESTCONTAINERS_RYUK_DISABLED=true -v {os.getcwd()}:{os.getcwd()} -w {os.getcwd()} -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker infrahub-test" - exec_cmd = f"pytest -n {NBR_WORKERS} -v --cov=infrahub {MAIN_DIRECTORY}/tests/integration/schema_lifecycle/test_schema_update.py" - if database == "neo4j": - exec_cmd += " --neo4j" - print(f"{base_cmd} {exec_cmd}") - return execute_command(context=context, command=f"{base_cmd} {exec_cmd}") + exec_cmd = f"poetry run pytest -n {NBR_WORKERS} -v --cov=infrahub {MAIN_DIRECTORY}/tests/integration" + print(f"{exec_cmd=}") + return execute_command(context=context, command=f"{exec_cmd}") @task