Make nix the one and only dev environment; remove obsolete tooling
This commit is contained in:
committed by
Wolfgang Walther
parent
1a5f6cce46
commit
de5742fc7d
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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 <<EOF
|
||||
SELECT pg_terminate_backend(pg_stat_activity.pid)
|
||||
FROM pg_stat_activity
|
||||
WHERE pg_stat_activity.datname = '$DB'
|
||||
AND pid <> 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
|
||||
@@ -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:
|
||||
Vendored
-1
@@ -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"
|
||||
Reference in New Issue
Block a user