|
1 | | -# Aqua.jl |
| 1 | +# Aqua.jl: |
| 2 | +## *A*uto *QU*ality *A*ssurance for Julia packages |
2 | 3 |
|
3 | | -```@autodocs |
4 | | -Modules = [Aqua] |
5 | | -Private = false |
| 4 | +Aqua.jl provides functions to run a few automatable checks for Julia packages: |
| 5 | + |
| 6 | +* There are no method ambiguities. |
| 7 | +* There are no undefined `export`s. |
| 8 | +* There are no unbound type parameters. |
| 9 | +* There are no stale dependencies listed in `Project.toml`. |
| 10 | +* Check that test target of the root project `Project.toml` and test project |
| 11 | + (`test/Project.toml`) are consistent. |
| 12 | +* Check that all external packages listed in `deps` have corresponding |
| 13 | + `compat` entry. |
| 14 | +* `Project.toml` formatting is compatible with Pkg.jl output. |
| 15 | +* There are no "obvious" type piracies. |
| 16 | + |
| 17 | +## Quick usage |
| 18 | + |
| 19 | +Call `Aqua.test_all(YourPackage)` from the REPL, e.g., |
| 20 | + |
| 21 | +```julia |
| 22 | +using YourPackage |
| 23 | +using Aqua |
| 24 | +Aqua.test_all(YourPackage) |
| 25 | +``` |
| 26 | + |
| 27 | +## How to add Aqua.jl... |
| 28 | + |
| 29 | +### ...as a test dependency? |
| 30 | + |
| 31 | +There are two ways to add Aqua.jl as a test dependency to your package. |
| 32 | +To avoid breaking tests when a new Aqua.jl version is released, it is |
| 33 | +recommended to add a version bound for Aqua.jl. |
| 34 | + |
| 35 | + 1. In `YourPackage/test/Project.toml`, add Aqua.jl to `[dep]` and `[compat]` sections, like |
| 36 | + ```toml |
| 37 | + [deps] |
| 38 | + Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" |
| 39 | + Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" |
| 40 | + |
| 41 | + [compat] |
| 42 | + Aqua = "0.6" |
| 43 | + ``` |
| 44 | + |
| 45 | + 2. In `YourPackage/Project.toml`, add Aqua.jl to `[compat]` and `[extras]` section and the `test` target, like |
| 46 | + ```toml |
| 47 | + [compat] |
| 48 | + Aqua = "0.6" |
| 49 | + |
| 50 | + [extras] |
| 51 | + Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" |
| 52 | + Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" |
| 53 | + |
| 54 | + [targets] |
| 55 | + test = ["Aqua", "Test"] |
| 56 | + ``` |
| 57 | + |
| 58 | +If your package supports Julia pre-1.2, you need to use the second approach, |
| 59 | +although you can use both approaches at the same time. |
| 60 | + |
| 61 | +!!! warning |
| 62 | + In normal use, `Aqua.jl` should not be added to `[deps]` in `YourPackage/Project.toml`! |
| 63 | + |
| 64 | +### ...to your tests? |
| 65 | +It is recommended to create a separate file `YourPackage/test/Aqua.jl` that gets included in `YourPackage/test/runtests.jl` |
| 66 | +with either |
| 67 | + |
| 68 | +```julia |
| 69 | +using Aqua |
| 70 | +Aqua.test_all(YourPackage) |
| 71 | +``` |
| 72 | +or some fine-grained checks with options, e.g., |
| 73 | + |
| 74 | +```julia |
| 75 | +using Aqua |
| 76 | + |
| 77 | +@testset "Aqua.jl" begin |
| 78 | + Aqua.test_all( |
| 79 | + YourPackage; |
| 80 | + ambiguities=(exclude=[SomePackage.some_function], broken=true), |
| 81 | + unbound_args=true, |
| 82 | + undefined_exports=true, |
| 83 | + project_extras=true, |
| 84 | + stale_deps=(ignore=[:SomePackage],), |
| 85 | + deps_compat=(ignore=[:SomeOtherPackage],), |
| 86 | + project_toml_formatting=true, |
| 87 | + piracy=false, |
| 88 | + ) |
| 89 | +end |
| 90 | +``` |
| 91 | +For more details on the options, see the respective functions [below](@ref test_functions). |
| 92 | + |
| 93 | +### Example uses |
| 94 | +The following is a small selection of packages that use Aqua.jl: |
| 95 | +- [GAP.jl](https://github.com/oscar-system/GAP.jl) |
| 96 | +- [Hecke.jl](https://github.com/thofma/Hecke.jl) |
| 97 | +- [Oscar.jl](https://github.com/oscar-system/Oscar.jl) |
| 98 | + |
| 99 | +## [Test functions](@id test_functions) |
| 100 | +```@docs |
| 101 | +Aqua.test_all |
6 | 102 | ``` |
7 | 103 |
|
8 | 104 | ```@autodocs |
9 | | -Modules = [Aqua, Aqua.Piracy] |
10 | | -Public = false |
11 | | -Filter = t -> startswith(String(nameof(t)), "test_") |
| 105 | +Modules = [Aqua] |
| 106 | +Filter = t -> startswith(String(nameof(t)), "test_") && t != Aqua.test_all |
12 | 107 | ``` |
0 commit comments