Skip to content

Commit

Permalink
Install API Platform (BeWelcome#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentchalamon authored Nov 29, 2020
1 parent b073b52 commit da0714c
Show file tree
Hide file tree
Showing 92 changed files with 7,840 additions and 3,045 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ indent_size = 2

[.github/*/*.yml]
indent_size = 2

[*.feature]
indent_size = 2
11 changes: 11 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ DB_USER=bewelcome
DB_PASS=bewelcome
DB_PORT=3306

APP_REFRESH_TOKEN_TTL=600

###> symfony/framework-bundle ###
APP_ENV=dev
# Set secret in .env.local
Expand Down Expand Up @@ -33,3 +35,12 @@ MAILER_DSN=smtp://mailer:25

LOCALES=ar,bg,ca,cs,da,de,el,en,eo,es,eu,fa,fi,fr,hi,hr,hu,id,it,ja,lt,lv,nb,nl,no,pl,pt,pt-BR,rm,ro,ru,sk,sl,sr,su,sw,tr,zh-Hans,zh-Hant

###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
###< nelmio/cors-bundle ###

###> lexik/jwt-authentication-bundle ###
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
JWT_PASSPHRASE=02567efd63a56b25644e9b52815ce880
###< lexik/jwt-authentication-bundle ###
7 changes: 7 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
DATABASE_URL=mysql://root:bewelcome_root_dev@db:3306/bewelcome-test
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private-test.pem
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public-test.pem
JWT_PASSPHRASE=A2706413B33785537E7421AC51D62C46
241 changes: 235 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
name: CI

on:
# Run CI every night at 2am
schedule:
- cron: 0 2 * * *
# Run CI on every Pull Request
pull_request:
# Run CI only on push on bootstrap4 branch
push:
branches:
- bootstrap4

jobs:
phpcpd:
Expand All @@ -16,7 +24,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: 7.3
php-version: 7.4
extensions: curl, dom, gd, iconv, intl, json, libxml, mbstring, mysqli, pcntl, pdo_mysql, phar, tokenizer, xdebug, xml, xmlwriter, xsl, zip

- name: Get Composer Cache Directory
Expand Down Expand Up @@ -48,7 +56,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: 7.3
php-version: 7.4
extensions: curl, dom, gd, iconv, intl, json, libxml, mbstring, mysqli, pcntl, pdo_mysql, phar, tokenizer, xdebug, xml, xmlwriter, xsl, zip

- name: Get Composer Cache Directory
Expand All @@ -68,6 +76,83 @@ jobs:
- name: Run phpunit tests
run: bin/phpunit

- name: Run phpunit tests
run: phpdbg -qrr bin/phpunit --coverage-text --coverage-xml=build/logs/phpunit/coverage-xml --coverage-clover=build/logs/phpunit/clover.xml --log-junit=build/logs/phpunit/junit.xml --colors=never

- name: Run Infection tests
run: vendor/bin/infection --only-covered --coverage=build/logs/phpunit --min-covered-msi=85 --threads=30

- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: infection.log
path: infection.log

behat:
name: Behat
runs-on: ubuntu-latest
strategy:
fail-fast: false
env:
MAILER_DSN: 'smtp://localhost:1025'
DATABASE_URL: 'mysql://bewelcome:bewelcome@127.0.0.1:3306/bewelcome'
APP_ENV: 'test'
services:
mailcatcher:
image: tophfr/mailcatcher
ports:
- 1080:80
- 1025:25
db:
image: mariadb:10.1.41
env:
MYSQL_ROOT_PASSWORD: bewelcome_root_dev
MYSQL_DATABASE: bewelcome
MYSQL_USER: bewelcome
MYSQL_PASSWORD: bewelcome
ports:
- 3306:3306
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: 7.4
extensions: curl, dom, gd, iconv, intl, json, libxml, mbstring, mysqli, pcntl, pdo_mysql, phar, tokenizer, xdebug, xml, xmlwriter, xsl, zip

- name: Setup NODE
uses: actions/setup-node@v2-beta
with:
node-version: '12'

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

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install project dependencies
run: |
yarn install --frozen-lock
composer install --prefer-dist --no-progress --no-suggest --no-interaction --no-scripts
- name: Prepare test database
run: |
yarn encore production
bin/console doctrine:database:create --env=test --if-not-exists
bin/console doctrine:schema:create --env=test
bin/console hautelook:fixtures:load --env=test --no-interaction
- name: Run behat tests
run: vendor/bin/behat --profile localhost --colors --tags='~@wip'

phploc:
name: PHPLoc
runs-on: ubuntu-latest
Expand All @@ -80,7 +165,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: 7.3
php-version: 7.4
extensions: curl, dom, gd, iconv, intl, json, libxml, mbstring, mysqli, pcntl, pdo_mysql, phar, tokenizer, xdebug, xml, xmlwriter, xsl, zip

- name: Get Composer Cache Directory
Expand Down Expand Up @@ -112,7 +197,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: 7.3
php-version: 7.4
extensions: curl, dom, gd, iconv, intl, json, libxml, mbstring, mysqli, pcntl, pdo_mysql, phar, tokenizer, xdebug, xml, xmlwriter, xsl, zip

- name: Get Composer Cache Directory
Expand Down Expand Up @@ -144,7 +229,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: 7.3
php-version: 7.4
extensions: curl, dom, gd, iconv, intl, json, libxml, mbstring, mysqli, pcntl, pdo_mysql, phar, tokenizer, xdebug, xml, xmlwriter, xsl, zip

- name: Get Composer Cache Directory
Expand Down Expand Up @@ -176,7 +261,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: 7.3
php-version: 7.4
extensions: curl, dom, gd, iconv, intl, json, libxml, mbstring, mysqli, pcntl, pdo_mysql, phar, tokenizer, xdebug, xml, xmlwriter, xsl, zip

- name: Get Composer Cache Directory
Expand All @@ -195,3 +280,147 @@ jobs:

- name: Run php-code-sniffer tests
run: vendor/bin/phpcs --colors --warning-severity=Error

lint-yaml:
name: Lint YAML
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: 7.4
extensions: curl, dom, gd, iconv, intl, json, libxml, mbstring, mysqli, pcntl, pdo_mysql, phar, tokenizer, xdebug, xml, xmlwriter, xsl, zip

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

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install project dependencies
run: composer install --prefer-dist --no-progress --no-suggest --no-interaction --no-scripts

- name: Run Linter
run: bin/console lint:yaml --parse-tags config fixtures

doctrine-schema-validator:
name: Validate Doctrine schema
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: 7.4
extensions: curl, dom, gd, iconv, intl, json, libxml, mbstring, mysqli, pcntl, pdo_mysql, phar, tokenizer, xdebug, xml, xmlwriter, xsl, zip

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

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install project dependencies
run: composer install --prefer-dist --no-progress --no-suggest --no-interaction --no-scripts

- name: Validate Doctrine schema
run: bin/console doctrine:schema:validate --skip-sync

swagger:
name: Swagger validator
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: 7.4
extensions: curl, dom, gd, iconv, intl, json, libxml, mbstring, mysqli, pcntl, pdo_mysql, phar, tokenizer, xdebug, xml, xmlwriter, xsl, zip

- name: Setup NODE
uses: actions/setup-node@v2-beta

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

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install project dependencies
run: |
composer install --prefer-dist --no-progress --no-suggest --no-interaction --no-scripts
yarn install --frozen-lock
- name: Export Swagger documentation
run: bin/console api:swagger:export > swagger.json

- name: Validate Swagger documentation
run: yarn swagger-cli validate swagger.json

security:
name: Security checks
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: 7.4
extensions: curl, dom, gd, iconv, intl, json, libxml, mbstring, mysqli, pcntl, pdo_mysql, phar, tokenizer, xdebug, xml, xmlwriter, xsl, zip

- name: Setup NODE
uses: actions/setup-node@v2-beta

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

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install project dependencies
run: |
composer install --prefer-dist --no-progress --no-suggest --no-interaction --no-scripts
yarn install --frozen-lock
- name: Run PHP security checker
run: vendor/bin/security-checker security:check

- name: Run JS security checker
run: yarn audit
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ phploc.xml
/public/main.js.map
/public/service-worker.js
/public/service-worker.js.map
/swagger.json

# deployer config
/config/deployer.yml
Expand All @@ -54,14 +55,19 @@ phploc.xml
/.php_cs
/.php_cs.cache
###< friendsofphp/php-cs-fixer ###

###> symfony/phpunit-bridge ###
.phpunit
/phpunit.xml
/build
.phpunit.result.cache
###< symfony/phpunit-bridge ###

###> symfony/webpack-encore-bundle ###
/node_modules/
/public/build/
/public/main.js*
/public/service-worker.js*
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###
Expand All @@ -70,3 +76,12 @@ yarn-error.log
/.phpcs-cache
/phpcs.xml
###< squizlabs/php_codesniffer ###

###> lexik/jwt-authentication-bundle ###
/config/jwt/*.pem
!/config/jwt/*-test.pem
###< lexik/jwt-authentication-bundle ###

###> friends-of-behat/symfony-extension ###
/behat.yml
###< friends-of-behat/symfony-extension ###
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ before_install:
- sudo mysql -u root -e 'FLUSH PRIVILEGES;'

install:
- yarn
- yarn install --frozen-lock
- composer install --no-interaction --ignore-platform-reqs --no-scripts

script:
Expand Down
Loading

0 comments on commit da0714c

Please sign in to comment.