Skip to content

Commit

Permalink
Start to setup the CI process
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Ullyott <[email protected]>
  • Loading branch information
Orrison committed Jul 13, 2023
1 parent 377d8b6 commit c545676
Show file tree
Hide file tree
Showing 8 changed files with 426 additions and 15 deletions.
20 changes: 20 additions & 0 deletions .github/actions/composer-dependency-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Setup composer dependencies'
description: 'Sets up composer dependencies for the workflow'
runs:
using: "composite"
steps:
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
shell: bash

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ 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
shell: bash
129 changes: 129 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: CI

on:
workflow_call:
workflow_dispatch:

jobs:
build-deps:
runs-on: ubuntu-22.04

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: "8.2"

- uses: actions/checkout@v3

- name: Setup Dependencies
uses: ./.github/actions/composer-dependency-setup
test:
runs-on: ubuntu-22.04

timeout-minutes: 10

needs: [build-deps]

env:
DB_PORT: 3306
DB_HOST: 127.0.0.1
DB_USERNAME: root
DB_PASSWORD: root
DB_DATABASE: testing
SCOUT_PREFIX: test_
MEILISEARCH_KEY: testing
MEILISEARCH_HOST: http://127.0.0.1:7700
MEILISEARCH_PORT: 7700

services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: ${{ env.DB_PASSWORD }}
MYSQL_DATABASE: ${{ env.DB_DATABASE }}
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

redis:
image: redis
ports:
- 6379:6379
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3

meilisearch:
image: "getmeili/meilisearch:v1.2.0"
ports:
- 7700:7700
options: --health-cmd "wget --no-verbose --spider http://127.0.0.1:7700/health" --health-timeout 5s --health-retries 3

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: "8.2"

- uses: actions/checkout@v3

- name: Start Mysql
run: sudo service mysql start

- name: Create Database
run: mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS testing"

- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"

- name: Setup Dependencies
uses: ./.github/actions/composer-dependency-setup

- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- run: npm install

- name: Build Assets
run: npm run build

- name: Generate key
run: php artisan key:generate

- name: Clear Config
run: php artisan optimize:clear

- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache

- name: Check route integrity
run: php artisan route:list

- name: Execute tests (Unit and Feature tests) via PHPUnit
run: php artisan test --parallel --configuration phpunit-ci.xml --testsuite=Feature,Unit
lint:
runs-on: ubuntu-22.04

timeout-minutes: 10

needs: [build-deps]

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: "8.2"

- uses: actions/checkout@v3

- name: Setup Dependencies
uses: ./.github/actions/composer-dependency-setup

- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- run: npm install

- name: Build Assets
run: npm run build

- name: PHP CS Fixer
run: ./vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --dry-run -v --using-cache=no --stop-on-violation --config=./php-cs-fixer.php
10 changes: 10 additions & 0 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Pull Requests

on:
pull_request:

jobs:
code-checks:
name: Code Checks

uses: ./.github/workflows/ci.yml
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"spatie/laravel-medialibrary": "^10.7"
},
"require-dev": {
"brianium/paratest": "^7.2",
"fakerphp/faker": "^1.9.1",
"friendsofphp/php-cs-fixer": "^3.21",
"laravel/sail": "^1.18",
Expand Down
Loading

0 comments on commit c545676

Please sign in to comment.