Skip to content

Commit 381b007

Browse files
Merge with upstream
1 parent b91f180 commit 381b007

File tree

110 files changed

+598394
-288142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+598394
-288142
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
*sw?
2+
/build
23
/node_modules
4+
/perf/provisioning/secure/*
5+
/provisioning/secure/*
36
/releases
4-
/tmp
7+
/secure
8+
/secure.tar.gz
59
/vagrant/.vagrant
10+
npm-debug.log

.travis.yml

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,54 @@
1-
# .travis.yml
21
language: node_js
3-
sudo: false
2+
sudo: required
3+
services:
4+
- docker
45
node_js:
5-
- "0.12"
6+
- '6'
67
addons:
7-
postgresql: "9.4"
88
apt:
99
packages:
10-
- postgresql-contrib-9.4
11-
- postgresql-9.4-plv8
10+
- python-pip
11+
env:
12+
global:
13+
- secure: OhbEMmdvXwMoNsQCzWRIQsYc6LwcRAARjAoVv150LRTDB4s/FPo/67DQuUkcMJPp5+HyGh2/9giNArmn7NcMiXHtiUZKQKRkt758Ga9IdYidHJrmUI3wZKJns6W7SeCr4GSsd7cVcDo/ubFQQGZK2yIlRRF3zmWnEcPt9uLIlyJlrBu5DKUev65n/AdUzaqGf48efavz97A9DCVxwuE44jGp5Bqjoqqrben97j9U5L8A3APGIcweBaxcLQPunIZboA9DX8xrP/Y+C0cTJlJksbEb8jDNwrK+xLmX/Bd3o5fQh83/wyu2c/E9WrOR96e74VutLjXhdt5gOfzD79Q09lPziYg+0PkR8NaBwHldpmzRf75asem83OYGlNDacd2dkyiuqCNpa1xOIutdk9IKl0FNCn5C4OYFXaR6vPNwwZWF4lt+cXXs0il2/buWkR1Ydt35W1j0LHAPLezrrD839klfxHmVd+3BEf1RB9TQGMzSseSdMEsx5pWJh1k3gM/QGTRpjeaTat49oHEusSx6P+nU5L1VzfPN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Vt+crA9VlIUvfd3Oli1KaEB7GsTCZs2xFPc48oinchei2T/Kb7oB13YW+6T2QYiWEjCw5Y9OEA7G+Ic7KSRqNruUH/63xaBEeCmBKUw5pbg/OKXvHEbI68AlMTls/xEoCPXY52KFUBCJ5tws8MXlC5vdzotjAz+gcBDz3pbQEaEA+MeCz1j9ogRTQCJ7lxqK8zWO8z4HV2u0ZOZ0sHA5IrHuHwiuLNjZyHwneTS+ov889s5ChdChvObRbcLOXtfQUABhvz69zyX/5c8kfVmniQ+FfYNmskNCPoqJifiZESjTnGbgknfNyHeiH2+QHU7nkpQjzbNUpePbJv3hMWSyh4gDT2ky6rxikvaLmsXZLybmvLyiF733VeF2svNXraaJ8yTW6ss/rhfTdESXxMghalFV4Pk02jW2PzLaFND3RH7ZY=
16+
matrix:
17+
- PLV8_VERSION=1.4.3 SCHEMAS="public"
18+
- PLV8_VERSION=1.4.4 SCHEMAS="public"
19+
- PLV8_VERSION=1.4.7 SCHEMAS="foo bar"
20+
# Unfortunately plv8 1.5.x hard to install because required very new libv8 version <https://github.com/plv8/plv8/issues/158#issuecomment-189621200>.
1221
notifications:
13-
slack: healthsamurai:lKl1jXV360NHMSzV2nwndkOv
14-
slack: fhirbase:isitOv0KvPgaMzrccuAzVUwB
15-
16-
# - sudo apt-get install postgresql-contrib-9.4 postgresql-9.4-plv8 -qq -y
17-
before_script:
18-
- npm install && cd plpl && npm install
19-
- npm install -g mocha && npm install -g coffee-script
20-
- psql -c "CREATE USER fb WITH PASSWORD 'fb'"
21-
- psql -c 'ALTER ROLE fb WITH SUPERUSER'
22-
- psql -c 'CREATE DATABASE fhirbase;' -U postgres
23-
- psql -c '\dt' -U postgres
24-
- cd ..
25-
26-
script: export DATABASE_URL=postgres://fb:fb@localhost:5432/fhirbase && export TRAVIS=true && FB_SCHEMA=foo ./build.sh && { echo "CREATE SCHEMA IF NOT EXISTS foo; SET search_path TO foo;"; cat tmp/build.sql; } | psql fhirbase && FB_SCHEMA=foo npm run test && FB_SCHEMA=bar ./build.sh && { echo "CREATE SCHEMA IF NOT EXISTS bar; SET search_path TO bar;"; cat tmp/build.sql; } | psql fhirbase && FB_SCHEMA=bar npm run test
22+
slack: fhirbase:isitOv0KvPgaMzrccuAzVUwB
23+
before_install:
24+
- |
25+
cd $TRAVIS_BUILD_DIR || exit 1
26+
docker build --tag=fhirbase-tests-in-schemas:pg-9.4-plv8-$PLV8_VERSION \
27+
--file=Dockerfile-pg-9.4-plv8-$PLV8_VERSION ./ || exit 1
28+
script: |
29+
docker run fhirbase-tests-in-schemas:pg-9.4-plv8-$PLV8_VERSION \
30+
--schemas="$SCHEMAS" --install-fhirbase || exit 1
31+
after_success: |
32+
if [ "$PLV8_VERSION" == "1.4.7" ] && [ ! -z "$TRAVIS_TAG" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
33+
echo $PASS | gpg --passphrase-fd 0 --decrypt --output - ./secure.tar.gz.asc \
34+
| tar --extract --gzip --file -
35+
[[ ${PIPESTATUS[0]} -ne 0 || ${PIPESTATUS[1]} -ne 0 ]] && exit 1
36+
pip install --user --upgrade 'ansible<2' || exit 1
37+
pip install --user --upgrade boto || exit 1
38+
cd perf/provisioning || exit 1
39+
export ANSIBLE_HOST_KEY_CHECKING=False || exit 1
40+
python2 ~/.local/bin/ansible-playbook \
41+
--inventory-file=inventories/ec2 \
42+
ec2_start.yml || exit 1
43+
python2 ~/.local/bin/ansible-playbook \
44+
--private-key=../../secure/fhirbase_performance_benchmark.pem \
45+
--inventory-file=inventories/ec2.py \
46+
--user=ubuntu \
47+
bootstrap.yml || exit 1
48+
python2 ~/.local/bin/ansible-playbook \
49+
--private-key=../../secure/fhirbase_performance_benchmark.pem \
50+
--inventory-file=inventories/ec2.py \
51+
--user=ubuntu \
52+
--extra-vars="timestamp=foobar" \
53+
perf.yml || exit 1
54+
fi

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Contributing
2+
3+
* Star us on GitHub
4+
* If you encountered a bug, please [make an Issue][]
5+
* Contribute to fhirbase
6+
7+
[make an Issue]: https://github.com/fhirbase/fhirbase-plv8/issues/new
8+
9+
We love pull requests from everyone.
10+
11+
Some things that will increase the chance that your pull request is accepted:
12+
13+
* Write tests.
14+
* Write a [good commit message][commit].
15+
16+
[commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html

ChangeLog

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2016-04-11 Danil Kutkevich <[email protected]>
2+
3+
* src/core/schema.coffee (fhir_create_all_storages) Implements the
4+
function for creating tables for all known resource types.
5+
6+
* src/core/schema.coffee (fhir_drop_all_storages) Implements
7+
the function for dropping all resources tables.
8+
9+
2016-04-10 Danil Kutkevich <[email protected]>
10+
11+
* src/fhir/search.litcoffee (_search_sql) Respects filter
12+
by `updated_at` (#97).
13+
14+
* src/fhir/query_string.coffee (grouping)
15+
Respects `_lastUpdated` (#97).
16+
117
2016-02-03 Danil Kutkevich <[email protected]>
218

319
* src/fhir/crud.coffee (fhir_patch_resource): Fix `fhir_patch_resource`.

Dockerfile renamed to Dockerfile-dev

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM ubuntu:14.04.3
1+
FROM ubuntu:16.04
22
MAINTAINER Nicola <[email protected]>, \
33
BazZy <[email protected]>, \
44
Danil Kutkevich <[email protected]>
55

6-
ENV REFRESHED_AT 2015-12-24
6+
ENV REFRESHED_AT 20160425T0900Z
77

88
RUN localedef --force --inputfile=en_US --charmap=UTF-8 \
99
--alias-file=/usr/share/locale/locale.alias \
@@ -13,9 +13,9 @@ ENV LANG en_US.UTF-8
1313
RUN apt-get --yes update
1414
RUN apt-get --yes upgrade
1515

16-
# Add PostgreSQL 9.4 apt repository
16+
# Add PostgreSQL (9.1, 9.2, 9.3, 9.4, 9.5) apt repository
1717
# <http://www.postgresql.org/download/linux/ubuntu/>.
18-
RUN apt-get install --yes curl
18+
RUN apt-get install --yes curl sudo
1919
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main' \
2020
> /etc/apt/sources.list.d/pgdg.list
2121
RUN curl --silent https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
@@ -34,12 +34,6 @@ RUN apt-get install --yes postgresql-$PG_MAJOR
3434
RUN apt-get install --yes git build-essential libv8-dev postgresql-server-dev-$PG_MAJOR
3535
RUN apt-get install --yes nodejs-dev
3636

37-
ENV PLV8_BRANCH r1.4
38-
39-
RUN cd /tmp && git clone -b $PLV8_BRANCH https://github.com/plv8/plv8.git \
40-
&& cd /tmp/plv8 \
41-
&& make all install
42-
4337
# Adjust PostgreSQL configuration so that remote connections to the
4438
# database are possible.
4539
RUN echo 'host all all 0.0.0.0/0 md5' >> /etc/postgresql/$PG_MAJOR/main/pg_hba.conf
@@ -74,36 +68,53 @@ RUN cd ~ \
7468
&& git submodule update --init --recursive
7569

7670
# Install nodejs.
77-
RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh \
71+
RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh \
7872
| bash
79-
RUN bash -lc 'source ~/.nvm/nvm.sh && nvm install 5.3'
80-
RUN bash -lc 'cd ~/fhirbase && source ~/.nvm/nvm.sh && nvm use 5.3 \
73+
RUN bash -lc 'source ~/.nvm/nvm.sh && nvm install 6.2.0'
74+
RUN bash -lc 'cd ~/fhirbase && source ~/.nvm/nvm.sh && nvm use 6.2.0 \
8175
&& npm install'
82-
RUN bash -lc 'cd ~/fhirbase/plpl && source ~/.nvm/nvm.sh && nvm use 5.3 \
76+
RUN bash -lc 'cd ~/fhirbase/plpl && source ~/.nvm/nvm.sh && nvm use 6.2.0 \
8377
&& npm install'
8478

79+
USER root
80+
81+
ENV PLV8_VERSION v1.4.7
82+
83+
RUN cd /tmp \
84+
&& git clone https://github.com/plv8/plv8.git \
85+
&& cd /tmp/plv8 \
86+
&& git checkout $PLV8_VERSION \
87+
&& make all install
88+
89+
USER fhirbase
90+
8591
# Install fhirbase.
8692
RUN bash -lc 'sudo service postgresql start \
8793
&& cd ~/fhirbase \
88-
&& source ~/.nvm/nvm.sh && nvm use 5.3 \
94+
&& source ~/.nvm/nvm.sh && nvm use 6.2.0 \
8995
&& export PATH="$HOME"/fhirbase/node_modules/coffee-script/bin:"$PATH" \
9096
&& export DATABASE_URL=postgres://fhirbase:fhirbase@localhost:5432/fhirbase \
91-
&& ~/fhirbase/build.sh \
92-
&& cat ~/fhirbase/tmp/build.sql | psql fhirbase'
97+
&& ~/fhirbase/build-commit.sh --rebuild \
98+
&& cat ~/fhirbase/build/latest/build.sql | psql fhirbase'
9399

94-
# Run test suite.
95-
RUN bash -lc 'sudo service postgresql start \
96-
&& cd ~/fhirbase \
97-
&& source ~/.nvm/nvm.sh && nvm use 5.3 \
98-
&& export DATABASE_URL=postgres://fhirbase:fhirbase@localhost:5432/fhirbase \
99-
&& npm run test'
100+
101+
USER root
102+
103+
COPY docker-run-tests.sh /
104+
RUN chmod a+rwx /docker-run-tests.sh
105+
RUN chown fhirbase /docker-run-tests.sh
106+
107+
# Install utils.
108+
RUN apt-get install --yes openssh-server aptitude
109+
110+
USER fhirbase
100111

101112
# Expose the PostgreSQL port.
102113
EXPOSE 5432
103114

104115
# Add VOLUMEs to allow backup of config, logs, socket and databases
105116
VOLUME ['/etc/postgresql', '/var/log/postgresql', '/var/lib/postgresql', '/var/run/postgresql']
106117

107-
WORKDIR ~/fhirbase
118+
WORKDIR /home/fhirbase
108119

109-
CMD sudo service postgresql start
120+
CMD /bin/bash

Dockerfile-pg-9.4-plv8-1.4.3

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
FROM ubuntu:14.04.4
2+
MAINTAINER Danil Kutkevich <[email protected]>
3+
4+
ENV REFRESHED_AT 20160418T0800Z
5+
6+
RUN localedef --force --inputfile=en_US --charmap=UTF-8 \
7+
--alias-file=/usr/share/locale/locale.alias \
8+
en_US.UTF-8
9+
ENV LANG en_US.UTF-8
10+
11+
RUN apt-get --yes update
12+
# RUN apt-get --yes upgrade
13+
14+
# Add PostgreSQL (9.1, 9.2, 9.3, 9.4, 9.5) apt repository
15+
# <http://www.postgresql.org/download/linux/ubuntu/>.
16+
RUN apt-get install --yes curl
17+
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main' \
18+
> /etc/apt/sources.list.d/pgdg.list
19+
RUN curl --silent https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
20+
sudo apt-key add -
21+
22+
RUN apt-get --yes update
23+
# RUN apt-get --yes upgrade
24+
25+
# Install PostgreSQL.
26+
ENV PG_MAJOR 9.4
27+
28+
RUN apt-get install --yes postgresql-$PG_MAJOR
29+
30+
# Install plv8 (in case of plv8 compilation issues address to
31+
# README in <https://github.com/clkao/docker-postgres-plv8>).
32+
RUN apt-get install --yes git build-essential libv8-dev postgresql-server-dev-$PG_MAJOR
33+
RUN apt-get install --yes nodejs-dev
34+
35+
# Adjust PostgreSQL configuration so that remote connections to the
36+
# database are possible.
37+
RUN echo 'host all all 0.0.0.0/0 md5' >> /etc/postgresql/$PG_MAJOR/main/pg_hba.conf
38+
RUN echo 'local all all trust' >> /etc/postgresql/$PG_MAJOR/main/pg_hba.conf
39+
RUN echo "listen_addresses='*'" >> /etc/postgresql/$PG_MAJOR/main/postgresql.conf
40+
41+
USER postgres
42+
43+
# Fix PostgreSQL locale
44+
# <http://stackoverflow.com/questions/16736891/pgerror-error-new-encoding-utf8-is-incompatible#16737776>,
45+
# <http://www.postgresql.org/message-id/[email protected]>,
46+
# <http://www.postgresql.org/docs/current/static/multibyte.html#AEN35730>.
47+
RUN service postgresql start \
48+
&& psql --command="UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';" \
49+
&& psql --command="DROP DATABASE template1;" \
50+
&& psql --command="CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8';" \
51+
&& psql --command="UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';" \
52+
&& psql --command="CREATE ROLE fhirbase WITH SUPERUSER LOGIN PASSWORD 'fhirbase';" \
53+
&& psql --command="CREATE DATABASE fhirbase WITH OWNER fhirbase ENCODING = 'UTF8';"
54+
55+
USER root
56+
57+
RUN useradd --user-group --create-home --shell /bin/bash fhirbase \
58+
&& echo 'fhirbase:fhirbase' | chpasswd && adduser fhirbase sudo
59+
RUN echo 'fhirbase ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
60+
61+
USER fhirbase
62+
63+
RUN cd ~ \
64+
&& git clone https://github.com/fhirbase/fhirbase-plv8.git fhirbase \
65+
&& cd ~/fhirbase \
66+
&& git submodule update --init --recursive
67+
68+
# Install nodejs.
69+
RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh \
70+
| bash
71+
RUN bash -lc 'source ~/.nvm/nvm.sh && nvm install 6.2.0'
72+
RUN bash -lc 'cd ~/fhirbase && source ~/.nvm/nvm.sh && nvm use 6.2.0 \
73+
&& npm install'
74+
RUN bash -lc 'cd ~/fhirbase/plpl && source ~/.nvm/nvm.sh && nvm use 6.2.0 \
75+
&& npm install'
76+
77+
USER root
78+
79+
ENV PLV8_VERSION v1.4.3
80+
81+
RUN cd /tmp \
82+
&& git clone https://github.com/plv8/plv8.git \
83+
&& cd /tmp/plv8 \
84+
&& git checkout $PLV8_VERSION \
85+
&& make all install
86+
87+
COPY docker-run-tests.sh /
88+
RUN chmod a+rwx /docker-run-tests.sh
89+
RUN chown fhirbase /docker-run-tests.sh
90+
91+
USER fhirbase
92+
93+
# Install fhirbase and run test suite.
94+
ENTRYPOINT ["/docker-run-tests.sh"]
95+
96+
# CMD ["--schemas='public'"]

0 commit comments

Comments
 (0)