Bump nixpkgs and simplify/clean up nix setup (#1529)

* Refactor tests and fix README

* fix linting hints from new hlint version

* postgrest-style with new nixpkgs-fmt
This commit is contained in:
Remo Rechkemmer
2020-05-20 21:30:20 -05:00
committed by GitHub
parent e6874c866d
commit 48c9ac36b1
27 changed files with 268 additions and 344 deletions
+31 -33
View File
@@ -5,6 +5,7 @@
, git
, lib
, postgrestBuildEnv
, postgresql
, postgresqlVersions
, runtimeShell
, writeShellScript
@@ -14,53 +15,50 @@ let
# Wrap the `test/with_tmp_db` script with the required dependencies from Nix.
withTmpDb =
postgresql:
writeShellScript "postgrest-test-${postgresql.name}"
''
set -euo pipefail
writeShellScript "postgrest-test-${postgresql.name}"
''
set -euo pipefail
export PATH=${postgresql}/bin:${git}/bin:${runtimeShell}/bin:"$PATH"
export PATH=${postgresql}/bin:${git}/bin:${runtimeShell}/bin:"$PATH"
exec ${../test/with_tmp_db} "$@"
'';
exec ${../test/with_tmp_db} "$@"
'';
# Script to run the Haskell test suite against a specific version of
# PostgreSQL.
testSpec =
name: postgresql:
writeShellScriptBin name
''
set -euo pipefail
writeShellScriptBin
name
''
set -euo pipefail
cat << EOF
cat << EOF
Running spec against ${postgresql.name}...
Running spec against ${postgresql.name}...
EOF
EOF
# TODO: Make this work outside nix-shell when installed with nix-env.
# Probably using postgrestBuildEnv somehow?
${withTmpDb postgresql} ${cabal-install}/bin/cabal v2-test \
--test-show-detail=direct
# TODO: Make this work outside nix-shell when installed with nix-env.
# Probably using postgrestBuildEnv somehow?
${withTmpDb postgresql} ${cabal-install}/bin/cabal v2-test \
--test-show-detail=direct
cat << EOF
cat << EOF
Done running spec against ${postgresql.name}.
Done running spec against ${postgresql.name}.
EOF
'';
# The PostgreSQL version that we run the tests against by default.
defaultPostgresql =
builtins.head postgresqlVersions;
EOF
'';
defaultTestSpec =
testSpec "postgrest-test-spec" defaultPostgresql;
testSpec "postgrest-test-spec" postgresql;
# Create a `testSpec` for each PostgreSQL version that we want to test
# against.
testSpecVersions =
map
(postgresql: testSpec "postgrest-test-spec-${postgresql.name}" postgresql)
lib.mapAttrsToList
(name: postgresql: testSpec "postgrest-test-spec-${name}" postgresql)
postgresqlVersions;
# Helper script for running the tests against all PostgreSQL versions.
@@ -69,14 +67,14 @@ let
testRunners =
map (test: "${test}/bin/${test.name}") testSpecVersions;
in
writeShellScriptBin "postgrest-test-spec-all"
''
set -euo pipefail
writeShellScriptBin "postgrest-test-spec-all"
''
set -euo pipefail
${lib.concatStringsSep "\n" testRunners}
'';
${lib.concatStringsSep "\n" testRunners}
'';
in
# Create an environment that contains all the utility scripts for running tests
# Create an environment that contains all the utility scripts for running tests
# that we defined above.
buildEnv {
name =