Skip to content

Commit 5fb329f

Browse files
committed
feat: update alchemy docs
1 parent 20985d9 commit 5fb329f

File tree

1 file changed

+39
-28
lines changed

1 file changed

+39
-28
lines changed

src/docs/utils/testing.md

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,38 +42,40 @@ tests:
4242
processUncoveredFiles: true
4343

4444
lint:
45-
preset: 'PSR12'
46-
ignore_dot_files: true
45+
preset: PSR12
4746
rules:
48-
array_syntax:
49-
syntax: 'short'
5047
no_unused_imports: true
48+
not_operator_with_successor_space: false
5149
single_quote: true
52-
ordered_imports:
53-
imports_order: null
54-
case_sensitive: false
55-
sort_algorithm: 'alpha'
5650

5751
actions:
5852
run:
59-
- 'lint'
60-
- 'test'
53+
- lint
54+
- tests
6155
php:
6256
extensions: json, zip
6357
versions:
6458
- '8.3'
6559
event:
66-
- 'push'
67-
- 'pull_request'
60+
- push
61+
- pull_request
6862
```
6963
7064
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.
7165

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
7474
```
7575

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.
7779

7880
## Configuring Tests
7981

@@ -97,7 +99,7 @@ tests:
9799
processUncoveredFiles: true
98100
```
99101

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.
101103

102104
- `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.
103105

@@ -125,17 +127,18 @@ app:
125127
...
126128
127129
lint:
128-
preset: 'PSR12'
130+
preset: PSR12
129131
ignore_dot_files: true
130132
rules:
131133
array_syntax:
132-
syntax: 'short'
134+
syntax: short
133135
no_unused_imports: true
134136
single_quote: true
135137
ordered_imports:
136138
imports_order: null
137139
case_sensitive: false
138-
sort_algorithm: 'alpha'
140+
sort_algorithm: alpha
141+
...
139142
```
140143

141144
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
146149

147150
- `lint.ignore_dot_files`: Whether to ignore dot files when linting.
148151

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+
149156
- `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.
150157

151158
## Configuring GitHub Actions
@@ -155,26 +162,30 @@ Alchemy can also set up GitHub Actions for you. You can configure what it should
155162
```yaml
156163
actions:
157164
run:
158-
- 'lint'
159-
- 'test'
165+
- lint
166+
- tests
160167
php:
161168
extensions: json, zip
162169
versions:
163170
- '8.3'
164-
event:
165-
- 'push'
166-
- 'pull_request'
171+
events:
172+
- push
173+
- pull_request
167174
```
168175

169176
- `actions`: Configuration for GitHub Actions. You can remove this entire section if you don't want to generate GitHub Actions.
170177

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.
172183

173184
- `actions.php`: Configuration for PHP in GitHub Actions. You can set the PHP extensions to install and the PHP versions to test against.
174185

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.
176187

177-
## Overriding Alchemy Configuration
188+
<!-- ## Overriding Alchemy Configuration
178189

179190
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.
180191

@@ -194,4 +205,4 @@ composer run alchemy:eject
194205

195206
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.
196207

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

Comments
 (0)