diff --git a/Makefile b/Makefile index bd725abb..59addb70 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,11 @@ SHELL := /bin/bash DOCKER := $(shell which docker) DOCKER_COMPOSE := $(shell which docker-compose) +ifeq ($(STANDALONE), 1) + BASE_COMMAND := docker-compose run lando +else + BASE_COMMAND := docker exec -ti suite-lando-1 +endif .PHONY: help help: @@ -11,38 +16,27 @@ help: @echo @echo "target is one of:" @echo " help show this message and exit" - @echo " build build the docker image for lando" @echo " format run ruff and black on source code" @echo " test run the test suite" @echo " migrations generates migration files to reflect model changes in the database" - @echo " start run the application" - @echo " stop stop the application" @echo " attach attach for debugging (ctrl-p ctrl-q to detach)" .PHONY: test test: - docker-compose run lando lando tests + $(BASE_COMMAND) lando tests .PHONY: format format: - docker-compose run lando lando format - -.PHONY: build -build: - docker-compose build + $(BASE_COMMAND) lando format .PHONY: migrations migrations: - docker-compose run lando lando makemigrations - -.PHONY: start -start: - docker-compose up -d - -.PHONY: stop -stop: - docker-compose down + $(BASE_COMMAND) lando makemigrations .PHONY: attach attach: +ifeq ($(INSUITE), 1) + -@docker attach suite-lando-1 ||: +else -@docker-compose attach lando ||: +endif diff --git a/README.md b/README.md index 248e80bf..283becfb 100644 --- a/README.md +++ b/README.md @@ -19,15 +19,21 @@ Lando is an application that applies patches and pushes them to Git and Mercuria * docker compose ### Running the development server +It is recommended to use "conduit suite" to interact with Lando on your local machine, however, it can also be run using docker-compose if needed. - make start + docker-compose up The above command will run any database migrations and start the development server and its dependencies. - make stop + docker-compose down The above command will shut down the containers running lando. +## Specifying Suite or Stand-alone +By default, make commands will assume you are running them in suite. This will run the commands in the lando container in the suite. If you want to explicitly run commands on a standalone Lando container (i.e., if you started the container via `docker-compose up` above), then set STANDALONE=1. For example: + + STANDALONE=1 make test + ## Testing To run the test suite, invoke the following command: diff --git a/compose.yaml b/compose.yaml index bdfe23a5..f9868f52 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,4 +1,3 @@ -version: "3.8" services: db: image: postgres diff --git a/src/lando/utils/management/commands/create_environment_repos.py b/src/lando/utils/management/commands/create_environment_repos.py index 2f970996..d397b9e9 100644 --- a/src/lando/utils/management/commands/create_environment_repos.py +++ b/src/lando/utils/management/commands/create_environment_repos.py @@ -294,8 +294,12 @@ def handle(self, *args, **options): try: repo = Repo.objects.create(**definition) except IntegrityError: - self.stderr.write( - f"Repo {definition['name']} already exists, skipping." + self.stdout.write( + self.style.WARNING( + f"Repo {definition['name']} already exists, skipping." + ) ) else: - self.stdout.write(f"Created repo {repo.tree} ({repo.id}).") + self.stdout.write( + self.style.SUCCESS(f"Created repo {repo.tree} ({repo.id}).") + ) diff --git a/src/lando/utils/management/commands/setup_dev.py b/src/lando/utils/management/commands/setup_dev.py index b5a880be..e8a9a6de 100644 --- a/src/lando/utils/management/commands/setup_dev.py +++ b/src/lando/utils/management/commands/setup_dev.py @@ -1,5 +1,6 @@ from django.conf import settings from django.contrib.auth.models import User +from django.core.management import call_command from django.core.management.base import BaseCommand, CommandError from lando.environments import Environment @@ -33,6 +34,12 @@ def setup_workers(self): # Associate all repos with applicable worker. self.stdout.write(f"Adding {repo} ({repo.scm}) to {workers[repo.scm]}.") workers[repo.scm].applicable_repos.add(repo) + self.stdout.write( + self.style.SUCCESS( + 'Workers initialized ("hg" and "git"). ' + "To start one, run `lando start_landing_worker `.", + ) + ) def setup_users(self): """Ensure there is an administrator account on the local system.""" @@ -51,10 +58,20 @@ def setup_users(self): user.is_superuser = True user.is_staff = True user.save() + self.stdout.write( + self.style.SUCCESS( + "Superuser created with the following username and password: " + '"admin", "password".' + ) + ) def handle(self, *args, **options): if settings.ENVIRONMENT != Environment.local: raise CommandError("This script can only be run on a local environment.") + call_command("migrate") + call_command("create_environment_repos", Environment.local.value) self.setup_workers() self.setup_users() - self.stdout.write("Finished.") + self.stdout.write( + self.style.SUCCESS("Finished setting up local Lando environment.") + )