Skip to content

Continuous Integration #136

Continuous Integration

Continuous Integration #136

Workflow file for this run

name: Continuous Integration
on:
push:
branches:
- master
pull_request:
schedule:
- cron: '33 2 * * 1' # weekly, on Monday morning
env:
MAILER_DSN: null://null
ILIOS_LOCALE: en
ILIOS_SECRET: ThisTokenIsNotSoSecretChangeIt
ILIOS_FILE_SYSTEM_STORAGE_PATH: /tmp
SYMFONY_DEPRECATIONS_HELPER: disabled=1
MESSENGER_TRANSPORT_DSN: doctrine://default
latest_php: 8.3
DOCKER_BUILDKIT: 1
jobs:
code_style:
name: Code Style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use PHP ${{ env.latest_php }}
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ env.latest_php }}
extensions: apcu
- name: install dependencies
run: composer install --no-interaction --prefer-dist
- name: lint PHP
run: vendor/bin/phpcs
- name: lint twig
run: bin/console lint:twig templates custom
- name: phpstan
run: |
bin/console cache:warmup --env=test
vendor/bin/phpstan analyse --no-progress
tests:
name: PHPUnit Tests
needs: code_style
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [8.2, 8.3]
steps:
- uses: actions/checkout@v4
- name: Use PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
coverage: pcov
php-version: ${{ matrix.php-version }}
extensions: apcu
- name: install dependencies
run: composer install --no-interaction --prefer-dist
- name: Run Tests
run: vendor/bin/phpunit --coverage-clover build/coverage.xml
- name: Archive Coverage Report
uses: actions/upload-artifact@v3
with:
name: coverage-output
path: build/coverage.xml
retention-days: 1
test_migrations_against_mysql:
name: Test Migrations Against MySQL
needs: code_style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use PHP ${{ env.latest_php }}
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ env.latest_php }}
extensions: apcu
- name: install dependencies
run: composer install --no-interaction --prefer-dist
- name: Drop, Create, Migrate, and Validate DB
env:
ILIOS_DATABASE_URL: mysql://root:[email protected]:3306/ilios?serverVersion=8.0
run: |
sudo systemctl start mysql.service
bin/console doctrine:database:drop --if-exists --force
bin/console doctrine:database:create
bin/console doctrine:migrations:migrate --no-interaction
bin/console doctrine:schema:validate
run_twice:
name: PHPUnit Run Twice
needs: code_style
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [8.2, 8.3]
steps:
- uses: actions/checkout@v4
- name: Use PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-version }}
extensions: apcu
- name: install dependencies
run: composer install --no-interaction --prefer-dist
- name: First Run
run: vendor/bin/phpunit --group twice
- name: Second Run
run: vendor/bin/phpunit --group twice
build_amd_containers:
name: Build Containers (amd64)
needs: code_style
runs-on: ubuntu-latest
strategy:
matrix:
image:
- php-apache
- nginx
- fpm
- fpm-dev
- admin
- update-frontend
- consume-messages
- mysql
- mysql-demo
- opensearch
- redis
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build ${{ matrix.image }}
uses: docker/build-push-action@v5
with:
build-args: ILIOS_VERSION=test
target: ${{ matrix.image }}
push: false
outputs: type=docker,dest=/tmp/${{ matrix.image }}.tar
tags: ${{ matrix.image }}:testing
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.image }}-image
path: /tmp/${{ matrix.image }}.tar
retention-days: 1
build_arm_containers:
name: Build Containers (arm64)
needs: code_style
runs-on: ubuntu-latest
strategy:
matrix:
image:
- php-apache
- nginx
- fpm
- fpm-dev
- admin
- update-frontend
- consume-messages
- mysql
- mysql-demo
- opensearch
- redis
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build ${{ matrix.image }}
uses: docker/build-push-action@v5
with:
build-args: ILIOS_VERSION=test
target: ${{ matrix.image }}
push: false
run_containers:
name: Run and Test Containers
needs: build_amd_containers
runs-on: ubuntu-latest
env:
ILIOS_DATABASE_URL: mysql://root:[email protected]:3306/ilios?serverVersion=8.0
ILIOS_SECRET: DifferentSecret
ILIOS_FILE_SYSTEM_STORAGE_PATH: /tmp
steps:
- uses: actions/checkout@v4
- name: Drop, Create Database to use everywhere else
run: |
sudo systemctl start mysql.service
mysql -uroot -proot -e "DROP DATABASE IF EXISTS ilios"
mysql -uroot -proot -e "CREATE DATABASE ilios"
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: /tmp/
- name: Load Images
run: |
docker load --input /tmp/php-apache-image/php-apache.tar
docker load --input /tmp/nginx-image/nginx.tar
docker load --input /tmp/fpm-image/fpm.tar
docker load --input /tmp/fpm-dev-image/fpm-dev.tar
docker load --input /tmp/admin-image/admin.tar
docker load --input /tmp/update-frontend-image/update-frontend.tar
docker load --input /tmp/consume-messages-image/consume-messages.tar
docker load --input /tmp/mysql-image/mysql.tar
docker load --input /tmp/mysql-demo-image/mysql-demo.tar
docker load --input /tmp/opensearch-image/opensearch.tar
docker load --input /tmp/redis-image/redis.tar
docker image ls -a
- name: Consume Messages
run: |
docker run -d --name ilios-consume-messages -e ILIOS_SECRET -e ILIOS_DATABASE_URL -e ILIOS_FILE_SYSTEM_STORAGE_PATH consume-messages:testing
docker ps | grep -q ilios-consume-messages
- name: Apache PHP
run: |
docker run -d --name ilios-php-apache -e ILIOS_SECRET -e ILIOS_DATABASE_URL -e ILIOS_FILE_SYSTEM_STORAGE_PATH php-apache:testing
docker ps | grep -q ilios-php-apache
docker exec ilios-php-apache php /var/www/ilios/bin/console monitor:health
- name: Nginx
run: |
docker run -d --name ilios-nginx nginx:testing
sleep 15
docker ps --filter "health=healthy" | grep -q ilios-nginx
- name: FPM
run: |
docker run -d --name ilios-fpm -e ILIOS_SECRET -e ILIOS_DATABASE_URL -e ILIOS_FILE_SYSTEM_STORAGE_PATH fpm:testing
docker ps | grep -q ilios-fpm
docker exec ilios-fpm php bin/console monitor:health
- name: FPM Dev
run: |
docker run -d --name ilios-fpm-dev -e ILIOS_SECRET -e ILIOS_DATABASE_URL -e ILIOS_FILE_SYSTEM_STORAGE_PATH fpm-dev:testing
docker ps | grep -q ilios-fpm-dev
docker exec ilios-fpm-dev php bin/console monitor:health
- name: Admin
run: |
docker run -d --name ilios-admin admin:testing
docker ps | grep -q ilios-admin
- name: MySQL
run: |
docker run -d --name ilios-mysql mysql:testing
docker ps | grep -q ilios-mysql
- name: MySQL Demo
run: |
docker run -d --name ilios-mysql-demo mysql-demo:testing
docker ps | grep -q ilios-mysql-demo
- name: OpenSearch
run: |
docker run -d --name ilios-opensearch opensearch:testing
docker ps | grep -q ilios-opensearch
- name: REdis
run: |
docker run -d --name ilios-redis redis:testing
docker ps | grep -q ilios-redis
- name: Output Docker Logs
if: failure()
run: |
docker logs ilios-php-apache
docker logs ilios-nginx
docker logs ilios-fpm
docker logs ilios-fpm-dev
docker logs ilios-admin
docker logs ilios-update-frontend
docker logs ilios-consume-messages
docker logs ilios-mysql
docker logs ilios-mysql-demo
docker logs ilios-opensearch
docker logs ilios-redis
check_setup_command:
name: Setup Command
needs: code_style
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [8.2, 8.3]
steps:
- uses: actions/checkout@v4
- name: Use PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-version }}
extensions: apcu
- name: Run Setup Command
run: bin/setup
check_update_frontend_command:
name: Update Frontend Command
needs: code_style
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [8.2, 8.3]
steps:
- uses: actions/checkout@v4
- name: Use PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-version }}
extensions: apcu
- name: install dependencies
run: composer install --no-interaction --prefer-dist
- name: Run Update Frontend
run: bin/console ilios:update-frontend
coverage:
name: Upload Code Coverage
runs-on: ubuntu-latest
if: ${{ always() }}
needs: tests
steps:
- uses: actions/checkout@v4
- name: Download Coverage Report
uses: actions/download-artifact@v3
with:
name: coverage-output
- run: ls -lh coverage.xml
- name: Upload to CodeClimate
uses: paambaati/[email protected]
with:
coverageLocations:
coverage.xml:clover
env:
CC_TEST_REPORTER_ID: c2e072c72320901c23741e4c25bfd28e149441b5a19ba9abb8cf80ca0363ff9a