You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/docs/utils/testing.md
+39-28Lines changed: 39 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,38 +42,40 @@ tests:
42
42
processUncoveredFiles: true
43
43
44
44
lint:
45
-
preset: 'PSR12'
46
-
ignore_dot_files: true
45
+
preset: PSR12
47
46
rules:
48
-
array_syntax:
49
-
syntax: 'short'
50
47
no_unused_imports: true
48
+
not_operator_with_successor_space: false
51
49
single_quote: true
52
-
ordered_imports:
53
-
imports_order: null
54
-
case_sensitive: false
55
-
sort_algorithm: 'alpha'
56
50
57
51
actions:
58
52
run:
59
-
- 'lint'
60
-
- 'test'
53
+
- lint
54
+
- tests
61
55
php:
62
56
extensions: json, zip
63
57
versions:
64
58
- '8.3'
65
59
event:
66
-
- 'push'
67
-
- 'pull_request'
60
+
- push
61
+
- pull_request
68
62
```
69
63
70
64
You can make edits to this file to suit your needs. The `app` key is an array of directories to look for your app files in. The `tests` key is an array of configurations for your tests. The `lint` key is an array of configurations for your code styling checks. Once you're done setting up your `alchemy.yml` file, you can run the setup script.
71
65
72
-
```bash
73
-
leaf run alchemy # or composer run alchemy
66
+
::: code-group
67
+
68
+
```bash:no-line-numbers [Leaf CLI]
69
+
leaf run alchemy
70
+
```
71
+
72
+
```bash:no-line-numbers [Composer]
73
+
composer run alchemy
74
74
```
75
75
76
-
This will install your test engine, PHP CS Fixer and any other dependencies you might need, and then generate dummy tests using the test engine you chose. It will then lint your code, run your tests and generate a coverage report (if you selected that option). It will also add a `test` and `lint` command to your `composer.json` file which you can use to run your tests and lint your code respectively. Finally, it will generate a `.github/workflows` directory with a `test.yml` file and a `lint.yml` file which you can use to run your tests and linting on github actions.
76
+
:::
77
+
78
+
This will install your test engine, PHP CS Fixer and any other dependencies you might need, and then generate dummy tests using the test engine you chose. It will then lint your code, run your tests and also add `test` and `lint` commands to your `composer.json` file which you can use to run your tests and lint your code respectively. Finally, Alchemy will generate a `.github/workflows` directory with a `tests.yml` file and a `lint.yml` file which you can use to run your tests and linting on github actions.
77
79
78
80
## Configuring Tests
79
81
@@ -97,7 +99,7 @@ tests:
97
99
processUncoveredFiles: true
98
100
```
99
101
100
-
- `app`: This is a list of directories that contain your application code. Alchemy will use these directories to lint your code and also in code coverage reports.
102
+
- `app`: This is a list of directories that contain your application code. Alchemy will use these directories to lint your code and also in code coverage reports. If you want to use the root directory, you can just remove the entire `app` section.
101
103
102
104
- `tests.engine`: The testing engine to use. Only Pest and PHPUnit are supported engine at the moment, but we plan to add support for other engines in the future.
103
105
@@ -125,17 +127,18 @@ app:
125
127
...
126
128
127
129
lint:
128
-
preset: 'PSR12'
130
+
preset: PSR12
129
131
ignore_dot_files: true
130
132
rules:
131
133
array_syntax:
132
-
syntax: 'short'
134
+
syntax: short
133
135
no_unused_imports: true
134
136
single_quote: true
135
137
ordered_imports:
136
138
imports_order: null
137
139
case_sensitive: false
138
-
sort_algorithm: 'alpha'
140
+
sort_algorithm: alpha
141
+
...
139
142
```
140
143
141
144
As you see, you can set up your code styling rules in the `lint` section of the `alchemy.yml` file. All of [PHP-CS-Fixer Configurator](https://mlocati.github.io/php-cs-fixer-configurator/) rules are supported.
@@ -146,6 +149,10 @@ As you see, you can set up your code styling rules in the `lint` section of the
146
149
147
150
- `lint.ignore_dot_files`: Whether to ignore dot files when linting.
148
151
152
+
- `lint.ignore_vc_files`: Whether to ignore version control files when linting.
153
+
154
+
- `lint.parallel`: Whether to run linting in parallel. This can speed up your linting significantly.
155
+
149
156
- `lint.rules`: An array of rules to use for code styling checks. These rules are the same as the rules available in PHP CS Fixer.
150
157
151
158
## Configuring GitHub Actions
@@ -155,26 +162,30 @@ Alchemy can also set up GitHub Actions for you. You can configure what it should
155
162
```yaml
156
163
actions:
157
164
run:
158
-
- 'lint'
159
-
- 'test'
165
+
- lint
166
+
- tests
160
167
php:
161
168
extensions: json, zip
162
169
versions:
163
170
- '8.3'
164
-
event:
165
-
- 'push'
166
-
- 'pull_request'
171
+
events:
172
+
- push
173
+
- pull_request
167
174
```
168
175
169
176
- `actions`: Configuration for GitHub Actions. You can remove this entire section if you don't want to generate GitHub Actions.
170
177
171
-
- `actions.run`: An array of commands to generate GitHub Actions for. The default is `lint` and `test`, but you can remove any command you don't want to generate.
178
+
- `actions.run`: An array of commands to generate GitHub Actions for. The default is `lint` and `tests`, but you can remove any command you don't want to generate.
179
+
180
+
- `actions.fail-fast`: Whether to stop the workflow as soon as one of the jobs fails.
181
+
182
+
- `actions.os`: The operating system to run the GitHub Actions on. The default is `ubuntu-latest`, but you can set `windows-latest` or `macos-latest` or all of them.
172
183
173
184
- `actions.php`: Configuration for PHP in GitHub Actions. You can set the PHP extensions to install and the PHP versions to test against.
174
185
175
-
- `actions.event`: An array of events to generate GitHub Actions for. The default is `push` and `pull_request`, but you can remove any event you don't want to generate.
186
+
- `actions.events`: An array of events to generate GitHub Actions for. The default is `push` and `pull_request`, but you can remove any event you don't want to generate.
176
187
177
-
## Overriding Alchemy Configuration
188
+
<!-- ## Overriding Alchemy Configuration
178
189
179
190
Alchemy is designed to be a tool that sets up your tests and code styling checks with minimal configuration. Once you have written all the tests you need for your app and have your code styling checks, there's no longer the need for Alchemy's training wheels. At that point, you can remove Alchemy from your project and use PHPUnit or Pest directly with PHP CS Fixer.
180
191
@@ -194,4 +205,4 @@ composer run alchemy:eject
194
205
195
206
This command will export all of Alchemy's configuration to `phpunit.xml` and `.php_cs.dist` files in your project root. It will also update the `test` and `lint` commands in your `composer.json` file to use your selected engine and PHP CS Fixer directly. One more fresh install will be made automatically to ensure that your project is up to date, and then Alchemy will be removed from your project automatically.
196
207
197
-
<!-- If you find that you need to override Alchemy's configuration, you can do so by creating a `phpunit.xml` file in your project root. Once you have this file, Alchemy will use it and automatically delete the `alchemy.yml` file. -->
208
+
If you find that you need to override Alchemy's configuration, you can do so by creating a `phpunit.xml` file in your project root. Once you have this file, Alchemy will use it and automatically delete the `alchemy.yml` file. -->
0 commit comments