Skip to content

Merge pull request #303 from Games-of-Switzerland/feature/update-php-… #578

Merge pull request #303 from Games-of-Switzerland/feature/update-php-…

Merge pull request #303 from Games-of-Switzerland/feature/update-php-… #578

Workflow file for this run

name: Continuous Integration & Continuous Deployment
on: [push]
env:
COMPOSE_DOCKER_CLI_BUILD: 1
DOCKER_BUILDKIT: 1
jobs:
phpcs:
name: phpcs
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
tools: composer:v2, phpcs, cs2pr
- uses: actions/checkout@v4
- run: composer install --prefer-dist
- run: ./vendor/bin/phpcs --report=checkstyle | cs2pr
php-deprecation-detector:
name: php-deprecation-detector
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
tools: psalm, composer:v2
- uses: actions/checkout@v4
- run: cd tools/php-deprecation-detector && composer install --prefer-dist
# PHP 8.2 is not already supported by this tools:
# @see https://github.com/wapmorgan/PhpDeprecationDetector/issues/73
- run: ./tools/php-deprecation-detector/vendor/bin/phpdd --target 8.1 \
--file-extensions php,module,inc,install,test,profile,theme,info \
./web/modules/custom
- run: ./tools/php-deprecation-detector/vendor/bin/phpdd --target 8.1 --file-extensions php ./behat
php-cs-fixer:
name: php-cs-fixer
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
tools: php-cs-fixer, cs2pr, composer:v2
- uses: actions/checkout@v4
- run: cd tools/php-cs-fixer && composer install --prefer-dist
- run: ./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --using-cache=no --dry-run --format=checkstyle | cs2pr
phpstan:
name: phpstan
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
tools: phpstan, cs2pr, composer:v2
- uses: actions/checkout@v4
- run: composer install
- run: ./vendor/bin/phpstan analyse ./web/modules/custom ./behat --error-format=checkstyle | cs2pr
psalm:
name: psalm
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
tools: psalm, composer:v2
- uses: actions/checkout@v4
- run: composer install --prefer-dist
- run: cd tools/psalm && composer install --prefer-dist
- run: ./tools/psalm/vendor/bin/psalm --output-format=github --no-cache
upgrade-status:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker compose -f docker-compose.yml -f docker-compose.ci.yml pull --include-deps test browser elasticsearch
- name: Build the docker compose stack
run: |
docker compose -f docker-compose.yml -f docker-compose.ci.yml build --build-arg user=$(id -u) --build-arg group=$(id -g) test
mkdir -p ./log ./backups
- name: Run the docker stack
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml up -d test browser elasticsearch
- name: Bootstrap
run: docker compose exec -T test docker-as-wait db:3306 elasticsearch:9200 -- docker-as-drupal bootstrap
- name: Enable upgrade status
run: docker compose exec -T test docker-as-wait db:3306 -- ./vendor/bin/drush en upgrade_status -y
- name: Run upgrade status
run: docker compose exec -T test docker-as-wait db:3306 -- /var/www/vendor/bin/drush upgrade_status:analyze --ignore-contrib --ignore-uninstalled --all
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker compose -f docker-compose.yml -f docker-compose.ci.yml pull --include-deps test
- name: Build the docker compose stack
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml up --build -d test
- name: Run unit tests
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml exec -T test docker-as-wait db:3306 test:80 -- docker-as-drupal phpunit --skip-default-stops --group=gos --exclude-group=gos_functional
# functional-tests:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - run: docker compose -f docker-compose.yml -f docker-compose.ci.yml pull --include-deps test browser elasticsearch
# - name: Build the docker compose stack
# run: |
# docker compose -f docker-compose.yml -f docker-compose.ci.yml up --build -d test browser elasticsearch
# mkdir -p ./log ./backups
# - name: Bootstrap
# run: docker compose -f docker-compose.yml -f docker-compose.ci.yml exec -T test docker-as-wait db:3306 elasticsearch:9200 -- docker-as-drupal bootstrap --install-only
# - name: Run Functional tests
# run: docker compose -f docker-compose.yml -f docker-compose.ci.yml exec -T test docker-as-wait db:3306 test:80 browser:4444 elasticsearch:9200 -- docker-as-drupal phpunit --skip-default-stops --group=gos_functional --user=www-data
# - name: Upload Artifact
# uses: actions/upload-artifact@v4
# if: failure()
# with:
# path: ./log
behat-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker compose -f docker-compose.yml -f docker-compose.ci.yml pull --include-deps test browser elasticsearch
- name: Build the docker compose stack
run: |
docker compose -f docker-compose.yml -f docker-compose.ci.yml build --build-arg user=$(id -u) --build-arg group=$(id -g) test
mkdir -p ./log ./backups
- name: Run the docker stack
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml up -d test browser elasticsearch
- name: Bootstrap
run: docker compose exec -T test docker-as-wait db:3306 elasticsearch:9200 -- docker-as-drupal bootstrap --force --with-default-content
- name: Warmup Elasticsearch
run: |
docker compose exec -T test docker-as-wait db:3306 elasticsearch:9200 -- /var/www/vendor/bin/drush eshd -y
docker compose exec -T test docker-as-wait db:3306 elasticsearch:9200 -- /var/www/vendor/bin/drush eshs
docker compose exec -T test docker-as-wait db:3306 elasticsearch:9200 -- /var/www/vendor/bin/drush eshr
docker compose exec -T test docker-as-wait db:3306 elasticsearch:9200 -- /var/www/vendor/bin/drush queue:run elasticsearch_helper_indexing
- name: Run Behat tests
run: docker compose exec -T test docker-as-wait db:3306 test:80 browser:4444 -- docker-as-drupal behat --skip-db-reset --skip-default-content
- name: Upload Artifact
uses: actions/upload-artifact@v4
if: failure()
with:
path: ./log
deploy_prod:
name: Deploy to Production
needs: [phpcs, php-cs-fixer, phpstan, psalm, unit-tests, behat-tests]
environment:
name: Production
url: https://api.swissgames.garden
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
env:
PRIVATE_SSH_KEY: ${{ secrets.PRIVATE_SSH_KEY }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/deploy
with:
stage: production
ssh_private_key: ${{ secrets.PRIVATE_SSH_KEY }}
deploy_staging:
name: Deploy to Staging
needs: [phpcs, php-cs-fixer, phpstan, psalm, unit-tests, behat-tests]
environment:
name: Staging
url: https://staging-api.swissgames.garden
if: github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
env:
PRIVATE_SSH_KEY: ${{ secrets.PRIVATE_SSH_KEY }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/deploy
with:
stage: staging
ssh_private_key: ${{ secrets.PRIVATE_SSH_KEY }}