diff --git a/.env.ci b/.env.ci new file mode 100644 index 000000000000..8e4c86eb2051 --- /dev/null +++ b/.env.ci @@ -0,0 +1,15 @@ +APP_NAME="Invoice Ninja" +APP_ENV=local +APP_KEY= +APP_DEBUG=true +APP_URL=http://ninja.test +DB_CONNECTION=db-ninja-01 +DB_DATABASE1=ninja +MULTI_DB_ENABLED=false +# database +DB_HOST1=localhost +DB_PORT1=3306 +DB_USERNAME1=root +DB_PASSWORD1=ninja +NINJA_ENVIRONMENT=selfhost +COMPOSER_AUTH='{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}' diff --git a/.env.example b/.env.example index 4e5111f6f60d..41da546e1f3b 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,7 @@ APP_NAME="Invoice Ninja" APP_ENV=local APP_KEY= -APP_DEBUG=true +APP_DEBUG=false APP_URL=http://localhost @@ -25,7 +25,7 @@ DEMO_MODE=false BROADCAST_DRIVER=log LOG_CHANNEL=stack CACHE_DRIVER=file -QUEUE_CONNECTION=sync +QUEUE_CONNECTION=database SESSION_DRIVER=file SESSION_LIFETIME=120 @@ -49,4 +49,9 @@ API_SECRET=superdoopersecrethere ERROR_EMAIL= NINJA_ENVIRONMENT=selfhost -HASH_SALT= \ No newline at end of file + +SELF_UPDATER_REPO_VENDOR = invoiceninja +SELF_UPDATER_REPO_NAME = invoiceninja +SELF_UPDATER_USE_BRANCH = v2 +SELF_UPDATER_MAILTO_ADDRESS = user@example.com +SELF_UPDATER_MAILTO_NAME = "John Doe" diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml new file mode 100644 index 000000000000..a2142ddcd5be --- /dev/null +++ b/.github/workflows/phpunit.yml @@ -0,0 +1,56 @@ +on: + push: + branches: + - v2 + +name: phpunit +jobs: + phpunit: + runs-on: ubuntu-latest + + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: ninja + MYSQL_DATABASE: ninja + ports: + - 33306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - uses: actions/checkout@v1 + with: + ref: v2 + fetch-depth: 1 + + - name: Copy .env + run: | + cp .env.ci .env + + - name: Install composer dependencies + run: | + composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} + composer install + + - name: Prepare Laravel Application + run: | + php artisan key:generate + php artisan optimize + + - name: Prepare JS/CSS assets + run: | + npm i + npm run production + + - name: Create DB and schemas + run: | + mkdir -p database + touch database/database.sqlite + + - name: Migrate Database + run: | + php artisan migrate:fresh --seed --force && php artisan db:seed --class=RandomDataSeeder --force + + - name: Run Testsuite + run: vendor/bin/phpunit --testdox diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000000..e08996be68a7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,66 @@ +on: + release: + types: [released] + +#on: +# push: +# branches: +# - v2 + +name: Upload Release Asset + +jobs: + build: + name: Upload Release Asset + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v1 + with: + ref: v2 + + - name: Install composer dependencies + run: | + composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} + composer install + + - name: Prepare Laravel Application + run: | + cp .env.example .env + php artisan key:generate + php artisan optimize + php artisan storage:link + + - name: Prepare JS/CSS assets + run: | + npm i + npm run production + + - name: Build project # This would actually build your project, using zip for an example artifact + run: | + zip -r ./invoiceninja.zip ./ + + - name: Get tag name + id: get_tag_name + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.get_tag_name.outputs.VERSION }} + release_name: Release ${{ steps.get_tag_name.outputs.VERSION }} + draft: false + prerelease: false + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./invoiceninja.zip + asset_name: invoiceninja.zip + asset_content_type: application/zip diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 68d37db4b768..80c2f209086a 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -13,6 +13,7 @@ namespace App\Console; use App\Jobs\Cron\RecurringInvoicesCron; use App\Jobs\Util\VersionCheck; +use App\Utils\Ninja; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; @@ -35,15 +36,17 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - // $schedule->command('inspire') - // ->hourly(); - + //$schedule->job(new RecurringInvoicesCron)->hourly(); $schedule->job(new VersionCheck)->daily(); /* Build queue snapshots */ $schedule->command('horizon:snapshot')->everyFiveMinutes(); + /* Run queue's in shared hosting with this*/ + if(Ninja::isSelfHost()) + $schedule->command('queue:work')->everyMinute()->withoutOverlapping(); + } /** diff --git a/app/Http/Controllers/UserProfileController.php b/app/Http/Controllers/UserProfileController.php deleted file mode 100644 index ccd750e8c6f6..000000000000 --- a/app/Http/Controllers/UserProfileController.php +++ /dev/null @@ -1,98 +0,0 @@ -method() . ' - ' . $request->url() . ": $count queries - " . $time); + Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time); // if($count > 50) // Log::info($queries);