Skip to content

Refactor testing pipeline #1160

Refactor testing pipeline

Refactor testing pipeline #1160

Workflow file for this run

name: Run tests
on: [ pull_request ]
jobs:
run_tests:
name: Run tests
runs-on: ubuntu-latest
services:
database:
image: mariadb
env:
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: 1
MARIADB_DATABASE: movary
ports:
- 3306:3306
container:
image: webdevops/php-nginx:8.3-alpine
env:
DATABASE_MODE: mysql
DATABASE_MYSQL_HOST: database
DATABASE_MYSQL_PORT: 3306
DATABASE_MYSQL_USER: root
DATABASE_MYSQL_NAME: movary
DATABASE_MYSQL_PASSWORD: ''
WEB_DOCUMENT_ROOT: /app/public
PHP_DISMOD: imagick
ports:
- 80
volumes:
- /home/runner/work/movary/movary:/app
options: -u application -w /app --name movary
steps:
- uses: actions/checkout@v3
- name: Set environment variables
run: |
echo "DATABASE_MODE=mysql" > ".env"
echo "DATABASE_MYSQL_HOST=database" >> ".env"
echo "DATABASE_MYSQL_PORT=3306" >> ".env"
echo "DATABASE_MYSQL_USER=root" >> ".env"
echo "DATABASE_MYSQL_NAME=movary" >> ".env"
echo "DATABASE_MYSQL_PASSWORD=" >> ".env"
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Downloads and runs the Jetbrains HTTP Client CLI
run: |
curl -f -L -o ijhttp.zip "https://jb.gg/ijhttp/latest"
unzip ijhttp.zip
# - name: Get Docker network name of GitHub services
# run: docker inspect database --format='{{json .NetworkSettings.Networks}}'
# NETWORK=$( docker network ls --format "{{ .Name }}" | sed -n 1p) &&
- name: Build docker development image
run: docker build --target development --tag movary ./build/php/
- name: Install dependencies
run: docker exec movary composer --no-interaction install
- name: Run PHPCs
run: docker exec movary vendor/bin/phpcs --standard=./settings/phpcs.xml --report=checkstyle -q ./src ./tests | vendor/bin/cs2pr
- name: Run PHPStan
run: docker exec movary vendor/bin/phpstan analyse -c ./settings/phpstan.neon
- name: Run Psalm
run: docker exec movary vendor/bin/psalm -c ./settings/psalm.xml --show-info=false --output-format=github
- name: Run PHPUnit
run: docker exec movary vendor/bin/phpunit -c ./settings/phpunit.xml --testsuite unit
- name: Prepare for the tests
run: |
docker exec movary php bin/console.php database:migration:migrate
docker exec movary php bin/console.php user:create testUser@domain.com password1234 testUser true
- name: Run the HTTP tests
run: |
./ijhttp/ijhttp tests/rest/api/authentication.http --env-file tests/rest/api/http-client.env.json --env CI