Skip to content

Commit

Permalink
Update workflows, setup.sh and env.testing
Browse files Browse the repository at this point in the history
  • Loading branch information
curtisdelicata committed Jun 13, 2024
1 parent 0654a43 commit fbabdb6
Show file tree
Hide file tree
Showing 6 changed files with 349 additions and 117 deletions.
70 changes: 70 additions & 0 deletions .env.testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
APP_NAME=Liberu
APP_ENV=testing
APP_KEY=base64:GS0VwCqzgSVBnM0Wz/Ig610q86M+GIvyVmzQQvrL7Xw=
APP_DEBUG=true
APP_URL=http://localhost

OWNER_COMPANY_ID=1
DB_TENANT_DATABASE=tenant

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=liberu
DB_USERNAME=root
DB_PASSWORD=root

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
SESSION_DRIVER=file
SESSION_LIFETIME=120

CACHE_LIFETIME=60

LOGIN_ATTEMPTS_PER_MINUTE=5
PASSWORD_LIFETIME=0
PASSWORD_MIN_LENGTH=6
PASSWORD_MIXED_CASE=0
PASSWORD_NUMERIC=0
PASSWORD_SPECIAL=0

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=log
MAIL_HOST=
MAIL_PORT=
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

MAILGUN_DOMAIN=
MAILGUN_SECRET=
MAILGUN_ENDPOINT=api.mailgun.net

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

SENTRY_LARAVEL_DSN=

TELESCOPE_ENABLED=0
SCOUT_DRIVER=null

ENSO_API_TOKEN=

TINY_MCE_API_KEY=

SANCTUM_STATEFUL_DOMAINS=localhost,127.0.0.1,127.0.0.1:8000,127.0.0.1:3000,localhost:3000,localhost:8080,::1
53 changes: 53 additions & 0 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Install

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:

install:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'


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

- name: Create database
run: mysql -e "CREATE DATABASE IF NOT EXISTS liberu;" -uroot -proot

- name: Copy environment file
run: cp .env.testing .env

- name: Install dependencies
run: composer install

- name: Generate application key
run: php artisan key:generate

- name: Run database migrations
run: php artisan migrate

- name: Seed database
run: php artisan db:seed

- name: Install npm dependencies
run: npm install

- name: Build frontend assets
run: npm run build
122 changes: 5 additions & 117 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: CI
name: Docker

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]
deployment:
workflow_dispatch:

Expand All @@ -14,118 +14,6 @@ env:
DB_PASSWORD: secret

jobs:
yarn:
runs-on: ubuntu-22.04
env:
NODE_OPTIONS: --max_old_space_size=3072
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
SENTRY_URL: ${{ secrets.SENTRY_URL }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '14'
- uses: borales/actions-yarn@v4
with:
cmd: install
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: 'test node'
run: node -v
- name: 'install & build'
run: |
sudo composer install
sed -i 's/GOOGLE_ANALITICS_TOKEN/${{ secrets.GOOGLE_ANALITICS_TOKEN }}/g' resources/views/stubs/production-index.blade.stub
sudo cp -f resources/views/stubs/production-index.blade.stub vendor/laravel-liberu/core/stubs
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: resources
path: |
public/css/
public/js/
public/images/
resources/views
phpunit:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: 'PhpUnit'
run: |
sudo composer install
sudo php artisan test
phpcpd:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: 'Run Phpcpd'
run: |
sudo composer install
sudo test -f phpcpd.phar || curl -L https://phar.phpunit.de/phpcpd.phar -o phpcpd.phar
sudo php phpcpd.phar app/
php-insights:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: 'Run php-insight'
run: |
sudo composer install
sudo php artisan insights --min-quality=90 --min-complexity=90 --min-architecture=80 --min-style=90 --no-interaction
security:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: 'Run php-insight'
run: |
PHP_SC_VERSION=$(curl -s "https://api.github.com/repos/fabpot/local-php-security-checker/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/;s/^v//')
curl -LSs https://github.com/fabpot/local-php-security-checker/releases/download/v${PHP_SC_VERSION}/local-php-security-checker_${PHP_SC_VERSION}_linux_amd64 > ./php-security-checker
chmod +x ./php-security-checker
unset PHP_SC_VERSION
./php-security-checker
migration:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: mirromutth/[email protected]
with:
mysql database: ${{env.DB_DATABASE}}
mysql user: ${{env.DB_USERNAME}}
mysql password: ${{env.DB_PASSWORD}}
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: 'Run migration'
run: |
sudo composer install
php artisan migrate --force
deploy:
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'deployment' || github.event_name == 'push' }}
needs: [phpunit, phpcpd, migration, yarn, security, php-insights]
steps:
- uses: actions/checkout@v4
- name: 'Trig envoyer'
run: |
curl ${{ secrets.DEPLOY_WEBHOOK }}
docker:
if: github.event_name == 'push'
runs-on: ubuntu-latest
Expand All @@ -151,10 +39,10 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Build and push Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0
with:
# context: "{{defaultContext}}:.docker/prod/app/"
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
56 changes: 56 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
deployment:
workflow_dispatch:

env:
DB_DATABASE: liberu
DB_USERNAME: liberu
DB_PASSWORD: secret

jobs:

phpcpd:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: 'Run Phpcpd'
run: |
sudo composer install
sudo test -f phpcpd.phar || curl -L https://phar.phpunit.de/phpcpd.phar -o phpcpd.phar
sudo php phpcpd.phar app/
php-insights:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: 'Run php-insight'
run: |
sudo composer install
sudo php artisan insights --min-quality=90 --min-complexity=90 --min-architecture=80 --min-style=90 --no-interaction
security:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: 'Run php-insight'
run: |
PHP_SC_VERSION=$(curl -s "https://api.github.com/repos/fabpot/local-php-security-checker/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/;s/^v//')
curl -LSs https://github.com/fabpot/local-php-security-checker/releases/download/v${PHP_SC_VERSION}/local-php-security-checker_${PHP_SC_VERSION}_linux_amd64 > ./php-security-checker
chmod +x ./php-security-checker
unset PHP_SC_VERSION
./php-security-checker
54 changes: 54 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:

tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'


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

- name: Create database
run: mysql -e "CREATE DATABASE IF NOT EXISTS liberu;" -uroot -proot

- name: Copy environment file
run: cp .env.testing .env

- name: Install dependencies
run: composer install

- name: Generate application key
run: php artisan key:generate

- name: Run database migrations
run: php artisan migrate

- name: Seed database
run: php artisan db:seed

- name: Run tests
run: vendor/bin/phpunit --coverage-clover=coverage.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
run: vendor/bin/phpunit --coverage-clover=coverage.xml
Loading

0 comments on commit fbabdb6

Please sign in to comment.