diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index 839de13..2585689 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -2,9 +2,15 @@ name: Laravel on: push: +<<<<<<< HEAD + branches: [ main ] + pull_request: + branches: [ main ] +======= branches: [ main, dev ] pull_request: branches: [ main, dev ] +>>>>>>> 1b8fcd5fedf783df346660b0bbcf2aa16822bbce jobs: laravel-tests: @@ -17,6 +23,45 @@ jobs: php-version: '8.0' - uses: actions/checkout@v2 +<<<<<<< HEAD + - name: Copy .env + run: php -r "file_exists('.env') || copy('.env.test', '.env');" + - name: Cache Composer dependencies + uses: actions/cache@v2 + with: + path: /tmp/composer-cache + key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + - name: Install Dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + - name: Generate key + run: php artisan key:generate + - name: Directory Permissions + run: chmod -R 777 storage bootstrap/cache + - name: Create Database + run: | + mkdir -p database + touch database/database.sqlite + - name: Execute tests (Unit and Feature tests) via PHPUnit + env: + DB_CONNECTION: sqlite + DB_DATABASE: database/database.sqlite + run: vendor/bin/phpunit + + # This job is to cache the node modules in order to reduce the time it would take to run + - name: Use cached node_modules + uses: actions/setup-node@v2 + with: + directory: zc_plugin_expenses + + #this job installs intalls yarn dependencies on the github runner + #and also to build the static files that would be transferred to server later + - name: Install dependencies + run: | + npm install + npm run production +======= +>>>>>>> 1b8fcd5fedf783df346660b0bbcf2aa16822bbce - name: Git Pull on Server uses: appleboy/ssh-action@master @@ -27,8 +72,28 @@ jobs: # key: ${{ secrets.SSHKEY }} script: | cd /var/www/expenses.zuri.chat +<<<<<<< HEAD + sudo rm composer.lock + sudo rm package-lock.json + git pull origin dev + git branch -r + git stash + composer install + npm install + + # this job copies the build folder from GitHub runners to the server with sftp, make sure the paths are correct + - name: copy build to server + uses: Creepios/sftp-action@v1.0.1 + with: + username: ${{ secrets.USERNAME }} + host: ${{ secrets.ZURI_HOST }} + password: ${{ secrets.PASSWORD }} + localPath: './zc_plugin_expenses/webpack.mix.js' + remotePath: '/var/www/expenses.zuri.chat' +======= git stash git pull origin git branch -r composer install yarn +>>>>>>> 1b8fcd5fedf783df346660b0bbcf2aa16822bbce diff --git a/app/Http/Controllers/AboutController.php b/app/Http/Controllers/AboutController.php index e3e59ce..013eebb 100644 --- a/app/Http/Controllers/AboutController.php +++ b/app/Http/Controllers/AboutController.php @@ -6,14 +6,24 @@ class AboutController extends Controller { - public function show(){ - $about = [ - 'plugin_name' => 'zuri expenses', + public function showPluginInfo() { + $pluginInfo = [ + 'name' => 'Expenses Plugin', 'version' => '1.0', - 'team_name' => 'team_grange', - 'information' => 'This describes information about the expenses', + 'description' => [ + 'zuri.chat Plugin', + 'A plugin to track expenses' + ], + 'scaffold_structure' => 'Monolith', + 'team' => 'HNG-8.0/Expenses Team', + 'ping_url' => 'https://expenses.zuri.chat/api/ping', + // 'html_url' => 'https:', + // 'sidebar_url' => '', ]; - - return response()->json($about, 200); + return response()->json([ + 'status' => 'success', + 'type' => 'Plugin Information', + 'plugin_info' => $pluginInfo + ], 200); } } diff --git a/app/Http/Controllers/PingController.php b/app/Http/Controllers/PingController.php index 4fdb600..7ad7afd 100644 --- a/app/Http/Controllers/PingController.php +++ b/app/Http/Controllers/PingController.php @@ -6,12 +6,7 @@ class PingController extends Controller { - public function index(){ - $result=[ - "status"=>200, - "message" => "Successful", - "data" => "UP" - ]; - return json_encode($result); - } + public function ping() { + return response()->json(['message' => 'Server is live!'], 200); + } } diff --git a/routes/api.php b/routes/api.php index 9cb23b4..6eade8c 100644 --- a/routes/api.php +++ b/routes/api.php @@ -4,12 +4,14 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; use App\Http\Controllers\AboutController; +use App\Http\Controllers\PingController; use App\Http\Controllers\ListApi; use App\Http\Controllers\ExpenseController; use App\Http\Controllers\RoomController; use App\Http\Controllers\RoomMemberController; + /* |-------------------------------------------------------------------------- | API Routes @@ -30,7 +32,7 @@ Route::get('/sidebarlist', [SidebarAPI::class, 'sidebar']); }); -// Expense List endpoints +// Expense List endpoints Route::prefix('v1')->group(function () { Route::resource("list", "ListApi"); }); @@ -65,6 +67,10 @@ // Organization Endpoints +// plugin info related endpoints +Route::get('/info', [AboutController::class, 'showPluginInfo']); +Route::get('/ping', [PingController::class, 'ping']); +