Skip to content

Commit 3f29bb2

Browse files
authored
Testing (#7)
* streamlined ci * added more tests
1 parent 85c55c3 commit 3f29bb2

26 files changed

+328
-283
lines changed

.gitignore

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
.php_cs.cache
2-
bin/*
32
cache/
4-
neoclient.yml
5-
test.php
6-
tests/_reports
7-
tests/database_settings.yml
83
vendor/
94
phpunit.xml
105
.phpunit.result.cache
116
.idea/
7+
clover.xml
8+
cc-test-reporter

Dockerfile

+11-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ RUN apt-get update && apt-get install -y \
77
libzip-dev \
88
zip \
99
unzip \
10+
git \
11+
wget \
1012
&& docker-php-ext-install -j$(nproc) gd sockets bcmath \
11-
&& pecl install ds \
12-
&& docker-php-ext-enable ds
13+
&& pecl install ds pcov \
14+
&& docker-php-ext-enable ds \
15+
&& wget https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 \
16+
&& mv test-reporter-latest-linux-amd64 /usr/bin/cc-test-reporter \
17+
&& chmod +x /usr/bin/cc-test-reporter
1318

1419
ARG WITH_XDEBUG=false
1520

@@ -19,10 +24,13 @@ RUN if [ $WITH_XDEBUG = "true" ] ; then \
1924
fi;
2025
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
2126

22-
COPY composer.json composer.lock phpunit.xml.dist phpunit-bootstrap.php psalm.xml .php_cs ./
27+
WORKDIR /opt/project
28+
29+
COPY composer.json composer.lock phpunit.xml.dist phpunit.coverage.xml.dist psalm.xml .php_cs ./
2330
COPY src/ src/
2431
COPY tests/ tests/
2532
COPY tools/ tools/
33+
COPY .git/ .git/
2634

2735

2836
RUN composer install && \
@@ -31,4 +39,3 @@ RUN composer install && \
3139

3240

3341

34-

Jenkinsfile

+31-32
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
pipeline {
22
agent any
33

4+
environment {
5+
BRANCH_NAME = "${GIT_BRANCH.split("/").size() > 1 ? GIT_BRANCH.split("/")[1] : GIT_BRANCH}"
6+
}
7+
48
stages {
9+
stage('Pull') {
10+
steps {
11+
sh 'docker-compose -p $BRANCH_NAME -f docker/docker-compose.yml pull'
12+
}
13+
}
514
stage('Build') {
615
steps {
716
sh 'docker build -t php-neo4j:static-analysis .'
8-
sh 'docker-compose -f docker/docker-compose-4.2.yml build'
9-
sh 'docker-compose -f docker/docker-compose-4.1.yml build'
10-
sh 'docker-compose -f docker/docker-compose-4.0.yml build'
11-
sh 'docker-compose -f docker/docker-compose-3.5.yml build'
12-
sh 'docker-compose -f docker/docker-compose-2.3.yml build'
13-
sh 'docker-compose -f docker/docker-compose-php-7.4.yml build'
17+
sh 'docker-compose -p $BRANCH_NAME -f docker/docker-compose.yml build --parallel'
18+
sh 'docker-compose -p $BRANCH_NAME build'
1419
sh 'docker build -t php-neo4j:static-analysis .'
1520
}
1621
}
@@ -22,33 +27,27 @@ pipeline {
2227
}
2328
stage('Test') {
2429
steps {
25-
sh 'docker-compose -f docker/docker-compose-4.2.yml down --volumes'
26-
sh 'docker-compose -f docker/docker-compose-4.2.yml up -d --force-recreate'
27-
sh 'docker-compose -f docker/docker-compose-4.2.yml run client php vendor/bin/phpunit'
28-
sh 'docker-compose -f docker/docker-compose-4.2.yml down'
29-
30-
31-
sh 'docker-compose -f docker/docker-compose-4.1.yml down --volumes'
32-
sh 'docker-compose -f docker/docker-compose-4.1.yml up -d --force-recreate'
33-
sh 'docker-compose -f docker/docker-compose-4.1.yml run client php vendor/bin/phpunit'
34-
sh 'docker-compose -f docker/docker-compose-4.1.yml down'
35-
36-
37-
sh 'docker-compose -f docker/docker-compose-4.0.yml down --volumes'
38-
sh 'docker-compose -f docker/docker-compose-4.0.yml up -d --force-recreate'
39-
sh 'docker-compose -f docker/docker-compose-4.0.yml run client php vendor/bin/phpunit'
40-
sh 'docker-compose -f docker/docker-compose-4.0.yml down'
41-
42-
43-
sh 'docker-compose -f docker/docker-compose-3.5.yml down --volumes'
44-
sh 'docker-compose -f docker/docker-compose-3.5.yml up -d --force-recreate'
45-
sh 'docker-compose -f docker/docker-compose-3.5.yml run client php vendor/bin/phpunit'
46-
sh 'docker-compose -f docker/docker-compose-3.5.yml down'
47-
48-
// sh 'docker-compose -f docker/docker-compose-2.3.yml run client php vendor/bin/phpunit'
49-
sh 'docker-compose -f docker/docker-compose-php-7.4.yml run client php vendor/bin/phpunit'
50-
sh 'docker-compose -f docker/docker-compose-php-7.4.yml down'
30+
sh 'docker-compose -f docker/docker-compose.yml -p $BRANCH_NAME down --volumes --remove-orphans'
31+
sh 'docker-compose -f docker/docker-compose.yml -p $BRANCH_NAME up -d --force-recreate --remove-orphans'
32+
sh 'sleep 10' // Wait for the servers to complete booting
33+
sh 'docker-compose -f docker/docker-compose.yml -p $BRANCH_NAME run client-80 php vendor/bin/phpunit'
34+
sh 'docker-compose -f docker/docker-compose.yml -p $BRANCH_NAME run client-74 php vendor/bin/phpunit'
5135
}
5236
}
37+
stage ('Coverage') {
38+
steps {
39+
sh 'docker-compose -f docker/docker-compose.yml -p $BRANCH_NAME run client bash -c "\
40+
cc-test-reporter before-build && \
41+
vendor/bin/phpunit --config phpunit.coverage.xml.dist -d memory_limit=1024M && \
42+
cp out/phpunit/clover.xml clover.xml && \
43+
cc-test-reporter after-build --id ec331dd009edca126a4c27f4921c129de840c8a117643348e3b75ec547661f28 --exit-code 0"'
44+
}
45+
}
46+
}
47+
48+
post {
49+
always {
50+
sh 'docker-compose -f docker/docker-compose.yml -p $BRANCH_NAME down --volumes'
51+
}
5352
}
5453
}

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Laudis Neo4j PHP Client
22

3+
[![Maintainability](https://api.codeclimate.com/v1/badges/275c2269aa54c2c43210/maintainability)](https://codeclimate.com/github/laudis-technologies/neo4j-php-client/maintainability)
4+
[![Test Coverage](https://api.codeclimate.com/v1/badges/275c2269aa54c2c43210/test_coverage)](https://codeclimate.com/github/laudis-technologies/neo4j-php-client/test_coverage)
5+
[![MIT License](https://img.shields.io/apm/l/atomic-design-ui.svg?)](https://github.com/laudis-technologies/neo4j-php-client/blob/main/LICENSE)
6+
37
## Installation
48

59
Install via composer:

docker-compose.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,23 @@ services:
1111
dockerfile: Dockerfile
1212
args:
1313
- WITH_XDEBUG=true
14+
working_dir: /opt/project
1415
networks:
1516
- neo4j
1617
volumes:
1718
- .:/opt/project
1819
depends_on:
19-
- neo4j
20+
- neo4j-42
2021
expose:
2122
- 9000
22-
neo4j:
23+
environment:
24+
- XDEBUG_MODE=coverage
25+
neo4j-42:
2326
networks:
2427
- neo4j
2528
image: neo4j:4.2
26-
ports:
27-
- "7474:7474"
28-
- "7687:7687"
2929
expose:
3030
- 7474
3131
- 7687
32-
- 6362
3332
environment:
3433
- NEO4J_AUTH=neo4j/test

docker/Dockerfile-php-7.4

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ RUN apt-get update && apt-get install -y \
1414
ARG WITH_XDEBUG=false
1515

1616
RUN if [ $WITH_XDEBUG = "true" ] ; then \
17-
pecl install xdebug-2.9.8; \
17+
pecl install xdebug; \
1818
docker-php-ext-enable xdebug; \
1919
fi;
2020

2121
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
2222

23-
COPY composer.json composer.lock phpunit.xml.dist phpunit-bootstrap.php ./
23+
WORKDIR /opt/project
24+
25+
COPY composer.json composer.lock phpunit.xml.dist ./
2426
COPY src/ src/
2527
COPY tests/ tests/
2628

docker/Dockerfile-php-8.0

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ fi;
2020

2121
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
2222

23-
COPY composer.json composer.lock phpunit.xml.dist phpunit-bootstrap.php ./
23+
WORKDIR /opt/project
24+
25+
COPY composer.json composer.lock phpunit.xml.dist ./
2426
COPY src/ src/
2527
COPY tests/ tests/
2628

docker/docker-compose-2.3.yml

-28
This file was deleted.

docker/docker-compose-3.5.yml

-28
This file was deleted.

docker/docker-compose-4.0.yml

-28
This file was deleted.

docker/docker-compose-4.1.yml

-28
This file was deleted.

docker/docker-compose-4.2.yml

-28
This file was deleted.

docker/docker-compose-php-7.4.yml

-28
This file was deleted.

0 commit comments

Comments
 (0)