Skip to content

Commit 5a54eec

Browse files
committed
[TASK] Move commands to composer and use them from ci and nix-shell
1 parent 91d4a30 commit 5a54eec

3 files changed

Lines changed: 49 additions & 46 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,19 @@ jobs:
7979
run: composer install --prefer-dist --no-progress --no-suggest
8080

8181
- name: Coding Guideline
82-
run: .build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --using-cache=no --path-mode=intersection ./
82+
run: composer project:cgl
8383

8484
code-quality:
8585
runs-on: ubuntu-latest
8686
needs:
8787
- php-linting
8888
strategy:
8989
matrix:
90-
include:
91-
- php-version: '8.2'
92-
typo3-version: '^14.1'
93-
- php-version: '8.3'
94-
typo3-version: '^14.1'
95-
- php-version: '8.4'
96-
typo3-version: '^14.1'
97-
- php-version: '8.5'
98-
typo3-version: '^14.1'
90+
php-version:
91+
- 8.2
92+
- 8.3
93+
- 8.4
94+
- 8.5
9995
steps:
10096
- uses: actions/checkout@v4
10197

@@ -112,41 +108,35 @@ jobs:
112108
&& composer install --no-progress --no-ansi --no-interaction
113109
114110
- name: Code Quality (by PHPStan)
115-
run: .build/bin/phpstan analyse -c Build/phpstan.neon
111+
run: composer project:phpstan
116112

117113
tests-unit-and-functional:
118114
runs-on: ubuntu-latest
119115
needs:
120116
- coding-guideline
121117
- code-quality
118+
strategy:
119+
matrix:
120+
php-version:
121+
- 8.2
122+
- 8.3
123+
- 8.4
124+
- 8.5
122125
steps:
123-
- uses: actions/checkout@v5
126+
- uses: actions/checkout@v4
124127

125-
- uses: cachix/install-nix-action@v31
128+
- name: Install PHP
129+
uses: shivammathur/setup-php@v2
126130
with:
127-
nix_path: nixpkgs=channel:nixos-unstable
128-
129-
- name: Run Unit Tests PHP8.2
130-
run: nix-shell --arg phpVersion \"php82\" --pure --run project-test-unit
131-
132-
- name: Run Unit Tests PHP8.3
133-
run: nix-shell --arg phpVersion \"php83\" --pure --run project-test-unit
134-
135-
- name: Run Unit Tests PHP8.4
136-
run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-unit
137-
138-
- name: Run Unit Tests PHP8.5
139-
run: nix-shell --arg phpVersion \"php85\" --pure --run project-test-unit
140-
141-
- name: Run Functional Tests PHP8.2
142-
run: nix-shell --arg phpVersion \"php82\" --pure --run project-test-functional
131+
php-version: "${{ matrix.php-version }}"
132+
tools: composer:v2
143133

144-
- name: Run Functional Tests PHP8.3
145-
run: nix-shell --arg phpVersion \"php83\" --pure --run project-test-functional
134+
- name: Install dependencies
135+
run: composer install --prefer-dist --no-progress --no-suggest
146136

147-
- name: Run Functional Tests PHP8.4
148-
run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-functional
137+
- name: Run unit tests
138+
run: composer project:test:unit
149139

150-
- name: Run Functional Tests PHP8.5
151-
run: nix-shell --arg phpVersion \"php85\" --pure --run project-test-functional
140+
- name: Run functional tests
141+
run: export typo3DatabaseDriver=pdo_sqlite && composer project:test:functional
152142

composer.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@
7474
"typo3/testing-framework": "^9.5",
7575
"ssch/typo3-rector": "^3.11"
7676
},
77+
"scripts": {
78+
"project:cgl": ".build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --diff --using-cache=no --path-mode=intersection ./",
79+
"project:cgl:fix": ".build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php",
80+
"project:lint:php": "find ./*.php Classes Configuration Tests -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l",
81+
"project:phpstan": "./.build/bin/phpstan analyse -c Build/phpstan.neon --memory-limit 256M",
82+
"project:test:unit": ".build/bin/phpunit -c Build/phpunit.xml.dist --testsuite unit --display-warnings --display-deprecations --display-errors --display-notices",
83+
"project:test:functional": ".build/bin/phpunit -c Build/phpunit.xml.dist --testsuite functional --display-warnings --display-deprecations --display-errors"
84+
},
7785
"suggest": {
7886
"typo3/cms-dashboard": "^14.2",
7987
"typo3/cms-form": "^14.2"

shell.nix

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ let
1919
projectInstall = pkgs.writeShellApplication {
2020
name = "project-install";
2121
runtimeInputs = [
22-
php
2322
composer
23+
php
2424
];
2525
text = ''
2626
composer update --prefer-dist --no-progress
@@ -31,71 +31,77 @@ let
3131
name = "project-cgl";
3232

3333
runtimeInputs = [
34+
composer
3435
php
3536
];
3637

3738
text = ''
38-
./.build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --diff
39+
composer project:cgl
3940
'';
4041
};
4142

4243
projectCglFix = pkgs.writeShellApplication {
4344
name = "project-cgl-fix";
4445

4546
runtimeInputs = [
47+
composer
4648
php
4749
];
4850

4951
text = ''
50-
./.build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php
52+
composer project:cgl:fix
5153
'';
5254
};
5355

54-
projectLint = pkgs.writeShellApplication {
55-
name = "project-lint";
56+
projectLintPhp = pkgs.writeShellApplication {
57+
name = "project-lint-php";
5658

5759
runtimeInputs = [
60+
composer
5861
php
5962
];
6063

6164
text = ''
62-
find ./*.php Classes Configuration Tests -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l
65+
composer project:lint:php
6366
'';
6467
};
6568

6669
projectPhpstan = pkgs.writeShellApplication {
6770
name = "project-phpstan";
6871

6972
runtimeInputs = [
73+
composer
7074
php
7175
];
7276

7377
text = ''
74-
./.build/bin/phpstan analyse -c Build/phpstan.neon --memory-limit 256M
78+
composer project:phpstan
7579
'';
7680
};
7781

7882
projectTestUnit = pkgs.writeShellApplication {
7983
name = "project-test-unit";
8084
runtimeInputs = [
85+
composer
8186
php
8287
projectInstall
8388
];
8489
text = ''
8590
project-install
86-
.build/bin/phpunit -c Build/phpunit.xml.dist --testsuite unit --display-warnings --display-deprecations --display-errors --display-notices
91+
composer project:test:unit
8792
'';
8893
};
8994

9095
projectTestFunctional = pkgs.writeShellApplication {
9196
name = "project-test-functional";
9297
runtimeInputs = [
98+
composer
9399
php
94100
projectInstall
95101
];
96102
text = ''
97103
project-install
98-
.build/bin/phpunit -c Build/phpunit.xml.dist --testsuite functional --display-warnings --display-deprecations --display-errors
104+
composer project:test:functional
99105
'';
100106
};
101107

@@ -105,10 +111,9 @@ in pkgs.mkShell {
105111
php
106112
composer
107113
projectInstall
108-
projectPhpstan
109114
projectCgl
110115
projectCglFix
111-
projectLint
116+
projectLintPhp
112117
projectPhpstan
113118
projectTestUnit
114119
projectTestFunctional

0 commit comments

Comments
 (0)