Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run functional tests on github action #1885

Merged
merged 2 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ jobs:
tools: 'composer-normalize:2.11.0, php-cs-fixer:2.16.7'

- name: 'Check PHP code'
run: 'php-cs-fixer fix --diff --dry-run --allow-risky=yes --using-cache=false'
run: |
php-cs-fixer fix --diff --dry-run --allow-risky=yes --using-cache=false

- name: 'Check composer.json'
run: 'composer-normalize --diff --dry-run --indent-size=4 --indent-style=space --no-update-lock'
run: |
composer-normalize --diff --dry-run --indent-size=4 --indent-style=space --no-update-lock

phpunit:
runs-on: 'ubuntu-20.04'
Expand Down Expand Up @@ -55,7 +57,8 @@ jobs:

- name: 'Get composer cache directory'
id: 'composer_cache'
run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: 'Cache dependencies'
uses: 'actions/cache@v2'
Expand All @@ -67,7 +70,23 @@ jobs:
${{ runner.os }}-composer-

- name: 'Update dependencies'
run: 'composer update --prefer-dist --no-interaction --no-progress --ansi ${{ matrix.composer_flags }}'
run: |
composer update --prefer-dist --no-interaction --no-progress --ansi ${{ matrix.composer_flags }}

- name: 'Run tests'
run: 'vendor/bin/phpunit --group unit'
- name: 'Run unit tests'
run: |
vendor/bin/phpunit --group unit

- name: 'Setup Elasticsearch'
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
ES_VERSION=${{ matrix.elasticsearch }} docker-compose --file=docker/docker-compose.proxy.yml --file=docker/docker-compose.es.yml up --detach
docker run --rm --network=docker_elastic curlimages/curl --max-time 120 --retry-max-time 120 --retry 120 --retry-delay 5 --retry-all-errors --show-error --silent http://es01:9200
docker run --rm --network=docker_elastic curlimages/curl --max-time 120 --retry-max-time 120 --retry 120 --retry-delay 5 --retry-all-errors --show-error --silent http://es02:9200

- name: 'Run functional tests'
run: |
vendor/bin/phpunit --group functional
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Default version to start ES on Docker, overide with `ES_VERSION=75 make start-docker` for ES 7.5
ES_VERSION?=73

.PHONY: clean
clean:
rm -fr tools vendor build composer.lock .php_cs.cache
Expand Down Expand Up @@ -75,15 +72,14 @@ docker-start:
docker-compose --file=docker/docker-compose.yml \
--file=docker/docker-compose.proxy.yml \
--file=docker/docker-compose.es.yml \
--file=docker/docker-compose.es${ES_VERSION}.yml \
--file=docker/docker-compose.es.yml \
up ${DOCKER_OPTIONS}

.PHONY: docker-stop
docker-stop:
docker-compose --file=docker/docker-compose.yml \
--file=docker/docker-compose.proxy.yml \
--file=docker/docker-compose.es.yml \
--file=docker/docker-compose.es${ES_VERSION}.yml \
down

.PHONY: docker-run-phpunit
Expand Down
18 changes: 7 additions & 11 deletions docker/docker-compose.es.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
version: '3.4'

# Template docker-compose file: the ES services are not valid, as there is no `:latest` tag on those images.
#
# This is done on purpose as the ES version can be chosen when starting docker
# As an example: see docker-compose.es75.yml
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch-oss:latest
image: docker.elastic.co/elasticsearch/elasticsearch-oss:${ES_VERSION:-7.3.2}
command: >
/bin/sh -c "./bin/elasticsearch-plugin list | grep -q ingest-attachment
|| ./bin/elasticsearch-plugin install --batch ingest-attachment;
Expand All @@ -15,8 +11,8 @@ services:
environment:
- node.name=es01
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es02
- cluster.initial_master_nodes=es01,es02
- cluster.initial_master_nodes=es01
- discovery.seed_hosts=es01
- bootstrap.memory_lock=true
- processors=1
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
Expand All @@ -29,11 +25,11 @@ services:
- data01:/usr/share/elasticsearch/data
- esrepo:/usr/share/elasticsearch/repository
ports:
- 127.0.0.1:9200:9200
- 9200:9200
networks:
- elastic
es02:
image: docker.elastic.co/elasticsearch/elasticsearch-oss:latest
image: docker.elastic.co/elasticsearch/elasticsearch-oss:${ES_VERSION:-7.3.2}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much nicer! Good that we got rid of all the yaml files.

command: >
/bin/sh -c "./bin/elasticsearch-plugin list | grep -q ingest-attachment
|| ./bin/elasticsearch-plugin install --batch ingest-attachment;
Expand All @@ -42,8 +38,8 @@ services:
environment:
- node.name=es02
- cluster.name=es-docker-cluster
- cluster.initial_master_nodes=es01
- discovery.seed_hosts=es01
- cluster.initial_master_nodes=es01,es02
- bootstrap.memory_lock=true
- processors=1
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
Expand All @@ -64,4 +60,4 @@ volumes:

networks:
elastic:
driver: bridge
driver: bridge
7 changes: 0 additions & 7 deletions docker/docker-compose.es71.yml

This file was deleted.

7 changes: 0 additions & 7 deletions docker/docker-compose.es72.yml

This file was deleted.

7 changes: 0 additions & 7 deletions docker/docker-compose.es73.yml

This file was deleted.

7 changes: 0 additions & 7 deletions docker/docker-compose.es74.yml

This file was deleted.

7 changes: 0 additions & 7 deletions docker/docker-compose.es75.yml

This file was deleted.

4 changes: 2 additions & 2 deletions docker/docker-compose.proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ services:
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- 127.0.0.1:8000:8000
- 127.0.0.1:8001:8001
- 8000:8000
- 8001:8001
networks:
- elastic

Expand Down