Skip to content

Commit b879ac1

Browse files
Merge pull request #60 from Flutterwave/dev
Performance Optimization and Feature Update
2 parents 77fd11b + b4256b4 commit b879ac1

File tree

141 files changed

+3924
-1693
lines changed

Some content is hidden

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

141 files changed

+3924
-1693
lines changed

.distignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
docker-compose.yml
33
.gitignore
44
.github
5-
.env.example
5+
.env.example
6+
.docker
7+
Makefile

.docker/docker-compose.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
services:
2+
web:
3+
image: nginx:latest
4+
ports:
5+
- "80:80"
6+
volumes:
7+
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
8+
depends_on:
9+
- app
10+
app:
11+
build:
12+
context: .
13+
dockerfile: ./php/Dockerfile
14+
db:
15+
image: mysql:5.7
16+
volumes:
17+
- ./mysql:/var/lib/mysql

.docker/nginx/default.conf

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
root /var/www/html/public;
5+
index index.php;
6+
7+
location ~ \.php$ {
8+
fastcgi_pass app:9000;
9+
fastcgi_index index.php;
10+
fastcgi_param REQUEST_METHOD $request_method;
11+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
12+
include fastcgi_params;
13+
}
14+
15+
location / {
16+
try_files $uri $uri/ /index.php?$query_string;
17+
}
18+
}

.docker/php/Dockerfile

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
FROM php:8.1-fpm-alpine as app
2+
3+
# Useful PHP extension installer image, copy binary into your container
4+
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
5+
6+
# Install php extensions
7+
# exit on errors, exit on unset variables, print every command as it is executed
8+
RUN set -eux; \
9+
install-php-extensions pdo pdo_mysql;
10+
11+
# RUN docker-php-ext-install pdo pdo_mysql
12+
13+
# allow super user - set this if you use Composer as a
14+
# super user at all times like in docker containers
15+
ENV COMPOSER_ALLOW_SUPERUSER=1
16+
17+
# obtain composer using multi-stage build
18+
# https://docs.docker.com/build/building/multi-stage/
19+
COPY --from=composer:2.4 /usr/bin/composer /usr/bin/composer
20+
21+
#Here, we are copying only composer.json and composer.lock (instead of copying the entire source)
22+
# right before doing composer install.
23+
# This is enough to take advantage of docker cache and composer install will
24+
# be executed only when composer.json or composer.lock have indeed changed!-
25+
# https://medium.com/@softius/faster-docker-builds-with-composer-install-b4d2b15d0fff
26+
COPY ./app/composer.* ./
27+
28+
# install
29+
RUN composer install --prefer-dist --no-dev --no-scripts --no-progress --no-interaction
30+
31+
# copy application files to the working directory
32+
COPY ./app .
33+
34+
# run composer dump-autoload --optimize
35+
RUN composer dump-autoload --optimize
36+
37+
# Dev image
38+
# This stage is meant to be target-built into a separate image
39+
# https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
40+
# https://docs.docker.com/compose/compose-file/#target
41+
FROM app as app_dev
42+
43+
# Xdebug has different modes / functionalities. We can default to 'off' and set to 'debug'
44+
# when we run docker compose up if we need it
45+
ENV XDEBUG_MODE=off
46+
47+
# Copy xdebug config file into container
48+
COPY ./php/conf.d/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
49+
50+
# Install xdebug
51+
RUN set -eux; \
52+
install-php-extensions xdebug

.docker/php/conf.d/xdebug.ini

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
xdebug.client_host = 'host.docker.internal'

.github/workflows/change-review.yml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Review changes on Dev (Commits/PRs)
2+
3+
on:
4+
push:
5+
branches: ["dev"]
6+
pull_request:
7+
types:
8+
- opened
9+
10+
jobs:
11+
code-check:
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
fail-fast: true
16+
matrix:
17+
php: [7.4, 8.1, 8.2]
18+
19+
env:
20+
XDEBUG_MODE: coverage
21+
PUBLIC_KEY: ${{ secrets.PUBLIC_KEY }}
22+
SECRET_KEY: ${{ secrets.SECRET_KEY }}
23+
ENCRYPTION_KEY: ${{ secrets.ENCRYPTION_KEY }}
24+
ENV: ${{ secrets.ENV }}
25+
26+
steps:
27+
- uses: actions/checkout@v3
28+
29+
- name: Setup PHP
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: ${{ matrix.php }}
33+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
34+
coverage: xdebug
35+
36+
- name: Validate composer.json and composer.lock
37+
run: composer validate --strict
38+
39+
- name: Cache Composer packages
40+
id: composer-cache
41+
uses: actions/cache@v3
42+
with:
43+
path: vendor
44+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
45+
restore-keys: |
46+
${{ runner.os }}-php-
47+
48+
- name: Install dependencies
49+
run: composer install --prefer-dist --no-progress
50+
51+
- name: 'Create env file'
52+
run: |
53+
touch .env
54+
echo PUBLIC_KEY=${PUBLIC_KEY} >> .env
55+
echo SECRET_KEY=${SECRET_KEY} >> .env
56+
echo ENCRYPTION_KEY=${ENCRYPTION_KEY} >> .env
57+
echo ENV=${ENV} >> .env
58+
ls -a ${{ github.workspace }}
59+
60+
- name: run unit tests and coverage scan
61+
run: ./vendor/bin/pest --coverage --min=20 --coverage-clover ./coverage.xml
62+
63+
- name: Upload to Codecov
64+
uses: codecov/codecov-action@v2
65+
with:
66+
token: ${{ secrets.CODE_COV_TOKEN }}
67+
files: ./coverage.xml
68+
verbose: true
69+
70+
- name: push build status to Slack
71+
uses: 8398a7/action-slack@v3
72+
with:
73+
status: ${{ job.status }}
74+
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took,pullRequest
75+
env:
76+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
77+
MATRIX_CONTEXT: ${{ toJson(matrix) }}
78+
if: always()

.github/workflows/package-publish.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Pre-release
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
check-docs-update:
9+
runs-on: ubuntu-latest
10+
11+
strategy:
12+
fail-fast: true
13+
matrix:
14+
php: [7.4, 8.1, 8.2]
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: technote-space/get-diff-action@v6
19+
with:
20+
PATTERNS: |
21+
+(documentation)/*.md
22+
*.md
23+
CHANGE*.md
24+
FILES: |
25+
CHANGELOG.md
26+
27+
- name: log git diff
28+
run: |
29+
echo ${{ env.GIT_DIFF }}
30+
echo ${{ env.MATCHED_FILES }}
31+
echo ${{ env.GIT_DIFF_FILTERED }}
32+
33+
- name: Check if README.md or Doc/** is updated else exit
34+
if: (env.GIT_DIFF == '')
35+
run: |
36+
echo Update documentation files and README.md before push
37+
exit 1
38+
39+
- name: push build status to Slack
40+
uses: 8398a7/action-slack@v3
41+
with:
42+
status: ${{ job.status }}
43+
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took,pullRequest
44+
env:
45+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
46+
if: always()

.github/workflows/test.yml

-44
This file was deleted.

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,7 @@ examples/*.log
195195
examples/endpoint/*.log
196196
example.php
197197
.phpunit.result.cache
198+
.phpunit.cache
199+
coverage.xml
198200
.env.local
201+
.php-cs-fixer.cache

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## 1.0.4 | 2022-11-06
2+
3+
This release adds support for 7.4 and above. a new workflow for old and new tests.
4+
5+
### Dependency updates and bugfixes
6+
7+
- [ADDED] Support for PHP 7.4 and above
8+
- [ADDED] New workflow for old and new tests

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.PHONY: init
2+
test:
3+
@echo "Installing dependencies..."
4+
@composer install
5+
@echo "Installing dependencies... Done"
6+
@./vendor/bin/pest --coverage --min=0 --coverage-clover ./coverage.xml
7+
8+

0 commit comments

Comments
 (0)