Skip to content

Commit

Permalink
Merge pull request #15 from NoCompromises/standards-updates
Browse files Browse the repository at this point in the history
update project standards
  • Loading branch information
aaronsaray committed Dec 18, 2023
2 parents bca0cc9 + 958a074 commit 988495c
Show file tree
Hide file tree
Showing 90 changed files with 14,850 additions and 5,090 deletions.
13 changes: 9 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ APP_URL=https://my-project.test:30080
COMPOSE_PROJECT_NAME=my-project
DOCKER_MYSQL_LOCAL_PORT=33306
DOCKER_NGINX_LOCAL_PORT=30080
DOCKER_REDIS_LOCAL_PORT=36379
DOCKER_SERVER_NAME=my-project.test

SENTRY_LARAVEL_DSN=
SENTRY_TRACES_SAMPLE_RATE=1.0
SENTRY_SEND_DEFAULT_PII=true

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
Expand All @@ -21,15 +26,15 @@ DB_USERNAME=app
DB_PASSWORD=app

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

MEMCACHED_HOST=127.0.0.1

REDIS_HOST=127.0.0.1
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379

Expand Down
25 changes: 25 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": [
"airbnb-base",
"plugin:prettier/recommended",
"plugin:vue/base"
],
"plugins": [
"prettier",
"vue"
],
"rules": {
"prettier/prettier": [
"error"
],
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true
}
]
},
"env": {
"browser": true
}
}
76 changes: 48 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,39 @@ on: push

jobs:
tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

env:
PROJECT_NAME: my-project

steps:
- name: Checkout repo
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Setup default environment
run: cp .env.example .env

- name: Install mkcert
run: sudo apt install libnss3-tools && brew install mkcert && mkcert -install
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Generate test certificate
run: mkcert -cert-file "docker/nginx/ssl.pem" -key-file "docker/nginx/key.pem" "$PROJECT_NAME.test"
- name: Build Docker images
uses: docker/bake-action@v3
with:
load: true
files: |
docker-compose.yml
targets: |
php-fpm
set: |
*.cache-from=type=gha,scope=${{github.ref}}
*.cache-from=type=gha,scope=refs/heads/main
*.cache-to=type=gha,scope=${{github.ref}},mode=max
- name: Build Docker containers and start them
run: docker-compose -f docker-compose.yml up -d
run: docker compose up -d mysql mysql-test php-fpm --wait --no-build

- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}
Expand All @@ -44,40 +54,50 @@ jobs:
docker inspect "$PROJECT_NAME-mysql"
- name: Cache npm dependencies
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: node_modules
key: npm-${{ hashFiles('package-lock.json') }}

- name: Install JS dependencies
run: docker run --rm -e "TERM=xterm-256color" -v $(pwd):/usr/src/app -w /usr/src/app node:16-alpine npm ci && npm run prod
- name: Set up Volta to manage Node/Npm versions
uses: volta-cli/action@v4

# enable this on the project after adding your first test
# - name: Run JS test suite
# run: docker run --rm -e "TERM=xterm-256color" -v $(pwd):/usr/src/app -w /usr/src/app node:16-alpine npm test
- name: Install JS dependencies
run: npm install && npm run build

- name: Cache routes
run: docker exec "$PROJECT_NAME-php-fpm" ./artisan route:cache

- name: Cache views
run: docker exec "$PROJECT_NAME-php-fpm" ./artisan view:cache

- name: Run PHPCS
run: docker exec "$PROJECT_NAME-php-fpm" composer phpcs
- name: Cache Larastan result cache
uses: actions/cache@v3
with:
path: .phpstan.cache
key: "phpstan-result-cache-${{ github.run_id }}" # always unique key - always writes a new cache
restore-keys: | # prefix allows it to use previous cache as starting point
phpstan-result-cache-
- name: Run Larastan
run: docker exec "$PROJECT_NAME-php-fpm" /usr/bin/env sh -c "COMPOSER_MEMORY_LIMIT=-1 composer larastan"
- name: Cache php-cs-fixer result cache
uses: actions/cache@v3
with:
path: .php-cs-fixer.cache
key: "php-cs-fixer-result-cache-${{ github.run_id }}" # always unique key - always writes a new cache
restore-keys: | # prefix allows it to use previous cache as starting point
php-cs-fixer-result-cache-
- name: Run PHP test suite
run: docker exec "$PROJECT_NAME-php-fpm" composer test
- name: Run CI tools
run: docker exec "$PROJECT_NAME-php-fpm" /usr/bin/env sh -c "COMPOSER_MEMORY_LIMIT=-1 composer ci"

# - name: Check logs if you need to debug a failing test
# run: docker exec "$PROJECT_NAME-php-fpm" cat storage/logs/laravel.log
- name: Check logs if you need to debug a failing test
if: ${{ failure() }}
run: docker exec "$PROJECT_NAME-php-fpm" cat storage/logs/laravel.log

# - name: Deploy to staging if develop branch
# if: github.ref == 'refs/heads/develop'
# run: curl -s ${{ secrets.ENVOYER_STAGING_TRIGGER }}
- name: Deploy to staging if develop branch
if: github.ref == 'refs/heads/develop'
run: curl -s ${{ secrets.ENVOYER_STAGING_TRIGGER }}

# - name: Deploy to prod if master branch
# if: github.ref == 'refs/heads/master'
# run: curl -s ${{ secrets.ENVOYER_PROD_TRIGGER }}
- name: Deploy to prod if main branch
if: github.ref == 'refs/heads/main'
run: curl -s ${{ secrets.ENVOYER_PROD_TRIGGER }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
/vendor
.env
.env.backup
.phpstan.cache
.phpunit.result.cache
.php-cs-fixer.cache
auth.json
npm-debug.log
/.idea
Expand Down
5 changes: 5 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

declare(strict_types=1);

return NoCompromises\PhpCsFixer\Config\Factory::create(__DIR__);

0 comments on commit 988495c

Please sign in to comment.