diff --git a/.circleci/config.yml b/.circleci/config.yml index 1bdc9d677..f09cb966c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,14 +14,12 @@ jobs: - run: name: Run linter command: | - # Note: For checking this locally, use `make lint`. Or, if using - # `nix`, run `nix-shell --run postgrest-lint` + # Note: For checking this locally, use `nix-shell --run postgrest-lint` postgrest-lint - run: name: Run style check command: | - # 'Note: For checking this locally, use `make style`. Or, if using - # `nix`, run `nix-shell --run postgrest-style` + # 'Note: For checking this locally, use `nix-shell --run postgrest-style` postgrest-style-check # Run tests based on stack and docker against the oldest PostgreSQL version diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 132f939c9..274510ff8 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -44,8 +44,8 @@ your contributions. * All code must also pass [hlint](http://community.haskell.org/~ndm/hlint/) and [stylish-haskell](https://github.com/jaspervdj/stylish-haskell) with no warnings. This helps enforce a uniform style for all committers. Continuous integration will check this as well on every - pull request. There's a useful Makefile that helps with checking this locally. You can run `make commit-check` to do this manually but - we recommend adding it to `.git/hooks/pre-commit` to automatically check this before doing a commit. + pull request. There are useful tools in the nix-shell that help with checking this locally. You can run `postgrest-check` to do this manually but + we recommend adding it to `.git/hooks/pre-commit` as `nix-shell --run postgrest-check` to automatically check this before doing a commit. * For help building the Haskell code on your computer check out the [building from source](https://postgrest.org/en/stable/development.html#build-from-source) docs section. diff --git a/Makefile b/Makefile deleted file mode 100644 index 29b75dad5..000000000 --- a/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -.PHONY: commit-check check clean lint style test test-watch coverage circleci circleci-memory prompt-clean prompt-long-process cachix-push-all - -commit-check: lint style - -check: lint style test - -clean: prompt-clean - stack clean --full - -# For running these you'll need to install hlint and stylish-haskell first. Run: -# stack install hlint stylish-haskell -lint: - git ls-files | grep '\.l\?hs$$' | \ - xargs stack exec -- hlint -X QuasiQuotes -X NoPatternSynonyms "$$@" - -style: - git ls-files | grep '\.l\?hs$$' | xargs stack exec -- stylish-haskell -i - -test: - test/with_tmp_db stack test - -test-watch: - test/with_tmp_db stack build --file-watch --test \ - --test-arguments '--rerun --failure-report=.TESTREPORT --rerun-all-on-success' - -coverage: clean - stack build --coverage - test/with_tmp_db stack test --coverage - -circleci: prompt-long-process - circleci local execute --job stack-test - -circleci-memory: prompt-long-process - circleci local execute --job stack-test-memory - -prompt-clean: - @echo -n 'Are you sure? You will have to rebuild. [y/N] ' && read ans && [ $${ans:-N} = y ] - -prompt-long-process: - @echo -n 'Are you sure? This might take a while. [y/N] ' && read ans && [ $${ans:-N} = y ] - -cachix-push-all: - nix-store -qR --include-outputs $$(nix-instantiate) | cachix push postgrest diff --git a/test/Dockerfile.test b/test/Dockerfile.test deleted file mode 100644 index 7a04c3254..000000000 --- a/test/Dockerfile.test +++ /dev/null @@ -1,13 +0,0 @@ -FROM debian:jessie - -ENV PATH /root/.local/bin:$PATH - -RUN apt-get update \ - && apt-get install -y wget libpq-dev pkg-config libpcre3 libpcre3-dev \ - postgresql-client debconf locales build-essential libffi-dev libgmp-dev git \ - && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ - && echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen \ - && locale-gen \ - && echo 'export LC_ALL=en_US.UTF-8' >> /etc/profile \ - && wget -qO- https://get.haskellstack.org/ | sh - diff --git a/test/destroy_test_db b/test/destroy_test_db deleted file mode 100755 index 74c51641a..000000000 --- a/test/destroy_test_db +++ /dev/null @@ -1,65 +0,0 @@ -#! /usr/bin/env bash -if [ -z "$1" ] - then - echo "Please supply the connection uri for the user with create database privileges" - exit -1 -fi - -if [ -z "$2" ] - then - echo "Please supply the test database name" - exit -1 -fi -if [[ $1 != postgres://* ]] -then - echo "Please use a valid connection URI (https://www.postgresql.org/docs/current/static/libpq-connect.html#AEN45347)" - exit -1 -fi - -BASEPATH=$( cd $(dirname $0) ; pwd -P ) -URI="$1" -DB=$2 - -PGOPTIONS='-c client_min_messages=WARNING' psql "$URI" -Xq >/dev/null -c 'select rolcreatedb from pg_authid where rolname = current_user;' 2>/dev/null -if [ $? -ne 0 ]; then - echo "ERROR: Please specify the user with 'Create DB' permissions, and ensure that the default database for the username exists." - exit 1 -fi - -# plpgsql does not like psql variables, easier to pull this part off with bash variables -PGOPTIONS='-c client_min_messages=WARNING' psql "$URI" -Xq >/dev/null < pg_backend_pid(); - -drop database if exists "$DB"; - --- Find all test users that were members of role 'postgrest_test_author'--that way we don't have to know the --- test user name (in case it was auto-generated). -DO \$\$ -DECLARE - mem text; -BEGIN - FOR mem IN - SELECT pg_get_userbyid(member) - FROM pg_roles r - JOIN pg_auth_members m - ON m.roleid = r.oid - WHERE rolname = 'postgrest_test_author' - LOOP - EXECUTE 'drop role '|| mem || ';'; - END LOOP; -END \$\$; - -DO \$\$ -DECLARE - r text; -BEGIN - FOR r IN - VALUES('postgrest_test_author'),('postgrest_test_anonymous'),('postgrest_test_default_role') - LOOP - EXECUTE 'drop role if exists '|| r || ';'; - END LOOP; -END \$\$; -EOF diff --git a/test/docker-compose.yml b/test/docker-compose.yml deleted file mode 100644 index 0a231e7a8..000000000 --- a/test/docker-compose.yml +++ /dev/null @@ -1,30 +0,0 @@ -version: "3.6" - -services: - test: - build: - context: . - dockerfile: Dockerfile.test - depends_on: - - postgres - working_dir: /root/postgrest - volumes: - - ../:/root/postgrest - - stack-linux:/root/.stack - - stack-work:/root/postgrest/.stack-work - command: bash -c "POSTGREST_TEST_CONNECTION=$$(test/create_test_db 'postgres://postgres:postgres@postgres' test_db) stack test" - - postgres: - image: postgres:13 - environment: - POSTGRES_PASSWORD: postgres - volumes: - - postgres:/var/lib/postgresql/data - -volumes: - postgres: - driver_opts: - type: tmpfs - device: tmpfs - stack-linux: - stack-work: diff --git a/test/fixtures/dumpfixture.sh b/test/fixtures/dumpfixture.sh deleted file mode 100755 index eba1a1a82..000000000 --- a/test/fixtures/dumpfixture.sh +++ /dev/null @@ -1 +0,0 @@ -pg_dump --host localhost --port 5432 --username "postgres" --no-password --format plain --column-inserts --verbose --file "./test/fixtures/schema.sql" "postgrest_test"