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

Reusable workflows #23

Merged
merged 1 commit into from
May 3, 2024
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
99 changes: 99 additions & 0 deletions .github/workflows/reusable-codeception-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: "Codeception tests"

on:
workflow_call:
secrets:
COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN:
required: true
SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER:
required: true

jobs:
codeception-tests:
name: "Codeception tests"
runs-on: "ubuntu-20.04"
continue-on-error: ${{ matrix.experimental }}
env:
PIMCORE_TEST_DB_DSN: "mysql://root@127.0.0.1:33006/pimcore_test?serverVersion=${{ matrix.server_version }}"
strategy:
matrix:
include:
- {
php-version: 8.1,
database: "mariadb:10.7",
server_version: "10.7.7-MariaDB-1:10.7.7+maria~ubu2004",
dependencies: highest,
experimental: false,
}
- {
php-version: 8.2,
database: "mariadb:10.7",
server_version: "10.7.7-MariaDB-1:10.7.7+maria~ubu2004",
dependencies: highest,
experimental: false,
}
- {
php-version: 8.2,
database: "mariadb:10.7",
server_version: "10.7.7-MariaDB-1:10.7.7+maria~ubu2004",
dependencies: highest,
pimcore_version: "11.x-dev as 11.99.9",
experimental: true,
}

services:
mariadb:
image: "${{ matrix.database }}"
ports:
- 33006:3306
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
steps:
- name: "Checkout code"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: imagick
ini-values: display_errors=On, display_startup_errors=On, error_reporting=32767
php-version: "${{ matrix.php-version }}"

- name: Verify MariaDB connection
run: |
cp .github/ci/files/.my.cnf ~/.my.cnf
while ! mysqladmin ping --silent; do
sleep 1
done
- name: "Setup Pimcore environment"
run: |
mysql -e "CREATE DATABASE pimcore_test CHARSET=utf8mb4;"
chmod 755 .github/ci/scripts/setup-pimcore-environment.sh
.github/ci/scripts/setup-pimcore-environment.sh

- name: Install SSH Key # this is necessary for Composer to be able to clone source from pimcore/ee-pimcore
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }}
known_hosts: ".... we add this in the next step ;-)"

- name: "Add authentication for private pimcore packages"
run: |
composer config repositories.private-packagist composer https://repo.pimcore.com/github-actions/
composer config --global --auth http-basic.repo.pimcore.com github-actions ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}

- name: "Update Pimcore version"
env:
PIMCORE_VERSION: "${{ matrix.pimcore_version }}"
run: |
if [ ! -z "$PIMCORE_VERSION" ]; then
composer require --no-update pimcore/pimcore:"${PIMCORE_VERSION}"
fi
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"

- name: "Run Codeception"
run: "vendor/bin/codecept run -c . -vvv --xml"
25 changes: 25 additions & 0 deletions .github/workflows/reusable-php-style.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "PHP Style check"

on:
workflow_call:
inputs:
head_ref:
required: true
type: string

jobs:
php-cs-fixer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.head_ref }}

- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga:2.19.0
with:
args: --config=.php_cs.dist --allow-risky yes

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply php-cs-fixer changes
17 changes: 17 additions & 0 deletions .github/workflows/reusable-poeditor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Trigger POEditor Translations Export"

on:
workflow_call:
secrets:
POEDITOR_ACTION_TRIGGER_TOKEN:
required: true

jobs:
poeditor:
runs-on: ubuntu-latest
steps:
- name: Trigger workflow in pimcore/poeditor-export-action
env:
GH_TOKEN: ${{ secrets.POEDITOR_ACTION_TRIGGER_TOKEN }}
run: |
gh workflow run -R pimcore/poeditor-export-action poeditor-export.yaml
71 changes: 71 additions & 0 deletions .github/workflows/reusable-static-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: "Static Analysis with PHPStan"

on:
workflow_call:
secrets:
COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN:
required: true
SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER:
required: true

jobs:
static-analysis-phpstan:
name: "Static Analysis with PHPStan"
runs-on: "ubuntu-20.04"
strategy:
matrix:
include:
- { php-version: "8.1", dependencies: "lowest", experimental: false }
- { php-version: "8.2", dependencies: "highest", experimental: false }
- {
php-version: "8.2",
dependencies: "highest",
pimcore_version: "11.x-dev as 11.99.9",
experimental: true,
}
steps:
- name: "Checkout code"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
- name: Install SSH Key # this is necessary for Composer to be able to clone source from pimcore/ee-pimcore
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }}
known_hosts: ".... we add this in the next step ;-)"
- name: "Add authentication for private pimcore packages"
run: |
composer config repositories.private-packagist composer https://repo.pimcore.com/github-actions/
composer config --global --auth http-basic.repo.pimcore.com github-actions ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}
- name: "Setup Pimcore environment"
run: |
.github/ci/scripts/setup-pimcore-environment.sh
- name: "Update Pimcore version"
env:
PIMCORE_VERSION: "${{ matrix.pimcore_version }}"
run: |
if [ ! -z "$PIMCORE_VERSION" ]; then
composer require --no-update pimcore/pimcore:"${PIMCORE_VERSION}"
fi
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"

- name: "Run a static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan analyse --memory-limit=-1"

- name: "Generate baseline file"
if: ${{ failure() }}
run: "vendor/bin/phpstan analyse --memory-limit=-1 --generate-baseline"

- name: "Upload baseline file"
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: phpstan-baseline.neon
path: phpstan-baseline.neon