Skip to content

Commit f54dcb1

Browse files
gepAndrey Semikov
and
Andrey Semikov
authored
Initial open source preparations (#1)
* Initial Open source preparations * Correct readme. Installation dev instructions * Add CI * Add bcmath extention * Change code style standard * Add phpSpec as unit tests * Add phpSpec php version * Refactor PHP Spec * Correct docker compose files * Correct ci docker compose command * Correct ci docker compose command * Remove obsolete services * Experiment with the docker compose * Add functional tests into the pipeline * Correct CI docker compose and build * Separate tests * Rename actions * Rename, add some docs and authors * Some final renames * Some doc improvements and checks --------- Co-authored-by: Andrey Semikov <andrey.semikov@dealtrak.co.uk>
1 parent acea4d5 commit f54dcb1

File tree

224 files changed

+15836
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

224 files changed

+15836
-0
lines changed

.env.local.sample

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Used only for tests
2+
APP_ENV=dev
3+
4+
XDEBUG_MODE=debug
5+
6+
# enable xdebug if needed
7+
XDEBUG_START_WITH_REQUEST=0
8+
XDEBUG_DISCOVER_CLIENT_HOST=0
9+
XDEBUG_CLIENT_HOST=localhost
10+
#XDEBUG_CLIENT_HOST=docker.for.mac.localhost
11+
XDEBUG_CLIENT_PORT=9003
12+
13+
# settigns for PHP storm
14+
IDE_KEY=dynamo-db-adapter
15+
PHP_IDE_CONFIG=serverName=dynamo-db-adapter
16+
17+

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Code style, unit and functional tests
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
code-style:
14+
runs-on: ubuntu-latest
15+
steps:
16+
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
20+
- name: Composer install
21+
uses: php-actions/composer@v6
22+
with:
23+
php_version: 8.1
24+
php_extensions: bcmath
25+
26+
- name: PHP Code Sniffer
27+
uses: php-actions/phpcs@v1
28+
with:
29+
php_version: 8.1
30+
path: src/
31+
standard: PSR2
32+
33+
tests:
34+
runs-on: ubuntu-latest
35+
steps:
36+
37+
- name: Checkout
38+
uses: actions/checkout@v3
39+
40+
- name: Build image for subsequent tests
41+
run: docker-compose -f docker-compose.ci.yml build
42+
43+
- name: Run unit tests
44+
run: docker-compose -f docker-compose.ci.yml run --no-deps dynamodb-odm vendor/bin/phpspec run
45+
46+
- name: Run functional tests
47+
run: docker-compose -f docker-compose.ci.yml run dynamodb-odm vendor/bin/behat -c behat.yml --stop-on-failure

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/vendor/
2+
.idea
3+
logs/xdebug.log
4+
.envrc
5+
.env.local
6+
composer.lock
7+
.composer/**
8+
docker/dynamodb/**

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM composer:2.5.5 as composerDocker
2+
3+
FROM php:8.1.14-cli-buster
4+
5+
WORKDIR /application
6+
7+
ENV DEBIAN_FRONTEND noninteractive
8+
9+
RUN apt update && \
10+
apt install -y git && \
11+
apt install -y zip unzip libzip-dev && \
12+
pecl install xdebug-3.1.2 && \
13+
docker-php-ext-configure zip --with-zip && \
14+
docker-php-ext-install zip bcmath && \
15+
docker-php-ext-enable xdebug
16+
17+
ADD ./docker/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
18+
19+
COPY --from=composerDocker /usr/bin/composer /usr/bin/composer
20+
21+
COPY . /application
22+
23+
ARG COMPOSER_AUTH
24+
25+
RUN composer install --prefer-dist

Dockerfile.ci

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM composer:2.5.5 as composerDocker
2+
3+
FROM php:8.1.14-cli-buster
4+
5+
WORKDIR /application
6+
7+
ENV DEBIAN_FRONTEND noninteractive
8+
9+
RUN apt update && \
10+
apt install -y git && \
11+
apt install -y zip unzip libzip-dev && \
12+
docker-php-ext-configure zip --with-zip && \
13+
docker-php-ext-install zip bcmath
14+
15+
COPY --from=composerDocker /usr/bin/composer /usr/bin/composer
16+
17+
COPY . /application
18+
19+
ARG COMPOSER_AUTH
20+
21+
RUN composer install --prefer-dist --no-plugins --no-scripts

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# AWS Dynamodb ODM for PHP
2+
3+
![Code style, unit and functional tests](https://github.com/AutoProtect-Group/php-dynamodb-odm/actions/workflows/ci.yml/badge.svg)
4+
5+
This is a library and an Object Document Mapper to use with AWS DynamoDB in a more convenient way.
6+
7+
## Usage
8+
9+
To be added soon...
10+
11+
## Local dev environment installation
12+
13+
1. In order to build a dev image, please, run:
14+
```bash
15+
docker-compose build
16+
```
17+
2. Then run to install dependencies:
18+
```bash
19+
docker-compose run --no-deps dynamodb-odm composer install
20+
```
21+
22+
## Running tests
23+
24+
### Unit tests
25+
26+
This package uses phpspec for running unit tests.
27+
28+
Run them using the following way:
29+
```bash
30+
docker-compose run --no-deps dynamodb-odm vendor/bin/phpspec run
31+
```
32+
33+
One can use environment variables in the `.env.local` file to be able to debug the library. For this just Copy file [.env.local.sample](.env.local.sample) into [.env.local](.env.local) and set up the variable according to your OS.
34+
35+
And then run the tests with:
36+
37+
```bash
38+
docker-compose --env-file ./.env.local run --no-deps dynamodb-odm vendor/bin/phpspec run
39+
```
40+
41+
### Functional tests
42+
43+
This package uses behat for running functional tests.
44+
45+
Then just run the tests:
46+
47+
```bash
48+
docker-compose run dynamodb-odm vendor/bin/behat -c behat.yml --stop-on-failure
49+
```
50+
51+
### Syntax check tests
52+
53+
You need to check if the code style is OK by running:
54+
```bash
55+
docker-compose run --no-deps dynamodb-odm vendor/bin/phpcs --basepath=/application/src --standard=PSR2 src
56+
```

behat.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
default:
2+
formatters:
3+
progress: true
4+
5+
suites:
6+
default:
7+
contexts:
8+
- 'RepositoryContext'
9+
- 'QueryBuilderContext'

composer.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "autoprotect-group/dynamo-db-adapter",
3+
"description": "PHP Object Document Mapper for AWS DynamoDB",
4+
"type": "library",
5+
"authors": [
6+
{
7+
"name": "Andrey Semikov",
8+
"email": "andrew.semikov@gmail.com",
9+
"homepage": "https://github.com/gep"
10+
},
11+
{
12+
"name": "Kiryl Krasouski",
13+
"email": "kiryl.krasouski@dealtrak.co.uk"
14+
},
15+
{
16+
"name": "Artur Drabinka",
17+
"email": "artur.drabinka@dealtrak.co.uk"
18+
},
19+
{
20+
"name": "Siarhei Karavai",
21+
"email": "sergey.karavay@gmail.com",
22+
"homepage": "https://github.com/GinoPane"
23+
},
24+
{
25+
"name": "Denis Grinko",
26+
"email": "ut.scorpion2@gmail.com"
27+
}
28+
],
29+
"require": {
30+
"php": "^8.1",
31+
"aws/aws-sdk-php": "^3.218",
32+
"doctrine/annotations": "^1.13",
33+
"adbario/php-dot-notation": "^3.1",
34+
"ext-bcmath": "*",
35+
"moneyphp/money": "^4.0"
36+
},
37+
"require-dev": {
38+
"koriym/attributes": "^1.0",
39+
"squizlabs/php_codesniffer": "^3.6",
40+
"behat/behat": "^3.10",
41+
"phpspec/phpspec": "^7.2",
42+
"phpspec/prophecy": "^1.15",
43+
"defuse/php-encryption": "^2.3",
44+
"phpunit/phpunit": "^9.5",
45+
"henzeb/enumhancer": "^1.11"
46+
},
47+
"autoload": {
48+
"psr-4": {
49+
"Autoprotect\\DynamodbODM\\": "src/"
50+
}
51+
},
52+
"autoload-dev": {
53+
"psr-4": {
54+
"spec\\Autoprotect\\DynamodbODM\\": "spec/"
55+
}
56+
}
57+
}

docker-compose.ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: "3.8"
2+
services:
3+
dynamodb-odm:
4+
image: dynamodb-odm:ci
5+
build:
6+
context: .
7+
dockerfile: Dockerfile.ci
8+
environment:
9+
- AWS_ACCESS_KEY_ID=test
10+
- AWS_SECRET_ACCESS_KEY=test
11+
- AWS_SESSION_TOKEN=test
12+
- DYNAMODB_ENDPOINT_URL=http://dynamodb-local:8000
13+
depends_on:
14+
- dynamodb-local
15+
links:
16+
- dynamodb-local
17+
18+
dynamodb-local:
19+
command: "-jar DynamoDBLocal.jar -sharedDb"
20+
image: amazon/dynamodb-local:1.21.0
21+
container_name: dynamodb-local
22+
working_dir: /home/dynamodblocal
23+
24+
networks:
25+
default:
26+
name: dynamodb-odm-common

docker-compose.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: "3.8"
2+
services:
3+
dynamodb-odm:
4+
extends:
5+
service: dynamodb-odm
6+
file: docker-compose.ci.yml
7+
build:
8+
context: .
9+
dockerfile: Dockerfile
10+
environment:
11+
- AWS_ACCESS_KEY_ID=1
12+
- AWS_SECRET_ACCESS_KEY=1
13+
- AWS_SESSION_TOKEN=1
14+
- DYNAMODB_ENDPOINT_URL=http://dynamodb-local:8000
15+
volumes:
16+
- .:/application
17+
depends_on:
18+
- dynamodb-local
19+
links:
20+
- dynamodb-local
21+
22+
dynamodb-local:
23+
command: "-jar DynamoDBLocal.jar -sharedDb -dbPath ./data"
24+
extends:
25+
service: dynamodb-local
26+
file: docker-compose.ci.yml
27+
volumes:
28+
- "./docker/dynamodb:/home/dynamodblocal/data"
29+
30+
networks:
31+
default:
32+
name: dynamodb-odm-common

docker/xdebug.ini

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[Xdebug]
2+
zend_extension=xdebug.so
3+
4+
xdebug.mode=debug
5+
xdebug.start_with_request=${XDEBUG_START_WITH_REQUEST}
6+
xdebug.remote_connect_back=off
7+
xdebug.discover_client_host =0
8+
xdebug.client_host=${XDEBUG_CLIENT_HOST}
9+
xdebug.remote_handler=dbgp
10+
xdebug.client_port=${XDEBUG_CLIENT_PORT}
11+
12+
xdebug.output_dir = /home/log
13+
14+
xdebug.log=/application/logs/xdebug.log
15+
xdebug.idekey={IDE_KEY}
16+
17+
xdebug.max_nesting_level=1000

0 commit comments

Comments
 (0)