Skip to content

Commit

Permalink
Merge pull request #523 from pimcore/Switch-to-reusable-workflows-for…
Browse files Browse the repository at this point in the history
…-codeception,-php-style,-poeditor-export-and-static-analysis

Switch to reusable workflows for codeception, php-style, poedit…
  • Loading branch information
herbertroth authored Jul 4, 2024
2 parents 98eb1e8 + 034ddf8 commit db01841
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 157 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/codeception.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: "Codeception Tests centralised"

on:
workflow_dispatch:
push:
branches:
- "[0-9]+.[0-9]+"
- "[0-9]+.x"
- "feature-*"
pull_request:
types: [opened, synchronize, reopened]

env:
PIMCORE_PROJECT_ROOT: ${{ github.workspace }}
PRIVATE_REPO: ${{ github.event.repository.private }}

jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
php_versions: ${{ steps.parse-php-versions.outputs.php_versions }}
matrix: ${{ steps.set-matrix.outputs.matrix }}
private_repo: ${{ env.PRIVATE_REPO }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Checkout reusable workflow repo
uses: actions/checkout@v4
with:
repository: pimcore/workflows-collection-public
ref: main
path: reusable-workflows

- name: Parse PHP versions from composer.json
id: parse-php-versions
run: |
if [ -f composer.json ]; then
php_versions=$(jq -r '.require.php' composer.json | grep -oP '\d+\.\d+' | tr '\n' ',' | sed 's/,$//')
if [ -z "$php_versions" ]; then
echo "No PHP versions found in composer.json"
echo "Setting default PHP value"
echo "php_versions=default" >> $GITHUB_OUTPUT
else
echo "php_versions=$php_versions" >> $GITHUB_OUTPUT
echo "#### php versions #### : $php_versions"
fi
else
echo "composer.json not found"
exit 1
fi
- name: Set up matrix
id: set-matrix
run: |
php_versions="${{ steps.parse-php-versions.outputs.php_versions }}"
MATRIX_JSON=$(cat reusable-workflows/codeception-tests-configuration/matrix-config.json)
IFS=',' read -ra VERSIONS_ARRAY <<< "$php_versions"
FILTERED_MATRIX_JSON=$(echo $MATRIX_JSON | jq --arg php_versions "$php_versions" '
{
matrix: [
.configs[] |
select(.php_version == $php_versions) |
.matrix[]
]
}')
ENCODED_MATRIX_JSON=$(echo $FILTERED_MATRIX_JSON | jq -c .)
echo "matrix=${ENCODED_MATRIX_JSON}" >> $GITHUB_OUTPUT
codeception-tests:
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
uses: pimcore/workflows-collection-public/.github/workflows/reusable-codeception-tests-centralized.yaml@main
with:
APP_ENV: test
PIMCORE_TEST: 1
PRIVATE_REPO: ${{ needs.setup-matrix.outputs.private_repo}}
PHP_VERSION: ${{ matrix.matrix.php-version }}
DATABASE: ${{ matrix.matrix.database }}
SERVER_VERSION: ${{ matrix.matrix.server_version }}
DEPENDENCIES: ${{ matrix.matrix.dependencies }}
EXPERIMENTAL: ${{ matrix.matrix.experimental }}
PIMCORE_VERSION: ${{ matrix.matrix.pimcore_version }}
secrets:
SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }}
COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN: ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}
78 changes: 0 additions & 78 deletions .github/workflows/codeception.yml

This file was deleted.

33 changes: 11 additions & 22 deletions .github/workflows/php-cs-fixer.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
name: "PHP-CS-Fixer"

on:
pull_request_target:
branches:
- "[0-9]+.[0-9]+"
- "[0-9]+.x"
- "feature-*"
push:
branches:
- "[0-9]+.[0-9]+"
- "[0-9]+.x"
- "*_actions"
- "feature-*"
pull_request_target:
types: [ opened,closed,synchronize ]

permissions:
contents: read
contents: write

jobs:
php-cs-fixer:
permissions:
contents: write # for stefanzweifel/git-auto-commit-action to push code in repo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga:latest

- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Apply php-cs-fixer changes
php-style:
uses: pimcore/workflows-collection-public/.github/workflows/reusable-php-cs-fixer.yaml@main
secrets:
PHP_CS_FIXER_GITHUB_TOKEN: ${{ secrets.PHP_CS_FIXER_GITHUB_TOKEN }}
with:
head_ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
config_file: .php-cs-fixer.dist.php
13 changes: 4 additions & 9 deletions .github/workflows/poeditor-export.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ permissions:
contents: read

jobs:
poeditor:
runs-on: ubuntu-latest
if: ${{ github.repository == 'pimcore/admin-ui-classic-bundle' }}
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
php-style:
uses: pimcore/workflows-collection-public/.github/workflows/reusable-poeditor.yaml@main
secrets:
POEDITOR_ACTION_TRIGGER_TOKEN: ${{ secrets.POEDITOR_ACTION_TRIGGER_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/sonar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build
on:
push:
branches:
- 1.x
- 1.5
pull_request:
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Loading

0 comments on commit db01841

Please sign in to comment.