Skip to content

Commit

Permalink
Unify CI and drop empty tests (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek authored Oct 16, 2023
1 parent 0d26bef commit 75d9a2b
Show file tree
Hide file tree
Showing 22 changed files with 265 additions and 396 deletions.
14 changes: 9 additions & 5 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# See https://github.com/release-drafter/release-drafter#configuration
template: |
## What’s Changed
$CHANGES
categories:
- title: "Major features"
labels:
- "MAJOR"
- title: "Breaking changes"
labels:
- "BC-break"
- title: "Other changes"
template: $CHANGES
15 changes: 15 additions & 0 deletions .github/workflows/build-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build changelog

on:
push:
branches:
- develop

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- name: Run Release Drafter
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47 changes: 47 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build release

on:
push:
branches:
- 'release/*'

jobs:
autocommit:
name: Build Release
runs-on: ubuntu-latest
container:
image: ghcr.io/mvorisek/image-php:latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Install PHP dependencies
run: composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader

- name: Update composer.json
run: >-
composer config --unset version && php -r '
$f = __DIR__ . "/composer.json";
$data = json_decode(file_get_contents($f), true);
foreach ($data as $k => $v) {
if (preg_match("~^(.+)-release$~", $k, $matches)) {
$data[$matches[1]] = $data[$k]; unset($data[$k]);
}
}
$str = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . "\n";
echo $str;
file_put_contents($f, $str);
'
- name: Commit
run: |
git config --global user.name "$(git show -s --format='%an')"
git config --global user.email "$(git show -s --format='%ae')"
git add . -N && (git diff --exit-code || git commit -a -m "Branch for stable release")
- name: Push
uses: ad-m/github-push-action@master
with:
branch: ${{ github.ref }}
github_token: ${{ secrets.GITHUB_TOKEN }}
30 changes: 0 additions & 30 deletions .github/workflows/bundler.yml

This file was deleted.

16 changes: 0 additions & 16 deletions .github/workflows/release-drafter.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Unit

on:
pull_request:
push:
schedule:
- cron: '0 0/2 * * *'

jobs:
smoke-test:
name: Smoke
runs-on: ubuntu-latest
container:
image: ghcr.io/mvorisek/image-php:${{ matrix.php }}
strategy:
fail-fast: false
matrix:
php: ['latest']
type: ['CodingStyle', 'StaticAnalysis']
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure PHP
run: |
rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
php --version
- name: Setup cache 1/2
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Setup cache 2/2
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-smoke-${{ matrix.php }}-${{ matrix.type }}-${{ hashFiles('composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install PHP dependencies
run: |
if [ "${{ matrix.type }}" != "CodingStyle" ]; then composer remove --no-interaction --no-update friendsofphp/php-cs-fixer --dev; fi
if [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpstan/\* --dev; fi
composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader
- name: Check Coding Style (only for CodingStyle)
if: matrix.type == 'CodingStyle'
run: |
vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --diff --verbose
composer config --unset version && composer config --unset require-release
composer validate --strict --no-check-lock && composer normalize --dry-run --no-check-lock
- name: Run Static Analysis (only for StaticAnalysis)
if: matrix.type == 'StaticAnalysis'
run: |
echo "memory_limit = 2G" > /usr/local/etc/php/conf.d/custom-memory-limit.ini
vendor/bin/phpstan analyse
76 changes: 0 additions & 76 deletions .github/workflows/unit-tests.yml

This file was deleted.

8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
docs/build
demos/config.php
/build
/docs/build
/coverage
/vendor
/composer.lock
.idea
nbproject
.vscode
.DS_Store
php.cmd

local
*.local
Expand All @@ -16,4 +15,3 @@ cache
*.cache.*

/phpunit.xml
/phpunit-*.xml
29 changes: 14 additions & 15 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

$finder = PhpCsFixer\Finder::create()
->in([__DIR__])
->exclude([
'cache',
'build',
'vendor',
]);
->exclude(['vendor']);

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' =>true,
'@PHP71Migration:risky' => true,
'@PhpCsFixer:risky' => true,
'@PHP74Migration' => true,
'@PHP74Migration:risky' => true,

// required by PSR-12
'concat_space' => [
Expand All @@ -30,20 +27,18 @@
'equal' => false,
'identical' => false,
],
'native_constant_invocation' => true,
'native_function_invocation' => false,
'non_printable_character' => [
'use_escape_sequences_in_strings' => true,
],
'void_return' => false,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'exit'],
],
'combine_consecutive_issets' => false,
'combine_consecutive_unsets' => false,
'multiline_whitespace_before_semicolons' => false,
'no_superfluous_elseif' => false,
'ordered_class_elements' => false,
'php_unit_internal_class' => false,
'php_unit_test_case_static_method_calls' => [
'call_type' => 'this',
],
'php_unit_test_class_requires_covers' => false,
'phpdoc_add_missing_param_annotation' => false,
'return_assignment' => false,
Expand All @@ -54,6 +49,10 @@
'nullable_type_declaration_for_default_null_value' => [
'use_nullable_type_declaration' => false,
],

// fn => without curly brackets is less readable,
// also prevent bounding of unwanted variables for GC
'use_arrow_functions' => false,
])
->setFinder($finder)
->setCacheFile(__DIR__ . '/.php_cs.cache');
->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer.' . md5(__DIR__) . '.cache');
43 changes: 0 additions & 43 deletions CHANGELOG.md

This file was deleted.

Loading

0 comments on commit 75d9a2b

Please sign in to comment.