Skip to content

Commit a0b3bf8

Browse files
Merge pull request #66 from neo4j-php/neo4j-actions
Improve GitHub actions and add database integration tests
2 parents 02a0fb0 + 1860fa5 commit a0b3bf8

File tree

11 files changed

+509
-88
lines changed

11 files changed

+509
-88
lines changed

.github/workflows/analyse.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: analyse
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
analyse:
10+
name: "Static analysis (PHP ${{ matrix.php-version }})"
11+
runs-on: "ubuntu-22.04"
12+
continue-on-error: true
13+
14+
strategy:
15+
matrix:
16+
php-version: [ "8.1" ]
17+
18+
env:
19+
COMPOSER_VERSION: 2
20+
COVERAGE_DRIVER: none
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v3
25+
26+
- name: Setup PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: ${{ matrix.php-version }}
30+
coverage: ${{ env.COVERAGE_DRIVER }}
31+
tools: composer:${{ env.COMPOSER_VERSION }}
32+
33+
- name: Install dependencies
34+
run: composer install --no-interaction --prefer-dist --no-progress
35+
36+
- name: Execute type checking
37+
run: php vendor/bin/phpstan

.github/workflows/lint.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: lint
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
lint:
10+
name: "Linting (PHP ${{ matrix.php-version }})"
11+
runs-on: "ubuntu-22.04"
12+
continue-on-error: true
13+
14+
strategy:
15+
matrix:
16+
php-version: [ "8.1" ]
17+
18+
env:
19+
COMPOSER_VERSION: 2
20+
COVERAGE_DRIVER: none
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v3
25+
26+
- name: Setup PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: ${{ matrix.php-version }}
30+
coverage: ${{ env.COVERAGE_DRIVER }}
31+
tools: composer:${{ env.COMPOSER_VERSION }}
32+
33+
- name: Install dependencies
34+
run: composer install --no-interaction --prefer-dist --no-progress
35+
36+
- name: Run PHP-CS-Fixer
37+
run: php vendor/bin/php-cs-fixer fix --config .php-cs-fixer.dist.php --verbose --dry-run
38+
39+
40+
validate:
41+
name: "Validating composer.json"
42+
runs-on: "ubuntu-22.04"
43+
continue-on-error: true
44+
45+
env:
46+
COMPOSER_VERSION: 2
47+
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v3
51+
52+
- name: Setup PHP
53+
uses: shivammathur/setup-php@v2
54+
with:
55+
tools: composer:${{ env.COMPOSER_VERSION }}
56+
57+
- name: Run composer validate
58+
run: composer validate

.github/workflows/main.yml

Lines changed: 0 additions & 67 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: test
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
unit:
10+
name: "Unit and mutation testing (PHP ${{ matrix.php-version }})"
11+
runs-on: "ubuntu-22.04"
12+
continue-on-error: true
13+
14+
strategy:
15+
matrix:
16+
php-version: [ "7.4", "8.0", "8.1" ]
17+
18+
env:
19+
COMPOSER_VERSION: 2
20+
COVERAGE_DRIVER: xdebug
21+
MINIMUM_COVERAGE_PERCENTAGE: 80
22+
MINIMUM_MSI_PERCENTAGE: 80
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v3
27+
28+
- name: Setup PHP
29+
uses: shivammathur/setup-php@v2
30+
with:
31+
php-version: ${{ matrix.php-version }}
32+
coverage: ${{ env.COVERAGE_DRIVER }}
33+
ini-values: memory_limit=512M, xdebug.mode=off
34+
tools: composer:${{ env.COMPOSER_VERSION }}
35+
36+
- name: Install dependencies
37+
run: composer install --no-interaction --prefer-dist --no-progress
38+
39+
- name: Run unit tests
40+
run: XDEBUG_MODE=coverage php vendor/bin/phpunit --testsuite unit
41+
42+
- name: Check coverage
43+
run: php vendor/bin/coverage-check coverage/clover.xml ${{ env.MINIMUM_COVERAGE_PERCENTAGE }}
44+
45+
- name: Run mutation tests
46+
run: XDEBUG_MODE=coverage php vendor/bin/infection --show-mutations --min-msi=${{ env.MINIMUM_MSI_PERCENTAGE }} --threads=4
47+
48+
49+
integration:
50+
name: "Integration testing (PHP ${{ matrix.php-version }}, Neo4j ${{ matrix.neo4j-version }})"
51+
runs-on: "ubuntu-22.04"
52+
continue-on-error: true
53+
54+
strategy:
55+
matrix:
56+
neo4j-version: [ "4.2", "4.3", "4.4" ]
57+
php-version: [ "7.4", "8.0", "8.1" ]
58+
59+
services:
60+
neo4j:
61+
image: neo4j:${{ matrix.neo4j-version }}
62+
env:
63+
NEO4J_AUTH: neo4j/test
64+
NEO4JLABS_PLUGINS: '["apoc"]'
65+
ports:
66+
- 7687:7687
67+
- 7474:7474
68+
options: >-
69+
--health-cmd "wget -q --method=HEAD http://localhost:7474 || exit 1"
70+
--health-start-period "60s"
71+
--health-interval "30s"
72+
--health-timeout "15s"
73+
--health-retries "5"
74+
75+
env:
76+
COMPOSER_VERSION: 2
77+
COVERAGE_DRIVER: none
78+
NEO4J_CONNECTIONS: bolt://neo4j:test@localhost,http://neo4j:test@localhost
79+
80+
steps:
81+
- name: Checkout repository
82+
uses: actions/checkout@v3
83+
84+
- name: Setup PHP
85+
uses: shivammathur/setup-php@v2
86+
with:
87+
php-version: ${{ matrix.php-version }}
88+
coverage: ${{ env.COVERAGE_DRIVER }}
89+
ini-values: memory_limit=512M
90+
tools: composer:${{ env.COMPOSER_VERSION }}
91+
92+
- name: Install dependencies
93+
run: composer install --no-interaction --prefer-dist --no-progress
94+
95+
- name: Run integration tests
96+
run: php vendor/bin/phpunit --testsuite integration --no-coverage

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ vendor/
66
*.idea
77
.phpunit.result.cache
88
.php-cs-fixer.cache
9+
coverage/

0 commit comments

Comments
 (0)