Skip to content

Commit

Permalink
finish basic development environment
Browse files Browse the repository at this point in the history
There's still a bug or two to fix, I suspect, but this should mostly
work!
  • Loading branch information
preaction committed Dec 8, 2019
1 parent 5a9da9d commit e99d221
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 16 deletions.
36 changes: 29 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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

68 changes: 59 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ 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
2. `cpantesters/schema` - Container with the CPAN Testers schema
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:

Expand All @@ -58,30 +59,79 @@ Once the cluster starts, you can test the web apps with these URLs:

* <http://localhost:3000> - The main web app
* <http://localhost:4000> - The API web app
* <http://localhost:5000> - 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 [email protected]

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.

Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .
Expand Down

0 comments on commit e99d221

Please sign in to comment.