Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1 - project skeleton #15

Merged
merged 24 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2

[docker-compose.yml]
indent_size = 4
16 changes: 16 additions & 0 deletions .env.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
APP_NAME=escooters
APP_ENV=testing
APP_KEY=base64:WVG2VcHt+a2uzCw7n1tVUBPyw2kof644d6EoYA/UUAg=
APP_DEBUG=false
APP_URL=http://escooters.blumilk.localhost

LOG_CHANNEL=stack
LOG_LEVEL=debug

BROADCAST_DRIVER=log
CACHE_DRIVER=array
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=array
SESSION_LIFETIME=120
MAIL_MAILER=array
46 changes: 46 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
APP_NAME=Escooters
APP_ENV=local
APP_KEY=
kamilpiech97 marked this conversation as resolved.
Show resolved Hide resolved
APP_DEBUG=true
APP_URL=http://escooters.blumilk.localhost

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=pgsql
DB_HOST=escooters-db-dev
DB_PORT=5432
DB_DATABASE=escooters
DB_USERNAME=escooters
DB_PASSWORD=password
DB_ROOT_PASSWORD=example

BROADCAST_DRIVER=log
CACHE_DRIVER=redis
FILESYSTEM_DISK=local
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis
SESSION_LIFETIME=120

REDIS_HOST=escooters-redis-dev
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

# DOCKER
DOCKER_APP_HOST_PORT=3851
DOCKER_INSTALL_XDEBUG=true
DOCKER_DATABASE_HOST_PORT=3853
DOCKER_MAILPIT_DASHBOARD_HOST_PORT=3856
DOCKER_REDIS_HOST_PORT=3852

DOCKER_HOST_USER_ID=1000
38 changes: 38 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
env: {
node: true,
'vue/setup-compiler-macros': true,
},
extends: [
'plugin:vue/base',
'eslint:recommended',
'plugin:vue/vue3-recommended',
'plugin:tailwindcss/recommended',
],
rules: {
semi: ['error', 'never'],
quotes: ['error', 'single'],
indent: ['error', 2],
'block-spacing': ['error', 'always'],
'keyword-spacing': ['error'],
'padding-line-between-statements': [ 'error', {
blankLine: 'always', prev: '*', next: ['return', 'block-like'],
}],
'space-before-blocks': ['error', 'always'],
'eol-last': ['error', 'always'],
'vue/multi-word-component-names': 0,
'vue/first-attribute-linebreak': 0,
'vue/max-attributes-per-line': 0,
'vue/html-indent': ['error', 2],
'comma-dangle': ['error', 'always-multiline'],
'comma-spacing': ['error'],
'key-spacing': ['error'],
'object-curly-spacing': ['error', 'always'],
'tailwindcss/no-custom-classname': 0,
'vue/require-default-prop': 0,
'vue/padding-line-between-blocks': ['error', 'always'],
'vue/component-tags-order': ['error', {
'order': ['script', 'template', 'style'],
}],
},
}
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* text=auto eol=lf

*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php

/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
46 changes: 46 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: 2

updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: monthly
time: "06:30"
timezone: "Europe/Warsaw"
commit-message:
prefix: "- (php) "
target-branch: main
open-pull-requests-limit: 1

- package-ecosystem: npm
directory: "/"
schedule:
interval: monthly
time: "06:30"
timezone: "Europe/Warsaw"
commit-message:
prefix: "- (js) "
target-branch: main
open-pull-requests-limit: 1

- package-ecosystem: github-actions
directory: "/"
schedule:
interval: monthly
time: "06:30"
timezone: "Europe/Warsaw"
commit-message:
prefix: "- (github actions) "
target-branch: main
open-pull-requests-limit: 1

- package-ecosystem: docker
directory: "/environment/dev/app"
schedule:
interval: monthly
time: "06:30"
timezone: "Europe/Warsaw"
commit-message:
prefix: "- (docker dev) "
target-branch: main
open-pull-requests-limit: 1
12 changes: 12 additions & 0 deletions .github/worklflows/check-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Check PR Title
on:
pull_request:
branches: [ "main" ]
types: [opened, edited, synchronize, ready_for_review, reopened]

jobs:
check-pr-title:
name: Check PR title
runs-on: ubuntu-20.04
steps:
- uses: blumilksoftware/[email protected]
39 changes: 39 additions & 0 deletions .github/worklflows/test-and-lint-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test & lint JS codebase
kamilpiech97 marked this conversation as resolved.
Show resolved Hide resolved

on:
pull_request:
branches: [ "main" ]
types: [opened, synchronize, reopened, ready_for_review]
paths:
- '**.js'
- '**.vue'
- 'package.json'
- 'package.lock'

jobs:
test-and-lint-js:
name: Test & lint JS codebase
timeout-minutes: 10
if: github.event.pull_request.draft == false
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3

- name: Cache dependencies
uses: actions/cache@v2
kamilpiech97 marked this conversation as resolved.
Show resolved Hide resolved
with:
path: node_modules
key: ${{ runner.os }}-npm-dependencies-${{ hashFiles('package.lock') }}
restore-keys: ${{ runner.os }}-npm-dependencies

- name: Set up node
uses: actions/setup-node@v3
with:
node-version: 20

- name: Instal npm dependencies
run: npm clean-install

- name: Run JS linter
run: npm run lint
63 changes: 63 additions & 0 deletions .github/worklflows/test-and-lint-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Test & lint PHP codebase
kamilpiech97 marked this conversation as resolved.
Show resolved Hide resolved

on:
pull_request:
branches: [ "main" ]
types: [opened, synchronize, reopened, ready_for_review]
paths:
- '**.php'
- 'composer.json'
- 'composer.lock'
- 'phpunit.xml'
- 'env.ci'

jobs:
test-and-lint-php:
name: Test & lint PHP codebase
timeout-minutes: 10
if: github.event.pull_request.draft == false
runs-on: ubuntu-22.04
services:
pgsql:
image: postgres:15.2-alpine3.17
env:
POSTGRES_DB: escooters
POSTGRES_USER: escooters
POSTGRES_PASSWORD: password
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 3s
--health-timeout 3s
--health-retries 5
ports:
- 5432:5432

steps:
- uses: actions/checkout@v3

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache dependencies
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-composer-dependencies-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-composer-dependencies

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql, intl
coverage: none

- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-suggest

- name: Run PHP linter
run: composer cs

- name: Execute tests
run: php artisan test --env=ci
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/node_modules
/public/hot
/public/storage
/public/js/
/public/css/
/public/mix-manifest.json
/vendor
.env
.env.backup
.phpunit.result.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
google-credentials.json
.idea/
.vscode/
.composer
/public/build/
.appversion
supervisord.pid
59 changes: 59 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
export COMPOSE_DOCKER_CLI_BUILD = 1
export DOCKER_BUILDKIT = 1

include .env

SHELL := /bin/bash

DOCKER_COMPOSE_FILE = docker-compose.yaml
DOCKER_COMPOSE_APP_CONTAINER = app
DOCKER_COMPOSE_DATABASE_CONTAINER = database

CURRENT_USER_ID = $(shell id --user)
CURRENT_USER_GROUP_ID = $(shell id --group)
CURRENT_DIR = $(shell pwd)

TEST_DATABASE_NAME=escooters-test

init: check-env-file
@make build \
&& make run \
&& docker compose --file ${DOCKER_COMPOSE_FILE} exec --user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" ${DOCKER_COMPOSE_APP_CONTAINER} bash "./environment/dev/scripts/init.sh" \
&& make create-test-db

check-env-file:
@if [ ! -f ".env" ]; then \
echo "Create .env file and adjust." ;\
exit 1;\
fi; \

build:
@docker compose --file ${DOCKER_COMPOSE_FILE} build --pull

run:
@docker compose --file ${DOCKER_COMPOSE_FILE} up --detach

stop:
@docker compose --file ${DOCKER_COMPOSE_FILE} stop

restart: stop run

shell:
@docker compose --file ${DOCKER_COMPOSE_FILE} exec --user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" ${DOCKER_COMPOSE_APP_CONTAINER} bash

shell-root:
@docker compose --file ${DOCKER_COMPOSE_FILE} exec ${DOCKER_COMPOSE_APP_CONTAINER} bash

test:
@docker compose --file ${DOCKER_COMPOSE_FILE} exec --user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" ${DOCKER_COMPOSE_APP_CONTAINER} composer test

fix:
@docker compose --file ${DOCKER_COMPOSE_FILE} exec --user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" ${DOCKER_COMPOSE_APP_CONTAINER} bash -c 'composer csf'

queue:
@docker compose --file ${DOCKER_COMPOSE_FILE} exec --user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" ${DOCKER_COMPOSE_APP_CONTAINER} php artisan queue:work

create-test-db:
@docker compose --file ${DOCKER_COMPOSE_FILE} exec ${DOCKER_COMPOSE_DATABASE_CONTAINER} bash -c 'createdb --username=dev ${TEST_DATABASE_NAME} &> /dev/null && echo "Created database for tests (${TEST_DATABASE_NAME})." || echo "Database for tests (${TEST_DATABASE_NAME}) exists."'

.PHONY: init check-env-file build run stop restart shell shell-root test fix create-test-db queue
Loading