From e99d221fb0562d8ab2e70b44ee32d9f3bfb3284f Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Sun, 8 Dec 2019 01:20:21 -0600 Subject: [PATCH] finish basic development environment There's still a bug or two to fix, I suspect, but this should mostly work! --- Makefile | 36 +++++++++++++++++++----- README.md | 68 ++++++++++++++++++++++++++++++++++++++++------ docker-compose.yml | 13 +++++++++ 3 files changed, 101 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index e290710..e716fbc 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ SRC_DIR = src REPOS = cpantesters-schema cpantesters-backend cpantesters-web cpantesters-api .PHONY: src docker docker-base docker-schema docker-backend docker-web docker-api \ - start stop + start stop compose connect data restart src: for REPO in $(REPOS); do \ @@ -13,40 +13,62 @@ src: docker-base: @echo "Building base image as cpantesters/base..." - @docker build . --tag cpantesters/base >build-base.log + @docker build . --tag cpantesters/base >build-base.log \ + || echo "ERR: Build failed. See build-base.log"; docker-schema: docker-base @BUILD="schema"; \ REPO="cpantesters-$$BUILD"; \ TAG="cpantesters/$$BUILD"; \ echo "Building repo $$REPO as $$TAG..."; \ - docker build $(SRC_DIR)/$$REPO --tag $$TAG >build-$$BUILD.log; + docker build $(SRC_DIR)/$$REPO --tag $$TAG >build-$$BUILD.log \ + || echo "ERR: Build failed. See build-$$BUILD.log"; docker-backend: docker-base docker-schema @BUILD="backend"; \ REPO="cpantesters-$$BUILD"; \ TAG="cpantesters/$$BUILD"; \ echo "Building repo $$REPO as $$TAG..."; \ - docker build $(SRC_DIR)/$$REPO --tag $$TAG >build-$$BUILD.log; + docker build $(SRC_DIR)/$$REPO --tag $$TAG >build-$$BUILD.log \ + || echo "ERR: Build failed. See build-$$BUILD.log"; docker-web: docker-base docker-schema @BUILD="web"; \ REPO="cpantesters-$$BUILD"; \ TAG="cpantesters/$$BUILD"; \ echo "Building repo $$REPO as $$TAG..."; \ - docker build $(SRC_DIR)/$$REPO --tag $$TAG >build-$$BUILD.log; + docker build $(SRC_DIR)/$$REPO --tag $$TAG >build-$$BUILD.log \ + || echo "ERR: Build failed. See build-$$BUILD.log"; docker-api: docker-base docker-schema @BUILD="api"; \ REPO="cpantesters-$$BUILD"; \ TAG="cpantesters/$$BUILD"; \ echo "Building repo $$REPO as $$TAG..."; \ - docker build $(SRC_DIR)/$$REPO --tag $$TAG >build-$$BUILD.log; + docker build $(SRC_DIR)/$$REPO --tag $$TAG >build-$$BUILD.log \ + || echo "ERR: Build failed. See build-$$BUILD.log"; docker: docker-backend docker-web docker-api +compose: docker + @echo 'Refreshing docker-compose services' + @docker-compose build + @docker-compose up --no-start + start: - @docker-compose up + @docker-compose start stop: @docker-compose stop + +restart: + @docker-compose stop + @docker-compose start + +connect: + @docker-compose exec db_tester mysql cpantesters + +data: + @echo "Fetching data for $(DIST)" + @docker-compose run deploy cpantesters-schema fetch --dist $(DIST) report release + diff --git a/README.md b/README.md index 277cee8..5339304 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Testers repositories into the `src/` directory. ### Build Docker Containers -To build the initial Docker containers, use `make docker`. This will +To build the initial Docker containers, use `make compose`. This will build: 1. `cpantesters/base` - The base CPAN Testers container @@ -33,11 +33,12 @@ build: 3. `cpantesters/backend` - The backend, which runs Minion workers 4. `cpantesters/api` - The API web application 5. `cpantesters/web` - The new web application +6. The docker-compose utility container instances Each build will write a log to `build-*.log` to inspect for issues. Docker itself is smart about not rebuilding things it does not need to, -so `make docker` will be as fast as it can be. However, if you want to +so `make compose` will be as fast as it can be. However, if you want to only build a certain container, you can use the following `make` targets: @@ -58,30 +59,79 @@ Once the cluster starts, you can test the web apps with these URLs: * - The main web app * - The API web app +* - The legacy metabase web app + +To view the logs from the docker containers, use `docker-compose logs`. +The `-f` flag will follow the logs like `tail -f`. ### Populate Test Data -XXX +To add some data to your development instance, run `make data` and +specify a distribution (with an optional version), like so: + + make data DIST=Mojolicious@8.27 + +This will download all the data from the primary CPAN Testers database +and load it into your dev site. + +### Make Changes + +Make changes to the code in the `src/` directory. When you're done, use +`make compose` to rebuild the images and `make restart` to restart the +containers. -### Hack! +#### Connect to the Tester database -Here are some possible ways to test changes to parts of the code: +To connect to the running tester database, use `make connect`. #### Backend processing of incoming test reports Once a report is in the database, it must be processed. Any report in the database can be reprocessed any number of times. -XXX +To re-process an existing test report, run the `beam run report process` +command inside the `backend` container: + + docker-compose exec backend -- beam run report process dc9c7be4-1985-11ea-9825-b8cf277f9bb7 + +To send a request to re-process the report to the Minion job queue, use +`beam run report queue`: + + docker-compose exec backend -- beam run report queue dc9c7be4-1985-11ea-9825-b8cf277f9bb7 + +To see all the available backend commands: + + docker-compose exec backend -- beam list #### Test reporting clients -XXX - This requires another Docker node for the legacy metabase process +To submit reports to your dev instance, install and configure +[CPAN::Reporter](http://metacpan.org/pod/CPAN::Reporter). + + # Enter the cpan shell using the `cpan` command + cpan> install Task::CPAN::Reporter + cpan> reload cpan + cpan> o conf init test_report + +When asked about the `transport?` value, use the value below + + Metabase uri http://localhost:5000/api/v1/ id_file metabase_id.json + +This config file is also used by CPANPLUS and App-cpanminus-reporter. + +*NOTE:* CPAN::Reporter tries to stop you from sending duplicate reports +by keeping track of the reports you've sent. If you get this message, +you should clear the cache in `~/.cpanreporter/reports-sent.db`. + + CPAN::Reporter: this appears to be a duplicate report for the test phase: + PASS Mojolicious-8.27 darwin-2level 18.0.0 + + Test report will not be sent. #### Web applications -This one's pretty easy: Just make your change in the `src/` project -directory and rebuild. Your changed files will be added to the Docker +Make your change in the `src/` project directory, rebuild and restart +(`make compose restart`). Your changed files will be added to the Docker containers and ready to run! Note: Only files added to the Git repo will be installed into the Docker containers. diff --git a/docker-compose.yml b/docker-compose.yml index 3049222..20852fe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,6 +34,19 @@ services: OAUTH2_GITHUB_SECRET: f368e10f53b0587a0e6753a187a537009113d522 ports: - '3000:3000' + backend: + image: cpantesters/backend + depends_on: + - db_tester + legacy_metabase: + image: cpantesters/api + depends_on: + - db_tester + ports: + - '5000:4000' + environment: + MOJO_CONFIG: ./metabase.conf + command: [ 'cpantesters-legacy-metabase', 'daemon', '-l', 'http://*:4000' ] deploy: build: context: .