Updated CI configuration

This commit is contained in:
Gregorio Chiko Putra 2018-07-30 09:31:58 +07:00
parent eee570125d
commit ed701d9a63
12 changed files with 387 additions and 140 deletions

View File

@ -4,6 +4,6 @@ APP_DEBUG=true
DB_CONNECTION=sqlite
DB_HOST=sqlite
DB_DATABASE=:memory:
DB_DATABASE=/var/tmp/laraland.db
DB_USERNAME=
DB_PASSWORD=

View File

@ -1,13 +1,13 @@
# This file is a template, and might need editing before it works on your project.
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/php
image: registry.waf.or.id/ywa/sarpras:latest
image: registry.waf.or.id/gregorio/laraland:latest
# Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service
services:
# - mysql:latest
- registry.waf.or.id/gregorio/laraland/mariadb:latest
variables:
# MYSQL_DATABASE: laraland
@ -23,14 +23,18 @@ cache:
# This is a basic example for a gem or script which doesn't use
# services such as redis or postgres
before_script:
# Update packages
# - apt-get update -yqq
# Add mariadb hostname to hosts file
- printf "172.17.0.2 mariadb\n" >> /etc/hosts
# Update packages
- apt-get update -yqq
# Upgrade to Node 7
# - curl -sL https://deb.nodesource.com/setup_7.x | bash -
# Install dependencies
# - apt-get install git nodejs libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -yqq
- apt-get install git libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev mysql-client -yqq
# nodejs
# Install php extensions
# - docker-php-ext-install mbstring pdo_mysql curl json intl gd xml zip bz2 opcache
@ -40,8 +44,9 @@ before_script:
# - docker-php-ext-enable xdebug
# Install Composer and project dependencies.
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install
# - curl -sS https://getcomposer.org/installer | php
# - php composer.phar install
- composer install
# Install Node dependencies.
# comment this out if you don't have a node dependency
@ -55,6 +60,9 @@ before_script:
# DB_PASSWORD=secret
- cp .env.testing .env
# Generate database file
- touch /var/tmp/laraland.db
# Run npm build
# comment this out if you don't have a frontend build
# you can change this to to your frontend building script like
@ -67,17 +75,21 @@ before_script:
# Run database migrations.
- php artisan migrate
- php artisan module:migrate
# Run database seed
- php artisan db:seed
# - php artisan db:seed
# - php artisan module:seed
# Generate passport password client
- php artisan passport:client --password --name=laraland
test:
script:
# run laravel tests
# - php vendor/bin/phpunit --coverage-text --colors=never
- php vendor/bin/codeception run acceptance
- php vendor/bin/codeception run functional
- php vendor/bin/codeception run functional -c Modules/Karyawaf
- php vendor/bin/codecept run functional
- php vendor/bin/codecept run functional -c Modules/Karyawaf
# run frontend tests
# if you have any task for testing frontend

84
.gitlab-ci.yml.orig Normal file
View File

@ -0,0 +1,84 @@
# This file is a template, and might need editing before it works on your project.
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/php
image: php:latest
# Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service
services:
- mysql:latest
variables:
MYSQL_DATABASE: laraland
MYSQL_ROOT_PASSWORD: root
# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
paths:
- vendor/
# - node_modules/
# This is a basic example for a gem or script which doesn't use
# services such as redis or postgres
before_script:
# Update packages
- apt-get update -yqq
# Upgrade to Node 7
# - curl -sL https://deb.nodesource.com/setup_7.x | bash -
# Install dependencies
- apt-get install git libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -yqq
# nodejs
# Install php extensions
- docker-php-ext-install mbstring pdo_mysql curl json intl gd xml zip bz2 opcache
# Install & enable Xdebug for code coverage reports
- pecl install xdebug
- docker-php-ext-enable xdebug
# Install Composer and project dependencies.
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install
# Install Node dependencies.
# comment this out if you don't have a node dependency
# - npm install
# Copy over testing configuration.
# Don't forget to set the database config in .env.testing correctly
# DB_HOST=mysql
# DB_DATABASE=project_name
# DB_USERNAME=root
# DB_PASSWORD=secret
- cp .env.testing .env
# Run npm build
# comment this out if you don't have a frontend build
# you can change this to to your frontend building script like
# npm run build
# - npm run dev
# Generate an application key. Re-cache.
- php artisan key:generate
- php artisan config:cache
# Run database migrations.
# - php artisan migrate
# Run database seed
# - php artisan db:seed
test:
script:
# run laravel tests
- php vendor/bin/phpunit --coverage-text --colors=never
# run frontend tests
# if you have any task for testing frontend
# set it in your package.json script
# comment this out if you don't have a frontend test
# - npm test

41
Dockerfile Normal file
View File

@ -0,0 +1,41 @@
FROM debian:stretch
MAINTAINER Gregorio Chiko <gregorio@lepisi.ac.id>
RUN apt-get update && \
apt-get install -y \
apt-transport-https \
lsb-release \
ca-certificates \
curl \
git \
zip \
unzip \
sudo \
wget \
gnupg1
ADD https://packages.sury.org/php/apt.gpg /etc/apt/trusted.gpg.d/php.gpg
RUN sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
RUN chmod 664 /etc/apt/trusted.gpg.d/php.gpg
RUN apt-get update && \
apt-get install -y \
php7.2-fpm \
php7.2-cli \
php7.2-mysql \
php7.2-mbstring \
php7.2-json \
php7.2-sqlite3 \
php7.2-xml \
php7.2-curl \
php7.2-zip \
php7.2-intl \
php7.2-gd \
php7.2-bz2 \
php7.2-opcache
COPY --from=composer:1.5 /usr/bin/composer /usr/bin/composer
RUN php -v && \
git --version && \
composer --version

View File

@ -18,11 +18,15 @@ class KaryawanController extends Controller
*/
public function index()
{
$response = Karyawan::all();
// $response = Karyawan::all();
return response()->json([
'data' => $response
]);
// return response()->json([
// 'data' => $response
// ]);
return responder()
->success(Karyawan::all())
->meta(['count' => Karyawan::count()])
->respond();
}
/**
@ -45,9 +49,12 @@ class KaryawanController extends Controller
$response = Auth::user()->karyawans()->create($validated); // Auth::user()->karyawan->create()
return response()->json([
'data' => $response
]);
// return response()->json([
// 'data' => $response
// ]);
return responder()
->success($response)
->respond();
}
/**
@ -59,9 +66,18 @@ class KaryawanController extends Controller
{
$response = Karyawan::find($id);
return response()->json([
'data' => $response
]);
// return response()->json([
// 'data' => $response
// ]);
if (!$response) {
return responder()
->error('karyawan_error', 'Cannot find `karyawan` with id ' . $id)
->respond();
}
return responder()
->success($response)
->respond();
}
/**
@ -86,9 +102,13 @@ class KaryawanController extends Controller
$karyawan->update($validated);
return response()->json([
'data' => $karyawan
]);
// return response()->json([
// 'data' => $karyawan
// ]);
return responder()
->success($karyawan)
->respond();
}
/**
@ -102,8 +122,12 @@ class KaryawanController extends Controller
$karyawan->delete();
return response()->json([
'message' => 'The data has been deleted'
]);
// return response()->json([
// 'message' => 'The data has been deleted'
// ]);
return responder()
->success(['message' => 'The data has been deleted'])
->respond();
}
}

View File

@ -1,112 +1 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="3Dc6NR7zMHccW4wqadNLF8kfWBGANU0Sm5L6j4lH">
<title>Laravel</title>
<!-- Styles -->
<link href="http://laraland.test/css/app.css" rel="stylesheet">
</head>
<body>
<div id="app">
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<!-- Collapsed Hamburger -->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse" aria-expanded="false">
<span class="sr-only">Toggle Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- Branding Image -->
<a class="navbar-brand" href="http://laraland.test">
Laravel
</a>
</div>
<div class="collapse navbar-collapse" id="app-navbar-collapse">
<!-- Left Side Of Navbar -->
<ul class="nav navbar-nav">
&nbsp;
</ul>
<!-- Right Side Of Navbar -->
<ul class="nav navbar-nav navbar-right">
<!-- Authentication Links -->
<li><a href="http://laraland.test/login">Login</a></li>
<li><a href="http://laraland.test/register">Register</a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Login</div>
<div class="panel-body">
<form class="form-horizontal" method="POST" action="http://laraland.test/login">
<input type="hidden" name="_token" value="3Dc6NR7zMHccW4wqadNLF8kfWBGANU0Sm5L6j4lH">
<div class="form-group">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="" required autofocus>
</div>
</div>
<div class="form-group">
<label for="password" class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password" required>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<div class="checkbox">
<label>
<input type="checkbox" name="remember" > Remember Me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-8 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Login
</button>
<a class="btn btn-link" href="http://laraland.test/password/reset">
Forgot Your Password?
</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Scripts -->
<script src="http://laraland.test/js/app.js"></script>
</body>
</html>
{"status":200,"success":true,"data":{"message":"The data has been removed"}}

View File

@ -169,6 +169,7 @@ return [
*/
Spatie\Permission\PermissionServiceProvider::class,
Nwidart\Modules\LaravelModulesServiceProvider::class,
Flugg\Responder\ResponderServiceProvider::class,
/*
* Application Service Providers...
@ -227,6 +228,8 @@ return [
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Responder' => Flugg\Responder\Facades\Responder::class,
'Transformation' => Flugg\Responder\Facades\Transformation::class,
],

32
config/laravel Normal file
View File

@ -0,0 +1,32 @@
server {
listen 80;
listen [::]:80;
server_name laraland.test;
root /var/www/laraland/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
location /.well-known/acme-challenge/ {
root /var/www/letsencrypt/;
log_not_found off;
}
}

4
config/nginx-start.sh Normal file
View File

@ -0,0 +1,4 @@
#!/bin/bash
cp /opt/etc/nginx.conf /etc/nginx/nginx.conf
sed -i "s/%fpm-ip%/$FPM_PORT_9000_TCP_ADDR/" /etc/nginx/nginx.conf
exec /usr/sbin/nginx

34
config/nginx.conf Normal file
View File

@ -0,0 +1,34 @@
user www-data;
worker_processes 4;
pid /run/nginx.pid;
daemon off;
events {
worker_connections 2048;
multi_accept on;
use epoll;
}
http {
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;
types_hash_max_size 2048;
client_max_body_size 20M;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /dev/stdout;
error_log /dev/stderr;
gzip on;
gzip_disable "msie6";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-available/*.conf;
open_file_cache off; # Disabled for issue 619
charset UTF-8;
}

102
config/responder.php Normal file
View File

@ -0,0 +1,102 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Serializer Class Paths
|--------------------------------------------------------------------------
|
| The full class path to the serializer classes you want to use for both
| success- and error responses. The success serializer must implement
| Fractal's serializer. You can override these for every response.
|
*/
'serializers' => [
'success' => Flugg\Responder\Serializers\SuccessSerializer::class,
'error' => \Flugg\Responder\Serializers\ErrorSerializer::class,
],
/*
|--------------------------------------------------------------------------
| Response Decorators
|--------------------------------------------------------------------------
|
| Response decorators are used to decorate both your success- and error
| responses. A decorator can be disabled by removing it from the list
| below. You may additionally add your own decorators to the list.
|
*/
'decorators' => [
\Flugg\Responder\Http\Responses\Decorators\StatusCodeDecorator::class,
\Flugg\Responder\Http\Responses\Decorators\SuccessFlagDecorator::class,
],
/*
|--------------------------------------------------------------------------
| Fallback Transformer
|--------------------------------------------------------------------------
|
| When transforming data without specifying a transformer we'll instead
| use a fallback transformer specified below. The [ArrayTransformer]
| transformer will simply convert the data to an array untouched.
|
*/
'fallback_transformer' => \Flugg\Responder\Transformers\ArrayTransformer::class,
/*
|--------------------------------------------------------------------------
| Load Relationships With Query String Parameter
|--------------------------------------------------------------------------
|
| The package can automatically load relationships from the query string
| and will look for a query string parameter with the name configured
| below. You can set the value to null to disable the autoloading.
|
*/
'load_relations_parameter' => 'with',
/*
|--------------------------------------------------------------------------
| Filter Fields With Query String Parameter
|--------------------------------------------------------------------------
|
| The package can automatically filter the fields of transformed data
| from a query string parameter configured below. The technique is
| also known as sparse fieldsets. Set it to null to disable it.
|
*/
'filter_fields_parameter' => 'only',
/*
|--------------------------------------------------------------------------
| Recursion Limit
|--------------------------------------------------------------------------
|
| When transforming data, you may be including relations recursively.
| By setting the value below, you can limit the amount of times it
| should include relationships recursively. Five might be good.
|
*/
'recursion_limit' => 5,
/*
|--------------------------------------------------------------------------
| Error Message Translation Files
|--------------------------------------------------------------------------
|
| You can declare error messages in a language file, which allows for
| returning messages in different languages. The array below lists
| the language files that will be searched in to find messages.
|
*/
'error_message_files' => ['errors'],
];

View File

@ -0,0 +1,22 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Error Message Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are used by the Laravel Responder package.
| When it generates error responses, it will search the messages array
| below for any key matching the given error code for the response.
|
*/
'unauthenticated' => 'You are not authenticated for this request.',
'unauthorized' => 'You are not authorized for this request.',
'page_not_found' => 'The requested page does not exist.',
'relation_not_found' => 'The requested relation does not exist.',
'validation_failed' => 'The given data failed to pass validation.',
];