Skip to content

Commit

Permalink
Improve instructons and update packages and workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
curtisdelicata committed Jun 10, 2024
1 parent 9698119 commit b9e6bb6
Show file tree
Hide file tree
Showing 4 changed files with 211 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Install

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:

install:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'


- name: Start database
run: sudo /etc/init.d/mysql start

- name: Create database
run: mysql -e "CREATE DATABASE IF NOT EXISTS liberu;" -uroot -proot

- name: Copy environment file
run: cp .env.testing .env

- name: Install dependencies
run: composer install

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

- name: Run database migrations
run: php artisan migrate

- name: Seed database
run: php artisan db:seed

- name: Install npm dependencies
run: npm install

- name: Build frontend assets
run: npm run build
48 changes: 48 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Docker

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
deployment:
workflow_dispatch:

env:
DB_DATABASE: liberu
DB_USERNAME: liberu
DB_PASSWORD: secret

jobs:
docker:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

-
name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
with:
images: liberu/genealogy

-
# Setting up Docker Buildx with docker-container driver is required
# at the moment to be able to use a subdirectory with Git context
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push Docker image
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0
with:
# context: "{{defaultContext}}:.docker/prod/app/"
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
56 changes: 56 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
deployment:
workflow_dispatch:

env:
DB_DATABASE: liberu
DB_USERNAME: liberu
DB_PASSWORD: secret

jobs:

phpcpd:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: 'Run Phpcpd'
run: |
sudo composer install
sudo test -f phpcpd.phar || curl -L https://phar.phpunit.de/phpcpd.phar -o phpcpd.phar
sudo php phpcpd.phar app/
php-insights:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: 'Run php-insight'
run: |
sudo composer install
sudo php artisan insights --min-quality=90 --min-complexity=90 --min-architecture=80 --min-style=90 --no-interaction
security:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: 'Run php-insight'
run: |
PHP_SC_VERSION=$(curl -s "https://api.github.com/repos/fabpot/local-php-security-checker/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/;s/^v//')
curl -LSs https://github.com/fabpot/local-php-security-checker/releases/download/v${PHP_SC_VERSION}/local-php-security-checker_${PHP_SC_VERSION}_linux_amd64 > ./php-security-checker
chmod +x ./php-security-checker
unset PHP_SC_VERSION
./php-security-checker
54 changes: 54 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:

tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'


- name: Start database
run: sudo /etc/init.d/mysql start

- name: Create database
run: mysql -e "CREATE DATABASE IF NOT EXISTS liberu;" -uroot -proot

- name: Copy environment file
run: cp .env.testing .env

- name: Install dependencies
run: composer install

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

- name: Run database migrations
run: php artisan migrate

- name: Seed database
run: php artisan db:seed

- name: Run tests
run: vendor/bin/phpunit --coverage-clover=coverage.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
run: vendor/bin/phpunit --coverage-clover=coverage.xml

0 comments on commit b9e6bb6

Please sign in to comment.