Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: elifesciences/search
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 362f65c4a2afcfe5370c6bc281d67ca23c9260e6
Choose a base ref
..
head repository: elifesciences/search
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7d948e3e293ae1f746d5c34e018922cc38e08909
Choose a head ref
Showing with 54 additions and 72 deletions.
  1. +0 −3 .github/workflows/ci.yaml
  2. +4 −1 Dockerfile
  3. +42 −26 Makefile
  4. +0 −22 README.md
  5. +1 −1 composer.json
  6. +0 −16 docker-compose.app.yaml
  7. +7 −0 docker-compose.dev.yaml
  8. +0 −3 docker-compose.yaml
3 changes: 0 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -21,9 +21,6 @@ jobs:
- name: Debug bring up test stack
if: failure()
run: docker compose logs
- name: Take down test stack
if: always()
run: make stop
build-and-push:
needs: [tests]
runs-on: ubuntu-latest
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -54,5 +54,8 @@ ENV APACHE_DOCUMENT_ROOT=/app/web
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
RUN sed -ri -e 's!</VirtualHost>!\tFallbackResource app_prod.php\n</VirtualHost>!g' /etc/apache2/sites-available//000-default.conf
RUN mkdir /app/var

# Create /app/var only if it doesn't exist as a file or directory
RUN sh -c '[ ! -e /app/var ] && mkdir /app/var || echo "/app/var already exists"'

RUN chown -R www-data:www-data /app/var
68 changes: 42 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,51 +1,67 @@
.PHONY: dev
dev: bring-up-app-and-queue-watcher
docker compose logs --follow
docker compose --file docker-compose.yaml --file docker-compose.dev.yaml logs --follow

.PHONY: prod
prod: bring-up-app-and-queue-watcher
docker compose --file docker-compose.yaml --file docker-compose.dev.yaml logs --follow

.PHONY: bring-up-app-and-queue-watcher
bring-up-app-and-queue-watcher: config.php
docker compose up --wait
bring-up-app-and-queue-watcher: config.php build
docker compose --file docker-compose.yaml --file docker-compose.dev.yaml up --wait

.PHONY: bring-up-app-without-queue-watcher
bring-up-app-without-queue-watcher: config.php
docker compose up app --wait
docker compose down queue-watcher
bring-up-app-without-queue-watcher: config.php build
docker compose --file docker-compose.yaml --file docker-compose.dev.yaml up app --wait
docker compose --file docker-compose.yaml --file docker-compose.dev.yaml down queue-watcher

.PHONY: build
build:
docker compose --file docker-compose.yaml --file docker-compose.dev.yaml build

.PHONY: check
check: static-analysis test

.PHONY: static-analysis
static-analysis:
docker compose run --rm --no-deps app vendor/bin/phpcs --standard=phpcs.xml.dist --warning-severity=0 -p src/ tests/ web/
docker compose run --rm --no-deps app vendor/bin/composer-dependency-analyser
docker compose run --rm --no-deps app vendor/bin/phpstan analyse
static-analysis: config.php build
docker compose --file docker-compose.yaml --file docker-compose.dev.yaml run --rm --no-deps app vendor/bin/phpcs --standard=phpcs.xml.dist --warning-severity=0 -p src/ tests/ web/
docker compose --file docker-compose.yaml --file docker-compose.dev.yaml run --rm --no-deps app vendor/bin/composer-dependency-analyser
docker compose --file docker-compose.yaml --file docker-compose.dev.yaml run --rm --no-deps app vendor/bin/phpstan analyse

.PHONY: test
test: bring-up-app-and-queue-watcher
docker compose exec app vendor/bin/phpunit $(TEST)
test: config.php bring-up-app-and-queue-watcher
docker compose --file docker-compose.yaml --file docker-compose.dev.yaml exec app vendor/bin/phpunit $(TEST)

.PHONY: clean
clean:
docker compose --file docker-compose.yaml --file docker-compose.dev.yaml down --volumes
rm -rf var/logs/*.json

.PHONY: all-checks
all-checks: bring-up-app-without-queue-watcher
docker compose exec app bash project_tests.sh
all-checks: config.php clean bring-up-app-without-queue-watcher
docker compose --file docker-compose.yaml --file docker-compose.dev.yaml exec app bash project_tests.sh

.PHONY: stop
stop:
docker compose down

.PHONY: clean
clean:
docker compose down --volumes
rm -rf var/logs/*.json
docker compose --file docker-compose.yaml --file docker-compose.dev.yaml down

ENTITY = all
.PHONY: import-all
import-all:
docker compose exec app bin/console queue:import $(ENTITY)
.PHONY: import-entity
import-entity: config.php bring-up-app-and-queue-watcher
docker compose --file docker-compose.yaml --file docker-compose.dev.yaml exec app bin/console queue:import $(ENTITY)

.PHONY: import-all-entities-in-journal-test-environment
import-all-entities-in-journal-test-environment:
kubectl -n journal--test create job --from=cronjob/search-queue-import-all import-all-$(shell date "+%Y%m%d-%H%M")

.PHONY: update-api-sdk
update-api-sdk: config.php
docker compose run --no-deps setup composer install
docker compose run --no-deps setup composer update 'elife/api' 'elife/api-sdk' --no-suggest --no-interaction
update-api-sdk: config.php build
docker compose --file docker-compose.yaml --file docker-compose.dev.yaml run --no-deps setup composer install
docker compose --file docker-compose.yaml --file docker-compose.dev.yaml run --no-deps setup composer update 'elife/api' 'elife/api-sdk' --no-suggest --no-interaction

.PHONY: clean-index-for-search-test
clean-index-for-search-test:
kubectl -n journal--test exec -it $$(kubectl get pods -n journal--test -o json | jq -r '.items[] | select(.metadata.name | startswith("search-queue-watcher-")) | .metadata.name' | head -n1) -- ./bin/console search:setup -d

config.php:
cp config.php.dist config.php
22 changes: 0 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -59,25 +59,3 @@ docker compose down queue-watcher
docker compose exec app bash project_tests.sh
```
NOTE: these integration tests require the queue watcher to not be running so the tests can control when items are consumed. This is why we make sure to stop watcher services.

### Local web app, external opensearch

Port-forward the `journal--test` instance of opensearch:

```shell
kubectl port-forward service/opensearch --address 0.0.0.0 -n journal--test 9200:9200
```

Modify `$config['elastic_servers']` to point to `journal--test` opensearch in `/config.php`

```shell
'elastic_servers' => ['https://admin:admin@host.docker.internal:9200'],
```

Run the app only:

```shell
docker compose -f docker-compose.app.yaml up --wait
```

Visit: http://localhost:8888/search
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
},
"require": {
"php": "8.3.*",
"aws/aws-sdk-php": "3.339.1",
"aws/aws-sdk-php": "3.339.2",
"beberlei/assert": "^3.3",
"doctrine/annotations": "^1.4",
"elasticsearch/elasticsearch": "^7.11",
16 changes: 0 additions & 16 deletions docker-compose.app.yaml

This file was deleted.

7 changes: 7 additions & 0 deletions docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
app:
build:
target: dev
environment:
- GATEWAY_HOST=api-dummy:8080

3 changes: 0 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -70,9 +70,6 @@ services:
build:
context: .
dockerfile: Dockerfile
target: dev
environment:
- GATEWAY_HOST=api-dummy:8080
volumes:
- ./:/app
- ./config.php:/app/config.php