Lion-Helpers (CI Workflow) #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Lion-Helpers (CI Workflow) | |
on: | |
push: | |
branches: | |
- actions-sleon | |
- actions-saco | |
pull_request: | |
branches: | |
- main | |
schedule: | |
- cron: "15 0 * * *" | |
jobs: | |
composer-validation: | |
runs-on: ubuntu-latest | |
name: Composer Validation | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Cache Composer dependencies | |
uses: actions/cache@v3 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-composer | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.4' | |
extensions: mbstring, gd, zip | |
- name: Composer Validate | |
run: composer validate --strict | |
- name: Composer Check for vulnerabilities | |
run: composer audit --locked | |
- name: Composer Install | |
run: composer install | |
- name: Composer Dump-Autoload | |
run: composer dump-autoload --optimize --strict-psr | |
docker-validation: | |
runs-on: ubuntu-latest | |
name: Docker Validation | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Validate Docker Compose configuration | |
run: docker compose config | |
code-analyze: | |
runs-on: ubuntu-latest | |
name: PHP Code Analyze | |
needs: | |
- composer-validation | |
- docker-validation | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.4' | |
extensions: mbstring, gd, zip | |
- name: Composer Install | |
run: composer install | |
- name: PHP CodeSnifer (Src) | |
run: php -d memory_limit=-1 vendor/bin/phpcs --standard=PSR12 src | |
- name: PHPStan (Src) | |
run: php -d memory_limit=-1 vendor/bin/phpstan --level=max analyse src | |
tests: | |
runs-on: ubuntu-latest | |
name: PHP Tests | |
needs: code-analyze | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Tear down containers | |
run: docker compose down --volumes --remove-orphans | |
- name: Stop running Docker containers (if any) | |
run: | | |
docker ps -q | xargs -r docker stop | |
docker ps -aq | xargs -r docker rm | |
- name: Build the Docker image | |
run: docker build -t helpers-app . | |
- name: Start services using Docker Compose | |
run: | | |
docker compose -f docker-compose.yml up -d | |
env: | |
COMPOSE_PROJECT_NAME: test | |
- name: Install Composer dependencies | |
run: docker exec helpers-app composer install | |
- name: Run PHP Tests | |
run: docker exec helpers-app php vendor/bin/phpunit |