Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Introduce GitHub actions powered workflow #147

Merged
merged 10 commits into from
Mar 15, 2023

Conversation

sbuerk
Copy link
Contributor

@sbuerk sbuerk commented Feb 19, 2023

This pull-request integreates a enhanced CI guard
composed from several independat parts. The final
result contain following features:

* Multi TYPO3 core testing with `ddev`
* Multi TYPO3 core testing with `Build/Scripts/runTests.sh`
* Testing range from v9 up to v11
* Integrating a couple of code, check and validation tools
  in the through `runTests.sh`
* rst-file integrity check for the documentation files
* UTF-8 files BOM checker
* Integrity check to ensure no test method starts with "test"
* Basic support for multi dbms testing, albit only MySQL and
  MySQL is enabled for now (see workflow files for why the
  two dbms Postgres and SQLite is disabled for now)
* Integrating `deepL API MockServer` as additional service to
  the `ddev configuration` (development relevant). It's also
  included non-conflicting within `Build/Scripts/runTests.sh`
* Adjusted tests to be able to testagainst the API MockServer
* Fixed missing "port" support in apiUrl handling - at least
  partly. Should be done nicer in already planed refactoring.
* Code Style check using php-cs-fixer with slightly adjusted
  ruleset (detailed adjustment should be done later in it's
  own pull-request)
* Removing needles editorconfig cli tool (not reliable enough)
* Removed ext:news dev-dependency (not needed and tests should
  be build without it anyways)

For a list of possible runTests.sh commands see:

Build/Scripts/runtTests.sh
Build/Scripts/runtTests.sh -h

Additional examples can be found in the GitHub actions
.github/worflows/testcore*.yml files.

Note Each commit contains a descriptive commit message.
Therefore, not copy&pasting them to here to avoid a lengthy
story book.

As a final word - this is a streamlining kick-off to get
automatic testing in charge. That increases acceptance for
contributors.

Resolves #102 - albit it's set to 4.x milestone, I would
suggest to integrate this directly and as soon as possible.

@sbuerk sbuerk marked this pull request as draft February 24, 2023 08:38
@sbuerk
Copy link
Contributor Author

sbuerk commented Feb 24, 2023

Going to work further on it tomorrow

3rd party extension "georgringer/news" has been added
as development dependency. That should prepare to test
setups that extension provides. However, the dependency
has been added in a version narrowing down the available
core versions for development - without having any tests
yet.

Instead of dealing with a broad range of versions through
out all core version, this dependency is removed again for
now. After branching and dropping support for older TYPO3
core versions, this can be re-added along with adding the
planed tests.

Used command(s):

```shell
composer remove --dev --no-update georgringer/news
```
@sbuerk sbuerk force-pushed the github-actions-1 branch 26 times, most recently from 81045f2 to de11bdb Compare February 26, 2023 00:12
@sbuerk sbuerk force-pushed the github-actions-1 branch 2 times, most recently from 3177380 to b0622a6 Compare February 26, 2023 00:53
@sbuerk sbuerk changed the title [TASK] Introduce GitHub actions to guard code work [TASK] Introduce GitHub actions powered workflow Feb 26, 2023
@sbuerk sbuerk marked this pull request as ready for review February 26, 2023 01:04
This change makes some minor adjustment to the php-cs-fixer
ruleset to taggle minor cgl rules. The main reason is, to
get a first usable ruleset set and use php-cs-fixer as code
cgl check in CI (GitHub Action).

`php-cs-fixer` is used to apply the rule set as preparation
to add this as GitHub action workflow check, to avoid code
cgl violation in the future.

Changed rules and/or options:

* set rule `declare_equal_normalize` option `space`to `none`
* add `blank_line_after_opening_tag` set to `true`

Used command(s):

```shell
php-cs-fixer fix --config .config/.php-cs-rules.php --ansi
```
This change moves tools configuration into directory
structure under `Build/`, separating each tool to it's
own subfolder.

On the one hand, this is a preparation moving forward
and aligning the CI tools and tests into known TYPO3
core structures. Additionally, it prepares for a later
revert to the core testing-framework along with the
core `runTests.sh` in parallel to the ddev logic.
`armin/editorconfig-cli` has been added as a test
ballon to help with documentation rst files and
other formats based on the `.editorconfig` rules.

Rulesets cannot be taken hard, therefore running
it as CI check and auto fixing it would more often
breaks documentation and other files. Would always
emit false-positives and is therefore useless.

`.editorconfig` main reason to exist is to help in
integrated development environments, to format code
which matches a ruleset. For php code, where this
is mainly needed, `php-cs-fixer` can do a better
job at it. Only point is to avoid to much difference
between them.

Used command(s):

```shell
composer remove --dev --no-update \
  armin/editorconfig-cli
```
To avoid the need for a api and heavily abusing real api
limits during automatic tests, especially for the upcoming
github ci integration, a deepL mock api server is added
as a additional ddev service with proper interconnection.

Detection of ddev and environment variable configuration
in the extension configuration setup for functional test
is added. This covers the ddev setup automatically and
also prepares for upcoming TYPO3 core `runTests.sh`.

Therefore, functional tests can be executed against the
mock server. Minor api url preparation has to be adopted
due missing port support in the deepL service class:

  `\WebVision\WvDeepltranslate\Service\DeeplService`

Mock server only supports specified text for translation,
thus tests adjusted to reflect this.
The script ensuring prober composer requires and installation
TYPO3 core version aware is moved from the .ddev folder to the
more prominent `Build/Scripts/` folder.

This raises the visibility for it and further prepares for the
introduction of TYPO3 core `Build/Scripts/runTests.sh` testing.
New build folder is completly added to the
`.gitattributes` file to ensure it is not
exported in package archiving. Tests are
not part of distribution packages.
Test related scripts and tests themself do not contain
into exported archives and packages. Therefor, `Tests/`
folder is added to `.gitattributes`.
This change introduces some GitHub action workflow
definitions as a firsts round-up. Due several issues
not all tests and php-versions are covered for now.

The defined workflow kicks on on pushes, pull-requests
and also adding scheduled runs (aka nightlies).

No functional tests are executed yet, as this needs
either a valid DeepL API key, and consuming limits
and contigents. In a dedicated step, it can be tried
to use the DeepL API MockServer for functional test.

See: https://github.com/DeepLcom/deepl-mock

**Note:** This is only a first start, after tackling
the issues and streamlining and house-keeping has been
done, this can be increased and further extended.
TYPO3 core uses and maintains several tools to check,
guard and test the core. It's also a conveniant style
to use the same technique for extension and project
development.

Developer with core contribution experience, at least
they of them who contributes regularly, would find a
same entry point around all testing related.

Only requirement are:

* docker deamon installed
* docker-compose or docker compose plugin
* bash to execute runTests.sh dispatcher

Main thoughts and benefit of this techique is, that it
has a low requirement profile and non-conflicting effect
on all platforms. That makes this really conveniant to
be used in any kind of CI like GitHub actions, GitLab CI
workflows or locallay (MacOS, Linux, Windows/WSL2,..).

Core contributors loves the fact, that the can simply
look into a failed pipeline and simply copy'n paste the
needed script commands without having to translate them
to their local environments. By usind well-defined and
versioned images, issues are reproducable on all systems
eliminating environment depending differences and error
sources.

This change introduces the `Build/Scripts/runTests.sh`
wrapping script as main dispatcher, along with the
`Build/testing-docker/docker-compose.yml` file defining
all available services which may be used by tools, tests
and scripts. The service are defined in a non-conflicting
way wo avoid interferiance with host system installations.

The `ddev` based system to execute tools and tests is
kept and not deprecated yet.

Needed and usefull overlapping has been moved to central
places, used by both systems.

ddev has one minor flaw against `runTests.sh` it do not
have multi dbms testing configured.

Available `runTests.sh` scripts and further tests can be
displayed with:

```shell
Build/Scripts/runTests.sh -h
```

Further scripts are fetched from the TYPO3 core monorepo
to increase code and documentation quality:

* checkUtf8Bom.sh: Check for invalid UTF-8 BOM in files
* validateRstFiles.php: Validate rst files integrity
* checkTestMethodsPrefix: ensures tests methods do not
  start with "test"
* checkExceptionCodes: Find duplicate exception codes

Used command(s):

```shell
composer req --dev --no-update \
  "nikic/php-parser":"^4.15.1"
```

Last but not least, github action workflow is restructured
and changed to use `Build/Scripts/runTests.sh` wrapper for
all tasks.
@NarkNiro NarkNiro merged commit e20c65f into web-vision:master Mar 15, 2023
@sbuerk sbuerk deleted the github-actions-1 branch April 13, 2023 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup GitHub workflows for CI testing
3 participants