diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml new file mode 100644 index 0000000..65d6a84 --- /dev/null +++ b/.github/workflows/install.yml @@ -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 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..3c4bed9 --- /dev/null +++ b/.github/workflows/main.yml @@ -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 }} diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml new file mode 100644 index 0000000..436f39a --- /dev/null +++ b/.github/workflows/security.yml @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..71d352b --- /dev/null +++ b/.github/workflows/tests.yml @@ -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