Skip to content

Commit

Permalink
[TASK] Migrate CI workflow to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
IchHabRecht committed Apr 29, 2024
1 parent 74a3fbb commit 5566e6a
Show file tree
Hide file tree
Showing 6 changed files with 346 additions and 242 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: ✔ with code analysis

on:
push:
branches:
- main
- develop
- premerge/*
- pre-merge

jobs:
test:
uses: ./.github/workflows/test.yml

sonar:
name: '✔ with SonarCloud'

env:
php: '8.2'
typo3: '^12.4'

if: github.repository == 'IchHabRecht/social_gdpr'

needs: [ test ]

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download PHPUnit logs
uses: actions/download-artifact@v4
with:
path: .Log
pattern: phpunit-logs-*
merge-multiple: true

- name: Store Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- uses: actions/cache/restore@v4
id: restore-composer-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ env.typo3 }}-${{ env.php }}
restore-keys: |
${{ runner.os }}-composer-${{ env.typo3 }}-
${{ runner.os }}-composer-
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php }}
tools: composer:v2

- name: Composer install
run: composer require --no-progress --no-suggest typo3/cms-core:"${{ env.typo3 }}" nimut/phpunit-merger

- name: Merging log and coverage files
run: |
.Build/bin/phpunit-merger coverage .Log/coverage/ .Log/coverage.xml;
.Build/bin/phpunit-merger log .Log/junit/ .Log/junit.xml;
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
98 changes: 98 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: 🏃 dev tests

on: [ push, pull_request ]

jobs:
test:
uses: ./.github/workflows/test.yml

dev:
name: 'TYPO3: ${{ matrix.typo3 }} - PHP: ${{ matrix.php }} - ${{ matrix.dependency-version }}'

needs: [ test ]

strategy:
fail-fast: false
matrix:
os: [ 'ubuntu-latest' ]
typo3: [ '10.4.x-dev', '11.5.x-dev' ]
php: [ '7.4', '8.0', '8.1' ]
dependency-version: [ 'lowest', 'stable' ]
exclude:
- typo3: '10.4.x-dev'
php: '8.0'
- typo3: '10.4.x-dev'
php: '8.1'

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Store Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Store TYPO3 version
id: version-cache
env:
TYPO3: ${{ matrix.typo3 }}
run: echo "version=${TYPO3//[!0-9]/}" >> $GITHUB_OUTPUT

- uses: actions/cache/restore@v4
id: restore-composer-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.typo3 }}-${{ matrix.php }}
restore-keys: |
${{ runner.os }}-composer-${{ matrix.typo3 }}-
${{ runner.os }}-composer-
- name: Set up PHP Version ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, intl, pdo_sqlite, pdo_mysql
tools: composer:v2
coverage: none

- name: Environment Check
run: |
php --version
composer --version
mkdir -p .Log/coverage/ .Log/junit/
- name: Validate composer.json
run: composer validate

- name: Composer install
run: |
composer config minimum-stability dev
composer update --with "typo3/cms-core:${{ matrix.typo3 }}" --no-interaction --prefer-dist --prefer-${{ matrix.dependency-version }}
- name: Save composer cache
uses: actions/cache/save@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ steps.restore-composer-cache.outputs.cache-primary-key }}

- name: Lint PHP
run: php .Build/bin/parallel-lint --exclude .Build .

- name: Unit Tests
if: ${{ hashFiles('Tests/Unit/') != '' }}
run: .Build/bin/phpunit --bootstrap .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php --testsuite unit

- name: Functional Tests
if: ${{ success() || failure() }} && ${{ hashFiles('Tests/Functional/') != '' }}
env:
typo3DatabaseHost: '127.0.0.1'
typo3DatabaseName: 'typo3'
typo3DatabasePassword: 'root'
typo3DatabaseUsername: 'root'
run: |
sudo /etc/init.d/mysql start
mkdir -p .Build/public/typo3conf/ext/
if [ ! -L .Build/public/typo3conf/ext/social_gdpr ]; then ln -snvf ../../../../. .Build/public/typo3conf/ext/social_gdpr; fi
find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo; echo "Running functional test suite {}"; .Build/bin/phpunit --bootstrap .Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php {}'
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: 🚢 to TER

on:
push:
tags:
- "v?[0-9]+.[0-9]+.[0-9]+"

jobs:
test:
uses: ./.github/workflows/test.yml

release:
name: '🚢 to TER'

env:
php: '8.2'
typo3: '^12.4'

if: github.repository == 'IchHabRecht/social_gdpr'

needs: [ test ]

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Store Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- uses: actions/cache/restore@v4
id: restore-composer-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ env.typo3 }}-${{ env.php }}
restore-keys: |
${{ runner.os }}-composer-${{ env.typo3 }}-
${{ runner.os }}-composer-
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php }}
tools: composer:v2
coverage: none

- name: Extract version from GITHUB_REF
id: github-ref
run: |
echo "version=$(echo $GITHUB_REF | sed -E -n 's#^refs/tags/v?([0-9]+\.)([0-9]+\.)([0-9]+)#\1\2\3#p')" >> $GITHUB_OUTPUT
- name: Composer install
run: |
composer global require typo3/tailor
export PATH=$PATH:$(composer global config bin-dir --absolute --quiet)
- name: Uploading release ${{ steps.github-ref.outputs.version }} to TER
run: |
export TAG_MESSAGE=$(git tag -n10 -l ${{ steps.github-ref.outputs.version }} | sed 's/^[v]*[0-9.]*[ ]*//g')
echo $TAG_MESSAGE
echo
TYPO3_API_USERNAME="${{ secrets.TYPO3_ORG_USERNAME }}" TYPO3_API_PASSWORD="${{ secrets.TYPO3_ORG_PASSWORD }}" tailor ter:publish --comment "$TAG_MESSAGE" "${{ steps.github-ref.outputs.version }}" social_gdpr
107 changes: 107 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: 🏃 tests

on: [ push, pull_request, workflow_call ]

concurrency:
group: ${{ github.head_ref || github.run_id }}

jobs:
test:
name: 'TYPO3: ${{ matrix.typo3 }} - PHP: ${{ matrix.php }}'

strategy:
fail-fast: false
matrix:
os: [ 'ubuntu-latest' ]
typo3: [ '^10.4', '^11.5', '~12.0.0', '~12.1.0' ]
php: [ '7.4', '8.0', '8.1' ]
exclude:
- typo3: '^10.4'
php: '8.0'
- typo3: '^10.4'
php: '8.1'
- typo3: '~12.0.0'
php: '7.4'
- typo3: '~12.0.0'
php: '8.0'
- typo3: '~12.1.0'
php: '7.4'
- typo3: '~12.1.0'
php: '8.0'

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Store Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Store TYPO3 version
id: version-cache
env:
TYPO3: ${{ matrix.typo3 }}
run: echo "version=${TYPO3//[!0-9]/}" >> $GITHUB_OUTPUT

- uses: actions/cache/restore@v4
id: restore-composer-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.typo3 }}-${{ matrix.php }}
restore-keys: |
${{ runner.os }}-composer-${{ matrix.typo3 }}-
${{ runner.os }}-composer-
- name: Set up PHP Version ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, intl, pdo_sqlite, pdo_mysql
tools: composer:v2

- name: Environment Check
run: |
php --version
composer --version
mkdir -p .Log/coverage/ .Log/junit/
- name: Validate composer.json
run: composer validate

- name: Composer install
run: composer update --with "typo3/cms-core:${{ matrix.typo3 }}" --no-interaction

- name: Save composer cache
uses: actions/cache/save@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ steps.restore-composer-cache.outputs.cache-primary-key }}

- name: Lint PHP
run: php .Build/bin/parallel-lint --exclude .Build .

- name: Unit Tests
if: ${{ success() || failure() }} && ${{ hashFiles('Tests/Unit/') != '' }}
run: .Build/bin/phpunit --bootstrap .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php --log-junit .Log/junit/unit_${{ steps.version-cache.outputs.version }}.xml --coverage-php .Log/coverage/unit_${{ steps.version-cache.outputs.version }}.cov --testsuite unit

- name: Functional Tests
if: ${{ success() || failure() }} && ${{ hashFiles('Tests/Functional/') != '' }}
env:
typo3DatabaseHost: '127.0.0.1'
typo3DatabaseName: 'typo3'
typo3DatabasePassword: 'root'
typo3DatabaseUsername: 'root'
run: |
sudo /etc/init.d/mysql start
mkdir -p .Build/public/typo3conf/ext/
if [ ! -L .Build/public/typo3conf/ext/social_gdpr ]; then ln -snvf ../../../../. .Build/public/typo3conf/ext/social_gdpr; fi
find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo "Running functional test suite {}"; HASH=${{ steps.version-cache.outputs.version }}_$( echo {} | md5sum | cut -d " " -f 1); .Build/bin/phpunit --bootstrap .Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php --log-junit .Log/junit/functional_$HASH.xml --coverage-php .Log/coverage/functional_$HASH.cov {}'
- name: Archive PHPUnit logs
uses: actions/upload-artifact@v4
with:
name: phpunit-logs-${{ runner.os }}-${{ matrix.typo3 }}-${{ matrix.php }}
path: .Log/*
retention-days: 1
Loading

0 comments on commit 5566e6a

Please sign in to comment.