Skip to content

Commit

Permalink
Align release workflow 2.4.0 (#73)
Browse files Browse the repository at this point in the history
* Align with atk4/core workflow

* Add Behat test workflow from Atk4/Ui

* Remove js compilation from Behat tests

* Update composer.json

* Add phpstan.neon.dist from Atk4/Data, removed ignoreErrors

* Remove creation of db

* Initial Fixes phpstan

* Fix Namespace case

* demo rename login.php to form-login.php

* Re-Add create-sqlite-db.php

* Fix path & fqcn

* Fix database creation

* Fix release dep to 2.5

* Start fixing behat

* Drop inherited dependency from require-release

* Fix Behat

* Fix add -> addTo

* BugFix : hardcoded field login as email when use default Form/Login

* Fix access to array

* Remove useless [] when called new Array_()

* Fix UnitTest Array Access error using new way Array_/Db/Table/Rows

* CS-Fix

* Add Stan generated baseline

* Add Stan generated baseline

* Demo : Align layout form register to form login

* Rename basic.feature to login.feature

* Add Behat register.feature

* Align Login and Register to internally use fieldLogin and fieldPassword from Auth

* CS-Fix

* Clean up

* Change from GetProtected to Model->export

* CS Fix

* Fix add sleep(1) to right file.

* change init.php to init-app.php like in Atk4/Ui, to avoid errors on inevitable copy/paste

* Add 1 phpstan-ignore

* FIX : one FQCN error and removed from stan

* Solving phpstan errors

* fix array persistence test

* Fix : removing Array_($a /* empty array */) to Array_()

* test behat

* test

* contains?

* contains

* hmmm

* test

* hmm2

* test again

* rollback

* test behat & rollback

* try to fix behat

* try to fix behat

* try to fix behat

* try to fix behat

* Remove failing tests. Not to be tested in this repo

* Fix : Model::data now is private switch to &getDataRef()

* Use setMulti (getDataRef is internal)

* Rollback [Unit-Burn] using ui settings for testing leaks + Behat [Chrome lowest]

* Use Atk4/Ui/Behat/Context

* Set require to atk4/ui 2.4 for release

* Add conditional to local run https://github.com/nektos/act
issue open : nektos/act#329

* Fix password test for 2.4

* CS fix

* Add Behat context file for 2.4 release

* Rename deprecated filename for cs-fixer

* Adjust Behat conf

* Fix phpstan

* Fix memory leak

* remove condition, exception will throw before (in method fieldExists)

Co-authored-by: DarkSide <[email protected]>
  • Loading branch information
abbadon1334 and DarkSide666 committed Jul 26, 2021
1 parent cd9a7a9 commit 2cc0910
Show file tree
Hide file tree
Showing 33 changed files with 1,282 additions and 359 deletions.
1 change: 0 additions & 1 deletion .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ categories:
- "Documentation :books:"
template: |
## What’s Changed
$CHANGES
15 changes: 15 additions & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build Docs

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 }}
56 changes: 56 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build Release

on:
push:
branches:
- '**\.build'
- 'release/*'
- '!**\.gen'

jobs:
autocommit:
name: Build Release
runs-on: ubuntu-latest
container:
image: atk4/image:latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.ref }}

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

- name: Composer unset version
run: composer config version --unset

- name: Update composer.json
run: >-
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: Composer validate config
run: composer validate --strict --no-check-lock && composer normalize --dry-run --no-check-lock

- 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 -A && git diff --staged && git commit -m "Build Release"
- name: Push
uses: ad-m/github-push-action@master
with:
branch: ${{ github.ref }}.gen
force: true
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.

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

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

jobs:
smoke-test:
name: Smoke
runs-on: ubuntu-latest
container:
image: atk4/image:${{ matrix.php }}
strategy:
fail-fast: false
matrix:
php: ['latest']
type: ['Phpunit']
include:
- php: 'latest'
type: 'CodingStyle'
- php: 'latest'
type: 'StaticAnalysis'
env:
LOG_COVERAGE: ""
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Configure PHP
run: |
if [ -n "$LOG_COVERAGE" ]; then echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; else rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; fi
php --version
- name: Setup cache 1/2
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Setup cache 2/2
if: ${{ !env.ACT }}
uses: actions/cache@v1
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 }}" != "Phpunit" ] && [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpunit/phpunit johnkary/phpunit-speedtrap --dev ; fi
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/phpstan --dev ; fi
composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader
- name: Init
run: |
mkdir -p build/logs
- name: "Run tests: Phpunit (only for Phpunit)"
if: matrix.type == 'Phpunit'
run: "vendor/bin/phpunit \"$(if [ -n \"$LOG_COVERAGE\" ]; then echo '--coverage-text'; else echo '--no-coverage'; fi)\" -v"

- name: Check Coding Style (only for CodingStyle)
if: matrix.type == 'CodingStyle'
run: vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --diff --diff-format=udiff --verbose --show-progress=dots

- name: Run Static Analysis (only for StaticAnalysis)
if: matrix.type == 'StaticAnalysis'
run: |
echo "memory_limit = 1G" > /usr/local/etc/php/conf.d/custom-memory-limit.ini
vendor/bin/phpstan analyse
unit-test:
name: Unit
runs-on: ubuntu-latest
container:
image: atk4/image:${{ matrix.php }}
strategy:
fail-fast: false
matrix:
php: ['7.3', '7.4', 'latest']
type: ['Phpunit']
include:
- php: 'latest'
type: 'Phpunit Lowest'
- php: 'latest'
type: 'Phpunit Burn'
env:
LOG_COVERAGE: "${{ fromJSON('{true: \"1\", false: \"\"}')[matrix.php == 'latest' && matrix.type == 'Phpunit' && (github.event_name == 'pull_request' || (github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')))] }}"
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Configure PHP
run: |
if [ -n "$LOG_COVERAGE" ]; then echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; else rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; fi
php --version
- name: Setup cache 1/2
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Setup cache 2/2
if: ${{ !env.ACT }}
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.type }}-${{ hashFiles('composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install PHP dependencies
run: |
if [ "${{ matrix.type }}" != "Phpunit" ] && [ "${{ matrix.type }}" != "Phpunit Lowest" ] && [ "${{ matrix.type }}" != "Phpunit Burn" ]; then composer remove --no-interaction --no-update phpunit/phpunit --no-update phpunit/phpunit johnkary/phpunit-speedtrap --dev ; fi
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/phpstan --dev ; fi
composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader
if [ "${{ matrix.type }}" == "Phpunit Lowest" ]; then composer update --ansi --prefer-dist --prefer-lowest --prefer-stable --no-interaction --no-progress --optimize-autoloader ; fi
if [ "${{ matrix.type }}" == "Phpunit Burn" ]; then sed -i 's/ *public function runBare(): void/public function runBare(): void { gc_collect_cycles(); $mem0 = memory_get_usage(); for ($i = 0; $i < '"$(if [ \"$GITHUB_EVENT_NAME\" == \"schedule\" ]; then echo 5; else echo 5; fi)"'; ++$i) { $this->_runBare(); if ($i === 0) { gc_collect_cycles(); $mem1 = memory_get_usage(); } } gc_collect_cycles(); $mem2 = memory_get_usage(); if ($mem2 - 4000 * 1024 > $mem0 || $mem2 - 1536 * 1024 > $mem1) { $this->onNotSuccessfulTest(new AssertionFailedError("Memory leak detected! (" . round($mem0 \/ (1024 * 1024), 3) . " + " . round(($mem1 - $mem0) \/ (1024 * 1024), 3) . " + " . round(($mem2 - $mem1) \/ (1024 * 1024), 3) . " MB, " . $i . " iterations)")); } } private function _runBare(): void/' vendor/phpunit/phpunit/src/Framework/TestCase.php && cat vendor/phpunit/phpunit/src/Framework/TestCase.php | grep '_runBare(' ; fi
- name: Init
run: |
mkdir -p build/logs
- name: "Run tests: Phpunit (only for Phpunit)"
if: startsWith(matrix.type, 'Phpunit')
run: "vendor/bin/phpunit \"$(if [ -n \"$LOG_COVERAGE\" ]; then echo '--coverage-text'; else echo '--no-coverage'; fi)\" -v"

- name: Upload coverage logs (only for "latest" Phpunit)
if: env.LOG_COVERAGE
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: build/logs/clover.xml

behat-test:
name: Behat
runs-on: ubuntu-latest
container:
image: atk4/image:${{ matrix.php }}
strategy:
fail-fast: false
matrix:
php: ['latest-npm']
type: ['Chrome', 'Firefox', 'Chrome Lowest', 'Chrome Slow']
env:
LOG_COVERAGE: ''
services:
selenium-chrome:
image: selenium/standalone-chrome:latest
options: --health-cmd "/opt/bin/check-grid.sh"
selenium-firefox:
image: selenium/standalone-firefox:latest
options: --health-cmd "/opt/bin/check-grid.sh"
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Configure PHP
run: |
if [ -n "$LOG_COVERAGE" ]; then echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; else rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; fi
php --version
- name: Setup cache 1/2
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Setup cache 2/2
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.type }}-${{ hashFiles('composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install PHP dependencies
run: |
composer remove --no-interaction --no-update phpunit/phpunit johnkary/phpunit-speedtrap phpunit/phpcov --dev
composer remove --no-interaction --no-update friendsofphp/php-cs-fixer --dev
composer remove --no-interaction --no-update phpstan/phpstan --dev
composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader
if [ "${{ matrix.type }}" == "Chrome Lowest" ]; then composer update --ansi --prefer-dist --prefer-lowest --prefer-stable --no-interaction --no-progress --optimize-autoloader ; fi
- name: Init
run: |
mkdir -p build/logs
php demos/_demo-data/create-sqlite-db.php
- name: "Run tests: Behat"
run: |
php -S 172.18.0.2:8888 > /dev/null 2>&1 &
sleep 1
if [ "${{ matrix.type }}" == "Firefox" ]; then sed -i "s~chrome~firefox~" behat.yml.dist ; fi
if [ "${{ matrix.type }}" == "Chrome Slow" ]; then echo 'sleep(1);' >> demos/init-app.php ; fi
# remove once https://github.com/minkphp/Mink/pull/801
# and https://github.com/minkphp/MinkSelenium2Driver/pull/322 are released
sed -i 's/usleep(100000)/usleep(5000)/' vendor/behat/mink/src/Element/Element.php
sed -i 's/usleep(100000)/usleep(5000)/' vendor/behat/mink-selenium2-driver/src/Selenium2Driver.php
vendor/bin/behat -vv --config behat.yml.dist
Loading

0 comments on commit 2cc0910

Please sign in to comment.