Skip to content

Commit bc570db

Browse files
p123-stackPratiksha
andauthored
github-actions-pro-server-and-docker-container (#24)
Improve Github CI --------- Co-authored-by: Pratiksha <pratiksha@Pratiksha-Nagels>
1 parent 3981a4f commit bc570db

File tree

6 files changed

+126
-16
lines changed

6 files changed

+126
-16
lines changed

.github/workflows/psalm.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
name: Run Psalm
1010
runs-on: ubuntu-latest
1111

12+
1213
steps:
1314
- name: Checkout code
1415
uses: actions/checkout@v3

.github/workflows/test.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,22 @@ concurrency:
1010

1111
jobs:
1212
tests:
13+
services:
14+
neo4j:
15+
image: neo4j:latest
16+
ports:
17+
- 7474:7474
18+
- 7687:7687
19+
env:
20+
NEO4J_AUTH: neo4j/password
21+
options: >-
22+
--health-cmd "wget --no-verbose --tries=1 --spider localhost:7474 || exit 1"
23+
--health-interval 10s
24+
--health-retries 5
25+
--health-timeout 5s
26+
1327
name: Run PHPUnit Tests
1428
runs-on: ubuntu-latest
15-
1629
steps:
1730
- name: Checkout code
1831
uses: actions/checkout@v3
@@ -35,7 +48,7 @@ jobs:
3548

3649
- name: Run Tests without phpunit.xml
3750
env:
38-
NEO4J_ADDRESS: ${{ secrets.NEO4J_ADDRESS }}
39-
NEO4J_USERNAME: ${{ secrets.NEO4J_USERNAME }}
40-
NEO4J_PASSWORD: ${{ secrets.NEO4J_PASSWORD }}
51+
NEO4J_ADDRESS: "http://localhost:7474"
52+
NEO4J_USERNAME: "neo4j"
53+
NEO4J_PASSWORD: "password"
4154
run: vendor/bin/phpunit --configuration phpunit.dist.xml

.github/workflows/testaura.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Test Neo4j Aura
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch: # Allows manual trigger
8+
9+
concurrency:
10+
group: neo4j-aura-test-main
11+
cancel-in-progress: true
12+
13+
jobs:
14+
tests-aura:
15+
name: Run PHPUnit Tests with Neo4j Aura
16+
runs-on: ubuntu-latest
17+
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v3
22+
23+
- name: Set up PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: 8.2
27+
tools: composer, xdebug
28+
29+
- name: Cache Composer dependencies
30+
uses: actions/cache@v3
31+
with:
32+
path: vendor
33+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
34+
restore-keys: ${{ runner.os }}-composer-
35+
36+
- name: Install dependencies
37+
run: composer install --no-progress --prefer-dist
38+
39+
- name: Run Tests
40+
env:
41+
NEO4J_ADDRESS: ${{ secrets.NEO4J_ADDRESS }}
42+
NEO4J_USERNAME: ${{ secrets.NEO4J_USERNAME }}
43+
NEO4J_PASSWORD: ${{ secrets.NEO4J_PASSWORD }}
44+
run: vendor/bin/phpunit --configuration phpunit.dist.xml

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Use an official PHP image as the base image
2+
FROM php:8.2-fpm
3+
4+
# Install necessary extensions (e.g., for Composer)
5+
RUN apt-get update && apt-get install -y libpng-dev libjpeg-dev libfreetype6-dev \
6+
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
7+
&& docker-php-ext-install gd
8+
9+
# Set working directory
10+
WORKDIR /var/www
11+
12+
# Copy the composer.phar file to the container
13+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
14+
15+
# Expose PHP-FPM port
16+
EXPOSE 9000
17+
18+
# Start PHP-FPM server
19+
CMD ["php-fpm"]

docker-compose.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
version: '3.8'
2+
3+
services:
4+
# PHP Service
5+
app:
6+
build:
7+
context: .
8+
dockerfile: Dockerfile
9+
container_name: php-app
10+
working_dir: /var/www
11+
volumes:
12+
- .:/var/www
13+
networks:
14+
- mynetwork
15+
ports:
16+
- "9000:9000" # Exposing port for PHP-FPM
17+
18+
# Composer Service
19+
composer:
20+
image: composer:latest
21+
container_name: composer
22+
volumes:
23+
- .:/var/www
24+
working_dir: /var/www
25+
networks:
26+
- mynetwork
27+
command: ["install", "--no-progress", "--prefer-dist"]
28+
29+
# Neo4j Service (Optional, if you need Neo4j)
30+
neo4j:
31+
image: neo4j:latest
32+
container_name: neo4j
33+
environment:
34+
- NEO4J_AUTH=neo4j/password
35+
ports:
36+
- "7474:7474" # Web interface
37+
- "7687:7687" # Bolt protocol
38+
networks:
39+
- mynetwork
40+
41+
# Define a network for communication between containers
42+
networks:
43+
mynetwork:
44+
driver: bridge

tests/Integration/Neo4jQueryAPIIntegrationTest.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -393,18 +393,7 @@ public function testInvalidQueryException(): void
393393
}
394394
}
395395

396-
public function testCreateDuplicateConstraintException(): void
397-
{
398-
try {
399-
$this->api->run('CREATE CONSTRAINT person_name FOR (n:Person1) REQUIRE n.name IS UNIQUE', []);
400-
$this->fail('Expected a Neo4jException to be thrown.');
401-
} catch (Neo4jException $e) {
402-
// $errorMessages = $e->getErrorType() . $e->errorSubType() . $e->errorName();
403-
$this->assertInstanceOf(Neo4jException::class, $e);
404-
$this->assertEquals('Neo.ClientError.Schema.EquivalentSchemaRuleAlreadyExists', $e->getErrorCode());
405-
$this->assertNotEmpty($e->getMessage());
406-
}
407-
}
396+
408397

409398
public function testWithExactNames(): void
410399
{

0 commit comments

Comments
 (0)