Skip to content

Commit

Permalink
[TASK] Migrate to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
IchHabRecht committed Dec 17, 2024
1 parent 71bdc3a commit 8c3bbc4
Show file tree
Hide file tree
Showing 8 changed files with 489 additions and 247 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: ✔ with code analysis

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

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

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

sonar:
name: '✔ with SonarCloud'

needs: [ compute, test ]

env:
php: ${{ fromJson(needs.compute.outputs.php-single) }}
typo3: ${{ fromJson(needs.compute.outputs.typo3-single) }}

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

runs-on: ${{ fromJson(needs.compute.outputs.os-single) }}

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 }}
extensions: mbstring, intl, pdo_sqlite, pdo_mysql
tools: composer:v2

- name: Environment Check
run: |
php --version
composer --version
- 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 }}
136 changes: 136 additions & 0 deletions .github/workflows/compute.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: ✏️ matrix

env:
OS: |
"ubuntu-latest"
PHP: |
"7.4"
"8.0"
"8.1"
TYPO3: |
"^10.4"
"^11.5"
"^12.4"
TYPO3_DEV: |
"10.4.x-dev"
"11.5.x-dev"
"12.4.x-dev"
EXCLUDE: |
{
"10.4-8.0": {
"typo3": "^10.4",
"php": "8.0",
},
"10.4-8.1": {
"typo3": "^10.4",
"php": "8.1",
},
"10.4.x-dev-8.0": {
"typo3": "10.4.x-dev",
"php": "8.0",
},
"10.4.x-dev-8.1": {
"typo3": "10.4.x-dev",
"php": "8.1",
},
"12.4-7.4": {
"typo3": "^12.4",
"php": "7.4",
},
"12.4-8.0": {
"typo3": "^12.4",
"php": "8.0",
},
"12.4.x-dev-7.4": {
"typo3": "12.4.x-dev",
"php": "7.4",
},
"12.4.x-dev-8.0": {
"typo3": "12.4.x-dev",
"php": "8.0",
},
}
on:
workflow_call:
outputs:
os:
value: ${{ jobs.compute.outputs.os }}
os-single:
value: ${{ jobs.compute.outputs.os-single }}
php:
value: ${{ jobs.compute.outputs.php }}
php-single:
value: ${{ jobs.compute.outputs.php-single }}
typo3:
value: ${{ jobs.compute.outputs.typo3 }}
typo3-single:
value: ${{ jobs.compute.outputs.typo3-single }}
typo3_dev:
value: ${{ jobs.compute.outputs.typo3_dev }}
exclude:
value: ${{ jobs.compute.outputs.exclude }}

jobs:
compute:
name: Compute outputs

outputs:
os: ${{ steps.build-matrix.outputs.os }}
os-single: ${{ steps.build-matrix.outputs.os-single }}
php: ${{ steps.build-matrix.outputs.php }}
php-single: ${{ steps.build-matrix.outputs.php-single }}
typo3: ${{ steps.build-matrix.outputs.typo3 }}
typo3-single: ${{ steps.build-matrix.outputs.typo3-single }}
typo3_dev: ${{ steps.build-matrix.outputs.typo3_dev }}
exclude: ${{ steps.build-matrix.outputs.exclude }}

runs-on: ubuntu-latest

steps:
- name: Build matrix
id: build-matrix
run: |
echo ""
echo "::group::OS"
os=$(echo $OS | jq --compact-output --raw-input --raw-output '.' | jq --compact-output --slurp '.')
echo "os = $os"
echo "os=$os" >> "$GITHUB_OUTPUT"
echo "os-single = $(echo $os | jq '.'[0])"
echo "os-single=$(echo $os | jq '.'[0])" >> "$GITHUB_OUTPUT"
echo "::endgroup::"
echo ""
echo "::group::PHP"
php=$(echo $PHP | jq --compact-output --raw-input --raw-output '.' | jq --compact-output --slurp '.')
echo "php = $php"
echo "php=$php" >> "$GITHUB_OUTPUT"
echo "php-single = $(echo $php | jq '.'[-1])"
echo "php-single=$(echo $php | jq '.'[-1])" >> "$GITHUB_OUTPUT"
echo "::endgroup::"
echo ""
echo "::group::TYPO3"
typo3=$(echo $TYPO3 | jq --compact-output --raw-input --raw-output '.' | jq --compact-output --slurp '.')
echo "typo3 = $typo3"
echo "typo3=$typo3" >> "$GITHUB_OUTPUT"
echo "typo3-single = $(echo $typo3 | jq --compact-output '.[] | select( contains("^"))' | jq --slurp '.'[-1])"
echo "typo3-single=$(echo $typo3 | jq --compact-output '.[] | select( contains("^"))' | jq --slurp '.'[-1])" >> "$GITHUB_OUTPUT"
echo "::endgroup::"
echo ""
echo "::group::TYPO3_DEV"
typo3_dev=$(echo $TYPO3_DEV | jq --compact-output --raw-input --raw-output '.' | jq --compact-output --slurp '.')
echo "typo3_dev = $typo3_dev"
echo "typo3_dev=$typo3_dev" >> "$GITHUB_OUTPUT"
echo "::endgroup::"
echo ""
echo "::group::EXCLUDE"
exclude=$(cat <<EOF | jq -nc -f /dev/stdin | jq -c 'to_entries | map_values(.value)'
$EXCLUDE
EOF
)
echo "exclude = $exclude"
echo "exclude=$exclude)" >> "$GITHUB_OUTPUT"
echo "::endgroup::"
97 changes: 97 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: 🏃 dev tests

on: [ push, pull_request ]

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

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

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

needs: [ compute, test ]

strategy:
fail-fast: false
matrix:
os: ${{ fromJson(needs.compute.outputs.os) }}
php: ${{ fromJson(needs.compute.outputs.php) }}
typo3: ${{ fromJson(needs.compute.outputs.typo3_dev) }}
dependency-version: [ 'lowest', 'stable' ]
exclude: ${{ fromJson(needs.compute.outputs.exclude) }}

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-stable --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 --no-coverage --no-logging --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/filefill ]; then ln -snvf ../../../../. .Build/public/typo3conf/ext/filefill; fi
find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo ""; echo ""; echo; echo "Running functional test suite {}"; .Build/bin/phpunit --bootstrap .Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php --no-coverage --no-logging {}'
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: 🚢 to TER

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

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

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

release:
name: '🚢 to TER'

needs: [ compute, test ]

env:
php: ${{ fromJson(needs.compute.outputs.php-single) }}
typo3: ${{ fromJson(needs.compute.outputs.typo3-single) }}

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

runs-on: ${{ fromJson(needs.compute.outputs.os-single) }}

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 }}" filefill
Loading

0 comments on commit 8c3bbc4

Please sign in to comment.