From: Michal Migurski Date: Tue, 29 Dec 2020 02:02:33 +0000 (-0800) Subject: Added complete Rails test suite X-Git-Tag: live~1662^2~3 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/033c3b28b3b2708634f3015449d0c2ed222e26d6 Added complete Rails test suite - Added db/functions/functions.sql to docker-compose DB image - Added `file`, `libgd-dev`, and `unzip` packages to help tests pass --- diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c3b48d561..852e62cf6 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -24,9 +24,13 @@ jobs: - name: Prepare Database run: | docker-compose run --rm web rake db:migrate + docker-compose run web bundle exec rake i18n:js:export docker-compose run --rm web osmosis --rx docker/null-island.osm.xml --wd host=db database=openstreetmap user=openstreetmap password=openstreetmap validateSchemaVersion=no - name: Test Basic Website run: | curl -siL http://127.0.0.1:3000 | egrep '^HTTP/1.1 200 OK' curl -siL http://127.0.0.1:3000 | grep 'OpenStreetMap is the free wiki world map' curl -siL http://127.0.0.1:3000/api/0.6/node/1 | grep 'Null Island' + - name: Test Complete Suite + run: | + docker-compose run --rm web bundle exec rails test:db diff --git a/Dockerfile b/Dockerfile index 6b9110e92..33812d25d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,15 +3,17 @@ FROM ubuntu:20.04 ENV DEBIAN_FRONTEND=noninteractive # Install system packages -RUN apt-get update && \ - apt-get install --no-install-recommends -y \ +RUN apt-get update \ + && apt-get install --no-install-recommends -y \ build-essential \ curl \ default-jre-headless \ + file \ firefox-geckodriver \ imagemagick \ libarchive-dev \ libffi-dev \ + libgd-dev \ libmagickwand-dev \ libpq-dev \ libsasl2-dev \ @@ -23,13 +25,14 @@ RUN apt-get update && \ ruby2.7 \ ruby2.7-dev \ tzdata \ - yarnpkg && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* + unzip \ + yarnpkg \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* # Install current Osmosis -RUN curl -OL https://github.com/openstreetmap/osmosis/releases/download/0.47.2/osmosis-0.47.2.tgz && \ - tar -C /usr/local -xzf osmosis-0.47.2.tgz +RUN curl -OL https://github.com/openstreetmap/osmosis/releases/download/0.47.2/osmosis-0.47.2.tgz \ + && tar -C /usr/local -xzf osmosis-0.47.2.tgz ENV DEBIAN_FRONTEND=dialog @@ -39,8 +42,8 @@ WORKDIR /app # Install Ruby packages ADD Gemfile Gemfile.lock /app/ -RUN gem install bundler && \ - bundle install +RUN gem install bundler \ + && bundle install # Install NodeJS packages ADD package.json yarn.lock /app/ diff --git a/docker/postgres/Dockerfile b/docker/postgres/Dockerfile index 672e2e7a6..9faddd841 100644 --- a/docker/postgres/Dockerfile +++ b/docker/postgres/Dockerfile @@ -2,3 +2,6 @@ FROM postgres:11 # Add db init script to install OSM-specific Postgres functions/extensions. ADD docker/postgres/openstreetmap-postgres-init.sh /docker-entrypoint-initdb.d/ + +# Custom database functions are in a SQL file. +ADD db/functions/functions.sql /usr/local/sbin/osm-db-functions.sql diff --git a/docker/postgres/openstreetmap-postgres-init.sh b/docker/postgres/openstreetmap-postgres-init.sh index d8c619d45..3973311c1 100755 --- a/docker/postgres/openstreetmap-postgres-init.sh +++ b/docker/postgres/openstreetmap-postgres-init.sh @@ -3,9 +3,12 @@ set -ex # Create 'openstreetmap' user psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" <<-EOSQL - CREATE USER openstreetmap PASSWORD 'openstreetmap'; + CREATE USER openstreetmap SUPERUSER PASSWORD 'openstreetmap'; GRANT ALL PRIVILEGES ON DATABASE openstreetmap TO openstreetmap; EOSQL # Create btree_gist extensions psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -c "CREATE EXTENSION btree_gist" openstreetmap + +# Define custom functions +psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -f "/usr/local/sbin/osm-db-functions.sql" openstreetmap