Nixify io and memory tests (#1538)
* Include tests for io and memory in the Nix environment. * include spec tests in nix-shell by default * install the io and memory tests in CI
This commit is contained in:
+38
-18
@@ -17,16 +17,18 @@ artifacts from the `/nix/store`, you can run `nix-collect-garbage`.
|
||||
To build PostgREST from your local checkout of the repository, run:
|
||||
|
||||
```bash
|
||||
nix-build --attr postgrest
|
||||
nix-build --attr postgrestPackage
|
||||
|
||||
```
|
||||
|
||||
This will create a `result` directory that contains the PostgREST binary at
|
||||
`result/bin/postgrest`. The `--attr` parameter (or short: `-A`) tells Nix to
|
||||
build the `postgrest` attribute from the Nix expression it finds in our
|
||||
build the `postgrestPackage` attribute from the Nix expression it finds in our
|
||||
`default.nix` (see below for details). Nix will take care of getting the right
|
||||
GHC version and all the build dependencies.
|
||||
|
||||
## Binary cache
|
||||
|
||||
We recommend that you use the PostgREST binary cache on
|
||||
[cachix](https://cachix.org/):
|
||||
|
||||
@@ -66,17 +68,37 @@ The PostgREST utilities available in `nix-shell` all have names that begin with
|
||||
```
|
||||
# Note: The utilities listed here might not be up to date.
|
||||
[nix-shell]$ postgrest-<tab>
|
||||
postgrest-lint postgrest-test-spec-postgresql-10
|
||||
postgrest-style postgrest-test-spec-postgresql-11
|
||||
postgrest-style-check postgrest-test-spec-postgresql-12
|
||||
postgrest-test-all postgrest-test-spec-postgresql-9.4
|
||||
postgrest-test-spec postgrest-test-spec-postgresql-9.5
|
||||
postgrest-test-spec-all postgrest-test-spec-postgresql-9.6
|
||||
postgrest-lint postgrest-test-spec-postgresql-11
|
||||
postgrest-style postgrest-test-spec-postgresql-12
|
||||
postgrest-style-check postgrest-test-spec-postgresql-9.4
|
||||
postgrest-test-spec postgrest-test-spec-postgresql-9.5
|
||||
postgrest-test-spec-all postgrest-test-spec-postgresql-9.6
|
||||
postgrest-test-spec-postgresql-10
|
||||
|
||||
[nix-shell]$
|
||||
|
||||
```
|
||||
|
||||
Some additional modules like `ioTests`, `memoryTests`, `docker` and `release`
|
||||
have large dependencies that would need to be built before the shell becomes
|
||||
available, which could take an especially long time if the cachix binary cache
|
||||
is not used. You can activate those by passing a flag to `nix-shell`, which
|
||||
will make the respective utilites available:
|
||||
|
||||
```
|
||||
$ nix-shell --arg ioTests true
|
||||
[nix-shell]$ postgrest-<tab>
|
||||
postgrest-lint postgrest-test-spec-postgresql-10
|
||||
postgrest-style postgrest-test-spec-postgresql-11
|
||||
postgrest-style-check postgrest-test-spec-postgresql-12
|
||||
postgrest-test-io postgrest-test-spec-postgresql-9.4
|
||||
postgrest-test-spec postgrest-test-spec-postgresql-9.5
|
||||
postgrest-test-spec-all postgrest-test-spec-postgresql-9.6
|
||||
|
||||
```
|
||||
|
||||
Note that `postgrest-tests-io` is now also available.
|
||||
|
||||
To run one-off commands, you can also use `nix-shell --run <command>`, which
|
||||
will lauch the Nix shell, run that one command and exit. Note that the tab
|
||||
completion will not work with `nix-shell --run`, as Nix has yet to evaluate
|
||||
@@ -94,19 +116,17 @@ $ nix-shell --run "postgrest-foo --bar"
|
||||
A third option is to install utilities that you use very often locally:
|
||||
|
||||
```
|
||||
$ nix-env -f default.nix -iA style
|
||||
$ nix-env -f default.nix -iA devtools
|
||||
|
||||
# `postgrest-style` can now be run directly:
|
||||
$ postgrest-style
|
||||
|
||||
```
|
||||
|
||||
Note that this does not yet work for all utilities (e.g. `postgrest-test-spec` currently
|
||||
needs to be run within the Nix shell environment).
|
||||
|
||||
If you use `nix-shell` very often, you might like to use https://github.com/xzfc/cached-nix-shell,
|
||||
which skips evaluating all our Nix expressions if nothing changed, reducing startup time for the
|
||||
shell considerably.
|
||||
If you use `nix-shell` very often, you might like to use
|
||||
https://github.com/xzfc/cached-nix-shell, which skips evaluating all our Nix
|
||||
expressions if nothing changed, reducing startup time for the shell
|
||||
considerably.
|
||||
|
||||
## Testing
|
||||
|
||||
@@ -116,14 +136,14 @@ temporary test databases:
|
||||
|
||||
```bash
|
||||
# Run the tests against the most recent version of PostgreSQL:
|
||||
$ nix-shell --run postgrest-test-spec
|
||||
$ nix-shell --arg tests true --run postgrest-test-spec
|
||||
|
||||
# Run the tests against all supported versions of PostgreSQL:
|
||||
$ nix-shell --run postgrest-test-spec-all
|
||||
$ nix-shell --arg tests true --run postgrest-test-spec-all
|
||||
|
||||
# Run the tests against a specific version of PostgreSQL (use tab-completion in
|
||||
# nix-shell to see all available versions):
|
||||
$ nix-shell --run postgrest-test-spec-postgresql-9.5.21
|
||||
$ nix-shell --arg tests true --run postgrest-test-spec-postgresql-9.5
|
||||
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user