Skip to content

Commit

Permalink
Merge pull request #3 from amosngSP/main
Browse files Browse the repository at this point in the history
Main
  • Loading branch information
amosngSP authored Dec 12, 2021
2 parents 798eb82 + 9d16f03 commit 7c0a829
Show file tree
Hide file tree
Showing 134 changed files with 3,292 additions and 4,261 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ BOOTSTRAP_COLOR_SUCCESS="#18BC9C"
BOOTSTRAP_COLOR_DANGER="#E74C3C"
BOOTSTRAP_COLOR_WARNING="#F39C12"

LARAVEL_PAGE_SPEED_ENABLE=true
ACTIVITY_LOGGER_ENABLED=true
TELESCOPE_ENABLED=false

Expand Down
14 changes: 0 additions & 14 deletions .env.testing

This file was deleted.

1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @daveroverts
44 changes: 44 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# GitHub Action for Laravel with MySQL
name: CD
on:
push:
branches:
- main
jobs:
deploy:
name: Run Deployment
concurrency: production_environment
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP, with composer
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: 8.0
extensions: mbstring

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader --no-dev

- name: Run Deployment [Production]
if: github.ref == 'refs/heads/main'
uses: deployphp/action@master
with:
private-key: ${{ secrets.SSH_PRIVATE_KEY }}
known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
dep: deploy vps1.dutchvacc.nl -v
134 changes: 101 additions & 33 deletions .github/workflows/ci-cd.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# GitHub Action for Laravel with MySQL
name: CI/CD
name: CI
on: [push, pull_request]
jobs:
build-js:
Expand Down Expand Up @@ -30,65 +30,83 @@ jobs:
with:
name: assets
path: public
test-php:
name: Test PHP
test-php-mysql:
name: Test PHP with MySQL
runs-on: ubuntu-latest
env:
DB_DATABASE: laravel
DB_USERNAME: root
DB_PASSWORD: password
BROADCAST_DRIVER: log
# CACHE_DRIVER: redis
# QUEUE_CONNECTION: redis
# SESSION_DRIVER: redis
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: homestead
BUGSNAG_API_KEY: ${{ secrets.BUGSNAG_API_KEY }}
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: laravel
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
# redis:
# image: redis
# ports:
# - 6379/tcp
# options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
matrix:
php-versions: ["8.0"]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: 8.0
php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, fileinfo, mysql
coverage: pcov #optional
coverage: xdebug
tools: phpcs, phpcpd

- name: Start mysql service
run: sudo /etc/init.d/mysql start

- name: Get composer dev cache directory
id: composer-dev-cache
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ steps.composer-dev-cache.outputs.dir }}
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Prepare the application
run: |
php -r "file_exists('.env') || copy('.env.testing', '.env');"
php -r "file_exists('.env') || copy('.env.example', '.env');"
php artisan key:generate
- name: Clear Config
run: php artisan config:clear

- name: Run Migration
run: php artisan migrate -v
env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
# REDIS_PORT: ${{ job.services.redis.ports['6379'] }}

- name: Test with phpunit
run: vendor/bin/phpunit
run: vendor/bin/phpunit --coverage-text
env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
# REDIS_PORT: ${{ job.services.redis.ports['6379'] }}

- name: PHP_CodeSniffer
run: phpcs --extensions=php app
Expand All @@ -98,27 +116,56 @@ jobs:

- name: Enlightn Security Checker
run: php vendor/enlightn/security-checker/security-checker security:check composer.lock
deploy:
name: Run Deployment
concurrency: production_environment
if: github.ref == 'refs/heads/main'
test-php-postgresql:
name: Test PHP with PostgreSQL
runs-on: ubuntu-latest
env:
BROADCAST_DRIVER: log
# CACHE_DRIVER: redis
# QUEUE_CONNECTION: redis
# SESSION_DRIVER: redis
DB_CONNECTION: pgsql
DB_HOST: localhost
DB_PASSWORD: postgres
DB_USERNAME: postgres
DB_DATABASE: postgres
services:
postgres:
image: postgres:14.1
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432/tcp
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
# redis:
# image: redis
# ports:
# - 6379/tcp
# options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
matrix:
php-versions: ["8.0"]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP, with composer
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: 8.0
extensions: mbstring
php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, fileinfo, pgsql
coverage: xdebug
tools: phpcs, phpcpd

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
Expand All @@ -127,12 +174,33 @@ jobs:
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader --no-dev
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Run Deployment [Production]
if: github.ref == 'refs/heads/main'
uses: deployphp/action@master
with:
private-key: ${{ secrets.SSH_PRIVATE_KEY }}
known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
dep: deploy vps1.dutchvacc.nl -v
- name: Prepare the application
run: |
php -r "file_exists('.env') || copy('.env.example', '.env');"
php artisan key:generate
- name: Clear Config
run: php artisan config:clear

- name: Run Migration
run: php artisan migrate -v
env:
DB_PORT: ${{ job.services.postgres.ports[5432] }}
# REDIS_PORT: ${{ job.services.redis.ports['6379'] }}

- name: Test with phpunit
run: vendor/bin/phpunit --coverage-text
env:
DB_PORT: ${{ job.services.postgres.ports[5432] }}
# REDIS_PORT: ${{ job.services.redis.ports['6379'] }}

- name: PHP_CodeSniffer
run: phpcs --extensions=php app

- name: Copy/Paste Detector
run: phpcpd app/ --min-lines=50

- name: Enlightn Security Checker
run: php vendor/enlightn/security-checker/security-checker security:check composer.lock
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ _ide_helper*\.php

\.phpstorm\.meta\.php

.phpunit.result.cache
htdocs

.lando.yml
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Added [protonemedia/laravel-form-components](https://github.com/protonemedia/laravel-form-components) for all forms. Bootstrap 4 stuff have been published and changed to support custom forms (for Bootswatch Flatly) as much as possible. The only one I didn't change was input file.
- All strings (the ones I looked at) while adding laravel-form-components are now translatable.
- Added `EventCleanupReservations` job + command
- Added ability to delete bookings, in case you screwed up import, and want to do that again.

### Changed
- Changed some flash messages.
- Lots of old migrations that I screwed up back when I started this project in 2018

### Removed
- Removed (renatomarinho/laravel-page-speed)[https://github.com/renatomarinho/laravel-page-speed] as it gave to too many headaches, and I always just disabled it because of that.
- Removed `BookingController removeOverdueReservations()`, replaced by `EventCleanupReservationsJob`
- Dropped support for PHP 7.4

## [v2.2.5](https://github.com/daveroverts/bmac/compare/v2.2.4a...v2.2.5) - 2021-11-14

### Changed
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ When testing or running this project locally, Vatsim wants your to use their Con

## Installation

Before you begin, make sure you have a server with PHP (at least 7.3, 8 recommended) to run everything on. For local development, I use [Laravel Valet](https://laravel.com/docs/8.x/valet), and before that I used [Laravel Homestead](https://laravel.com/docs/master/homestead).
Before you begin, make sure you have a server with PHP 8 to run everything on. For local development, I use [Laravel Valet](https://laravel.com/docs/8.x/valet), and before that I used [Laravel Homestead](https://laravel.com/docs/master/homestead).

1. Clone the project

```bash
git clone https://github.com/daveroverts/bmac.git
git clone -b main https://github.com/daveroverts/bmac.git
```

2. Go to the project directory
Expand Down Expand Up @@ -120,7 +120,18 @@ Before you begin, make sure you have a server with PHP (at least 7.3, 8 recommen
7. If you want to include all airports to the database, navigate to `admin/airports/import` (be sure you're logged in as admin). Depending on your setup, this might take a little while, and you won't get a confirmation that import has been done.
The script uses [this](https://github.com/jpatokal/openflights/blob/master/data/airports.dat) file as source. Note that at the time of writing, the file was last edited 13 May 2019.


## Queue worker / Laravel Horizon
If you're not using `sync` as `QUEUE_CONNECTION`, you need to run a queue worker, or else things like emails aren't being sent. Check Laravel documentation on how to set one up using Supervisor <https://laravel.com/docs/master/queues#supervisor-configuration>

When you're using `redis` as `QUEUE_CONNECTION`, [Laravel Horizon](https://laravel.com/docs/master/horizon) is already installed and can be used to start a queue worker.

## Task scheduler

You need to add a cron entry to run `php artisan schedule:run` every minute. Example can be found below.

```bash
* * * * * cd /bmac && php artisan schedule:run >> /dev/null 2>&1
```

More info can be found here: <https://laravel.com/docs/master/scheduling#running-the-scheduler>
Loading

0 comments on commit 7c0a829

Please sign in to comment.