Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deployer deployment #370

Merged
merged 21 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
268 changes: 268 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
stages:
- build
- code quality
- dependency scanning
- test
- deploy

# Cache default configuration
cache: &global_cache
key: "$CI_PIPELINE_ID"
paths:
- node_modules
- public/build
- vendor
- bin
policy: pull


# Build section
Install dependencies and build assets:
image: sumocoders/cli-tools-php82:latest
script:
- COMPOSER_MEMORY_LIMIT=-1 composer install --no-scripts --no-progress
- volta install node
- npm install --no-progress
- npm run build
cache:
<<: *global_cache
policy: pull-push
stage: build
tags:
- docker


# Code Quality section
PHP_CodeSniffer - check code styling:
image: sumocoders/framework-php82:latest
script:
- bin/phpcs --report-full --report-junit=phpcs-report.xml
artifacts:
expire_in: 1 week
reports:
junit: phpcs-report.xml
stage: code quality
needs: ["Install dependencies and build assets"]
tags:
- docker

PHPStan - check for bugs:
image: sumocoders/framework-php82:latest
before_script:
# disable Xdebug and Blackfire extensions
- |
mkdir /usr/local/etc/php/conf.d/disabled
mv /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/disabled/docker-php-ext-xdebug.ini
mv /usr/local/etc/php/conf.d/blackfire.ini /usr/local/etc/php/conf.d/disabled/blackfire.ini
- bin/console cache:warmup --env=dev
script:
- bin/phpstan analyse --memory-limit=-1 --error-format=junit --no-progress > phpstan-report.xml
after_script:
# Run it again so the output is visible in the job
- bin/phpstan analyse --memory-limit=-1 --no-progress
artifacts:
expire_in: 1 week
reports:
junit: phpstan-report.xml
stage: code quality
needs: ["Install dependencies and build assets"]
tags:
- docker

Twigcs - check code styling:
image: sumocoders/framework-php82:latest
script:
- bin/twigcs --no-interaction --exclude=vendor --reporter=junit > twigcs-report.xml
after_script:
# Run it again so the output is visible in the job
- bin/twigcs --no-interaction --exclude=vendor
artifacts:
expire_in: 1 week
reports:
junit: twigcs-report.xml
stage: code quality
needs: ["Install dependencies and build assets"]
tags:
- docker
allow_failure: true

Stylelint - check code styling:
image: sumocoders/cli-tools-php82:latest
script:
- vendor/bin/convert-to-junit-xml convert:stylelint "$(node_modules/.bin/stylelint --formatter=json .)" > stylelint-report.xml
after_script:
# Run it again so the output is visible in the job
- node_modules/.bin/stylelint .
artifacts:
expire_in: 1 week
reports:
junit: stylelint-report.xml
stage: code quality
needs: ["Install dependencies and build assets"]
tags:
- docker
allow_failure: true

StandardJS - check code styling:
image: sumocoders/cli-tools-php82:latest
script:
- bin/convert-to-junit-xml convert:standardjs "$(node_modules/.bin/standard)" > standardjs-report.xml
after_script:
# Run it again so the output is visible in the job
- node_modules/.bin/standard
artifacts:
expire_in: 1 week
reports:
junit: standardjs-report.xml
stage: code quality
needs: ["Install dependencies and build assets"]
tags:
- docker
allow_failure: true

TODOs - check for unfinished code:
image: sumocoders/cli-tools-php82:latest
script:
- >
bin/convert-to-junit-xml convert:grep "$(
find .
-path "./.git/*" -prune -o
-path "./.gitlab-ci.yml" -prune -o
-path "./unresolved-todos-report.xml" -prune -o
-path "./bin/*" -prune -o
-path "./node_modules/*" -prune -o
-path "./public/build/*" -prune -o
-path "./var/*" -prune -o
-path "./vendor/*" -prune -o
-not -type d
-exec grep -niH -E "\b(FIXME|TODO|HACK|REVIEW|QUESTION|TEMP)\b" {} \;
)" > unresolved-todos-report.xml
after_script:
# Run it again so the output is visible in the job
- >
find .
-path "./.git/*" -prune -o
-path "./.gitlab-ci.yml" -prune -o
-path "./unresolved-todos-report.xml" -prune -o
-path "./bin/*" -prune -o
-path "./node_modules/*" -prune -o
-path "./public/build/*" -prune -o
-path "./var/*" -prune -o
-path "./vendor/*" -prune -o
-not -type d
-exec grep -niH -E "\b(FIXME|TODO|HACK|REVIEW|QUESTION|TEMP)\b" {} \;
artifacts:
expire_in: 1 week
reports:
junit: unresolved-todos-report.xml
stage: code quality
needs: ["Install dependencies and build assets"]
tags:
- docker
allow_failure: true


# Dependency Scanning section
NPM packages - check for vulnerabilities:
image: sumocoders/cli-tools-php82:latest
script:
- bin/convert-to-junit-xml convert:npm-audit "$(npm audit --production --json)" > npm-audit-report.xml
after_script:
# Run it again so the output is visible in the job output
- npm audit --production
artifacts:
expire_in: 1 week
reports:
junit: npm-audit-report.xml
stage: dependency scanning
needs: ["Install dependencies and build assets"]
tags:
- docker
allow_failure: true

PHP packages - check for vulnerabilities:
image: sumocoders/cli-tools-php82:latest
before_script:
- 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
script:
- bin/convert-to-junit-xml convert:sensiolabs-security-check "$(./php-security-checker --format=json)" > security-checker-report.xml
after_script:
# Run it again so the output is visible in the job output
- ./php-security-checker
artifacts:
expire_in: 1 week
reports:
junit: security-checker-report.xml
stage: dependency scanning
needs: ["Install dependencies and build assets"]
tags:
- docker
allow_failure: true


# Test section
PHPUnit - Run tests:
image: sumocoders/framework-php82:latest
services:
- mysql:5.7
before_script:
# Uncomment this if you need Chrome for PDF's
# or if you have integration tests that use Symfony Panther (https://github.com/symfony/panther)
# # install Chromium
# - apt-get --allow-releaseinfo-change update && apt-get install -y chromium
# # install Chromium Chromedriver
# - |
# curl -s -f -L -o /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE_97`/chromedriver_linux64.zip
# unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/
# disable Xdebug and Blackfire extensions
- |
mkdir /usr/local/etc/php/conf.d/disabled
mv /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/disabled/docker-php-ext-xdebug.ini
mv /usr/local/etc/php/conf.d/blackfire.ini /usr/local/etc/php/conf.d/disabled/blackfire.ini
script:
#- php bin/console doctrine:migrations:migrate --env=test --no-interaction --allow-no-migration
# Uncomment this if you have fixtures that need to be loaded
# Make sure that you have installed doctrine/doctrine-fixtures-bundle
#- php bin/console doctrine:fixtures:load --env=test
- bin/simple-phpunit --log-junit phpunit-report.xml
artifacts:
reports:
junit: phpunit-report.xml
stage: test
needs: ["Install dependencies and build assets"]
tags:
- docker
variables:
MYSQL_DATABASE: ci_test
MYSQL_ROOT_PASSWORD: root
DATABASE_URL: mysql://root:root@mysql:3306/ci_test?serverVersion=5.7
PANTHER_NO_SANDBOX: 1
PANTHER_WEB_SERVER_PORT: 9080


# Deploy section
Deploy - to staging:
image: sumocoders/cli-tools-php82:latest
before_script:
# Add the private SSH key to the CI environment
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- vendor/bin/dep deploy stage=staging
environment:
name: staging
url: https://forkcms.sumocoders.php82.sumocoders.eu
only:
- staging
stage: deploy
tags:
- docker
variables:
USER: "CI/CD gitlab-runner"
15 changes: 15 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
assets/images/
bin/*
config/*
drivers/*
migrations/*
node_modules/*
public/*
tests/*
translations/*
var/*
vendor/*
*.*
!*.css
!*.scss
Dockerfile
3 changes: 3 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "stylelint-config-standard-scss"
}
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@
"scienta/doctrine-json-functions": "^5.0",
"twig/intl-extra": "^3.3",
"symfony/expression-language": "6.*",
"symfony/lock": "6.*"
"symfony/lock": "6.*",
"tijsverkoyen/convert-to-junit-xml": "^1.10",
"sumocoders/deployer-sumo-forkcms": "^0.2.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "dev-master as 3.6.0",
Expand All @@ -81,10 +83,14 @@
"doctrine/doctrine-fixtures-bundle": "^3.4",
"symfony/stopwatch": "^6.0",
"symfony/web-profiler-bundle": "^6.0",
"symfony/browser-kit": "^6.0"
"symfony/browser-kit": "^6.0",
"friendsoftwig/twigcs": "^6.2"
},
"config": {
"bin-dir": "bin"
"bin-dir": "bin",
"allow-plugins": {
"symfony/flex": true
}
},
"support": {
"forum": "https://fork-cms.herokuapp.com",
Expand Down
Loading
Loading