-
Notifications
You must be signed in to change notification settings - Fork 17
84 lines (71 loc) · 3.44 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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
options: --name database
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
id: get_network
run: echo "NETWORK=$(docker ps --format '{{ json .Networks }}' --filter 'name=database' | cut -d "\"" -f 2)" >> "$GITHUB_OUTPUT"
- name: Build docker development image
run: docker build --target development --tag movary ./build/php/
- name: Install dependencies
run: docker run --rm --network $NETWORK -v /home/runner/work/movary/movary:/app movary composer --no-interaction install
env:
NETWORK: ${{ steps.get_network.outputs.NETWORK }}
- name: Run PHPCs
run: docker run --rm --network $NETWORK -v /home/runner/work/movary/movary:/app movary vendor/bin/phpcs --standard=./settings/phpcs.xml --report=checkstyle -q ./src ./tests | vendor/bin/cs2pr
env:
NETWORK: ${{ steps.get_network.outputs.NETWORK }}
- name: Run PHPStan
run: docker run --rm --network $NETWORK -v /home/runner/work/movary/movary:/app movary vendor/bin/phpstan analyse -c ./settings/phpstan.neon
env:
NETWORK: ${{ steps.get_network.outputs.NETWORK }}
- name: Run Psalm
run: docker run --rm --network $NETWORK -v /home/runner/work/movary/movary:/app movary vendor/bin/psalm -c ./settings/psalm.xml --show-info=false --output-format=github
env:
NETWORK: ${{ steps.get_network.outputs.NETWORK }}
- name: Run PHPUnit
run: docker run --rm --network $NETWORK -v /home/runner/work/movary/movary:/app movary vendor/bin/phpunit -c ./settings/phpunit.xml --testsuite unit
env:
NETWORK: ${{ steps.get_network.outputs.NETWORK }}
- name: Prepare for the tests
run: |
docker run --rm --network $NETWORK -v /home/runner/work/movary/movary:/app movary php bin/console.php database:migration:migrate
docker run --rm --network $NETWORK -v /home/runner/work/movary/movary:/app movary php bin/console.php user:create testUser@domain.com password1234 testUser true
env:
NETWORK: ${{ steps.get_network.outputs.NETWORK }}
- name: Run the HTTP tests
run: |
docker run --rm -d -p 80:80 --network $NETWORK -v /home/runner/work/movary/movary:/app movary &&
./ijhttp/ijhttp tests/rest/api/authentication.http --env-file tests/rest/api/http-client.env.json --env CI &&
docker stop movary && docker rm movary
env:
NETWORK: ${{ steps.get_network.outputs.NETWORK }}