Skip to content

Commit

Permalink
[TASK] Optimize Github workflows (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbertsoft authored Apr 2, 2022
1 parent da75661 commit 5257d7a
Show file tree
Hide file tree
Showing 14 changed files with 822 additions and 503 deletions.
548 changes: 548 additions & 0 deletions .github/workflows/continuous-integration.yml

Large diffs are not rendered by default.

67 changes: 45 additions & 22 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
name: Deployment (CD)
name: Deployment Template

on:
push:
branches:
- production
- develop
- stage
workflow_call:
inputs:
php_version:
description: 'PHP version to be used for the deployment.'
default: '8.1'
required: false
type: string
composer_version:
description: 'Composer version to be used for the deployment.'
default: '2'
required: false
type: string

jobs:
deployment:
name: Deployment
print_inputs:
name: Print Inputs
runs-on: ubuntu-latest

steps:
- name: Print the inputs
run: |
echo PHP version: ${{ inputs.php_version }}
echo Composer version: ${{ inputs.composer_version }}
deploy:
name: Deploy
needs:
- print_inputs
runs-on: ubuntu-latest

steps:
- name: Setup SSH Key
env:
Expand All @@ -20,33 +42,34 @@ jobs:
ssh-keygen -p -P "${{ secrets.SSH_PASSPHRASE }}" -N "" -f ~/.ssh/deploy_key
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add ~/.ssh/deploy_key
- uses: actions/checkout@v2
- name: Checkout submodules
shell: bash
run: |
# If your submodules are configured to use SSH instead of HTTPS please uncomment the following line
# git config --global url."https://github.com/".insteadOf "[email protected]:"
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- uses: actions/checkout@v3
name: Checkout
with:
submodules: 'recursive'

- name: Set up PHP Version
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer:v2, andres-montanez/magallanes
php-version: ${{ inputs.php_version }}
tools: composer:${{ inputs.composer_version }}, andres-montanez/magallanes

- name: Get Environment
id: environment
run: |
echo ::set-output name=target::$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//-/g')
- name: Deployment
env:
SSH_AUTH_SOCK: /tmp/ssh-auth.sock
run: |
mkdir -p ./.mage/logs
composer global exec mage deploy ${{ steps.environment.outputs.target }}
- name: Archive Logs
uses: actions/upload-artifact@v1
- name: Upload Logs
uses: actions/upload-artifact@v3
if: always()
with:
name: logs
name: deployment
path: .mage/logs
retention-days: 7
78 changes: 0 additions & 78 deletions .github/workflows/integration.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/manual-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Manual Deployment

on:
workflow_dispatch:
inputs:
php_version:
description: 'PHP version to be used for the deployment.'
default: '8.1'
required: true
type: choice
options:
- '8.1'
- 'latest'
- 'nightly'
composer_version:
description: 'Composer version to be used for the deployment.'
default: '2'
required: true
type: string

jobs:
deployment:
name: Deployment
uses: ./.github/workflows/deployment.yml
with:
php_version: ${{ github.event.inputs.php_version }}
composer_version: ${{ github.event.inputs.composer_version }}
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/.php-cs-fixer.cache
/.phplint-cache
/missing-downloads.yaml
.phpunit.result.cache

###> symfony/framework-bundle ###
/.env.local
Expand All @@ -23,8 +24,3 @@
/var/
/vendor/
###< symfony/framework-bundle ###
###> symfony/phpunit-bridge ###
.phpunit
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###
66 changes: 25 additions & 41 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"source": "https://github.com/TYPO3/get.typo3.org"
},
"require": {
"php": ">=7.4.25",
"php": ">=8.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"ext-json": "*",
Expand Down Expand Up @@ -97,7 +97,6 @@
"symfony/debug-bundle": "5.4.*",
"symfony/maker-bundle": "^1.0",
"symfony/panther": "^1.1.1",
"symfony/phpunit-bridge": "5.4.*",
"symfony/stopwatch": "5.4.*",
"symfony/var-dumper": "5.4.*",
"symfony/web-profiler-bundle": "5.4.*"
Expand All @@ -116,19 +115,14 @@
"symfony/polyfill-php71": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php73": "*",
"symfony/polyfill-php74": "*"
"symfony/polyfill-php74": "*",
"symfony/polyfill-php80": "*",
"symfony/polyfill-php81": "*"
},
"conflict": {
"symfony/symfony": "*"
},
"repositories": {
"local": {
"type": "path",
"url": "packages/*",
"exclude": [
"t3g/symfony-template-bundle"
]
},
"template-bundle": {
"type": "vcs",
"url": "https://github.com/gilbertsoft/symfony-template-bundle"
Expand Down Expand Up @@ -188,7 +182,8 @@
},
"bin": "echo 'bin not installed.'",
"ci": [
"@ci:static"
"@ci:static",
"@ci:dynamic"
],
"ci:composer": [
"@ci:composer:validate",
Expand All @@ -209,31 +204,26 @@
"ci:dynamic": [
"@ci:tests"
],
"ci:json:lint": "jsonlint -q composer.json",
"ci:json:lint": "@php jsonlint -q composer.json",
"ci:php": [
"@ci:php:copypaste",
"@ci:php:lint",
"@ci:php:rector",
"@ci:php:cs-fixer",
"@ci:php:sniff",
"@ci:php:stan",
"@ci:php:cs-fixer"
],
"ci:php:copypaste": "phpcpd src tests",
"ci:php:cs-fixer": "php-cs-fixer fix -v --dry-run --diff",
"ci:php:lint": "phplint --no-progress",
"ci:php:rector": [
"@php simple-phpunit install -c phpunit.xml.dist",
"@php rector process --dry-run --no-progress-bar --no-diffs"
],
"ci:php:sniff": "phpcs --standard=PSR12 src tests",
"ci:php:stan": [
"@php simple-phpunit install -c phpunit.xml.dist",
"@php phpstan analyse --no-progress"
"@ci:php:copypaste",
"@ci:php:stan"
],
"ci:php:copypaste": "@php phpcpd src tests",
"ci:php:cs-fixer": "@php php-cs-fixer fix -v --dry-run --diff",
"ci:php:lint": "@php phplint --no-progress",
"ci:php:rector": "@php rector process --dry-run --no-progress-bar || true",
"ci:php:sniff": "@php phpcs --standard=PSR12 src tests || true",
"ci:php:stan": "@php phpstan analyse --no-progress",
"ci:static": [
"@ci:composer",
"@ci:json:lint",
"@ci:php",
"@ci:yaml:lint"
"@ci:yaml:lint",
"@ci:php"
],
"ci:tests": [
"@ci:tests:php"
Expand All @@ -242,9 +232,9 @@
"@ci:tests:php:unit",
"@ci:tests:php:functional"
],
"ci:tests:php:functional": "simple-phpunit -c phpunit.xml.dist --log-junit var/log/phpunit-functional.xml --testsuite \"Functional Test Suite\"",
"ci:tests:php:unit": "simple-phpunit -c phpunit.xml.dist --log-junit var/log/phpunit-unit.xml --testsuite \"Unit Test Suite\"",
"ci:yaml:lint": "yaml-lint .ddev config",
"ci:tests:php:functional": "@php phpunit -c tests/Functional/phpunit.xml",
"ci:tests:php:unit": "@php phpunit -c tests/Unit/phpunit.xml",
"ci:yaml:lint": "@php yaml-lint .ddev config",
"fix": [
"@fix:composer",
"@fix:php"
Expand All @@ -257,16 +247,10 @@
"@fix:php:rector",
"@fix:php:cs-fixer"
],
"fix:php:cs-fixer": "php-cs-fixer fix",
"fix:php:rector": [
"@php simple-phpunit install -c phpunit.xml.dist",
"@php rector process --no-diffs"
],
"fix:php:cs-fixer": "@php php-cs-fixer fix",
"fix:php:rector": "@php rector process --no-diffs",
"fix:php:sniff": "phpcbf src",
"tools:php:rector": [
"@php simple-phpunit install -c phpunit.xml.dist",
"@php rector process --dry-run"
],
"tools:php:rector": "@php rector process --dry-run",
"tools:setup:clean": "rm -r tools/**/composer.lock tools/**/vendor",
"tools:setup:install": "@composer bin all install --ansi",
"tools:setup:update": "@composer bin all update --ansi"
Expand Down
Loading

0 comments on commit 5257d7a

Please sign in to comment.