diff --git a/.circleci/config.yml b/.circleci/config.yml index 72d5626e18..7ad23a6a08 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ workflows: - lint_phpcs - lint_elm - lint_shellcheck - - test: + - test_simpletest_linux: requires: - lint_phpcs - lint_elm @@ -36,17 +36,11 @@ jobs: - checkout - run: ci-scripts/install_shell.sh - run: ci-scripts/test_shell.sh - test: + test_simpletest_linux: machine: image: ubuntu-2004:202111-01 steps: - checkout - - restore_cache: - keys: - - drupal - - run: ci-scripts/install_server.sh - - run: ci-scripts/test_server.sh - - save_cache: - key: drupal - paths: - - /tmp/cache + - run: ci-scripts/install_ddev.sh + - run: ci-scripts/install_drupal.sh + - run: ddev simpletest diff --git a/.ddev/commands/web/simpletest b/.ddev/commands/web/simpletest index 3fe389b9ab..bef5e0bd7a 100755 --- a/.ddev/commands/web/simpletest +++ b/.ddev/commands/web/simpletest @@ -7,4 +7,9 @@ drush en simpletest -y cd .. php ./www/scripts/run-tests.sh --php "$(which php)" --concurrency 4 --verbose --color --url http://eheza-app.ddev.site:8081 Hedley 2>&1 | tee /tmp/simpletest-result.txt + grep -E -i "([1-9]+ fail)|(Fatal error)|([1-9]+ exception)|([0-9]+0 fail)|([0-9]+0 exception)" /tmp/simpletest-result.txt && exit 1 + +drush pm-disable simpletest -y + +exit 0 diff --git a/.ddev/config.yaml b/.ddev/config.yaml index 674ad65142..2b70280aaa 100644 --- a/.ddev/config.yaml +++ b/.ddev/config.yaml @@ -16,6 +16,7 @@ mutagen_enabled: false use_dns_when_possible: true composer_version: "1" web_environment: [] +nodejs_version: "16" # Key features of ddev's config.yaml: diff --git a/.ddev/gitpod-setup-ddev.sh b/.ddev/gitpod-setup-ddev.sh index 9a83e3decd..211b8594d5 100755 --- a/.ddev/gitpod-setup-ddev.sh +++ b/.ddev/gitpod-setup-ddev.sh @@ -15,17 +15,17 @@ cat < ${MYDIR}/config.gitpod.yaml use_dns_when_possible: false # Throwaway ports, otherwise Gitpod throw an error 'port needs to be > 1024' -router_http_port: "8888" +router_http_port: "8080" router_https_port: "8889" additional_fqdns: -- 8888-${shortgpurl} +- 8080-${shortgpurl} - 8025-${shortgpurl} - 8036-${shortgpurl} CONFIGEND # Forces proper external base URL. -DRUPAL_BASE=$(gp url 8888) +DRUPAL_BASE=$(gp url 8080) mkdir -p web/sites/all/drush cat < web/sites/all/drush/drush.yml options: diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index 86b1c520f0..71a1432385 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -8,7 +8,7 @@ RUN sudo apt-get -qq install -y python3 python3-pip libxext6 libxrender1 libxtst RUN pip3 install projector-installer # Install PhpStorm RUN mkdir -p ~/.projector/configs # Prevents projector install from asking for the license acceptance -RUN projector install 'PhpStorm 2021.1.4' --no-auto-run +RUN projector install 'PhpStorm 2022.2.2' --no-auto-run # Install ddev -RUN brew update && brew install drud/ddev/ddev && mkcert -install +RUN curl -fsSL https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh | bash -s v1.21.1 diff --git a/.gitpod.yml b/.gitpod.yml index c5d9b819eb..a9065c0803 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -19,7 +19,7 @@ tasks: ddev gulp elm || (sleep 1 && ddev gulp elm) nohup ddev gulp serve:dev & export DDEV_NONINTERACTIVE=false - gp await-port 8888 && gp preview $(gp url 8888) + gp await-port 8080 && gp preview $(gp url 8080) gp await-port 3000 && gp preview $(gp url 3000) # VScode xdebug extension vscode: @@ -54,7 +54,7 @@ ports: onOpen: ignore visibility: private # Drupal - - port: 8888 + - port: 8080 onOpen: ignore visibility: public # Elm diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 595b521603..0000000000 --- a/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM gizra/drupal-lamp - -ADD . /var/www/html/Server -WORKDIR /var/www/html/Server - -# Add a bash script to finalize all -RUN chmod +x /var/www/html/Server/docker_files/run.sh -ENTRYPOINT ["/var/www/html/Server/docker_files/run.sh"] - -EXPOSE 80 3306 22 diff --git a/README.md b/README.md index f462d6161f..6572b64b6e 100644 --- a/README.md +++ b/README.md @@ -24,52 +24,86 @@ Primary ports: ### GitPod first steps 1. Wait until the Drupal login page shows up -2. Login with `admin` / `admin` into the Drupal backend. -3. Choose "Remote Explorer" on the left and open port 3000 too, either in new browser window or in preview. -4. Use `12345678` as the pairing code (tied to Device nodes at the Drupal side). -5. Use `1234` as the PIN code (tied to the Nurse nodes at the Drupal side). -6. Initiate a sync process. The device status page allows you to initiate a manual sync with the backend. +1. Login with `admin` / `admin` into the Drupal backend. +1. Choose "Remote Explorer" on the left and open port 3000 too, either in new browser window or in preview. +1. Use `12345678` as the pairing code (tied to Device nodes at the Drupal side). +1. Use `1234` as the PIN code (tied to the Nurse nodes at the Drupal side). +1. Initiate a sync process. The device status page allows you to initiate a manual sync with the backend. You can also choose which health centers to sync, for instance "Nyange Health Center" for the tests. -7. Choose the synced health center. -8. Explore the system. +1. Choose the synced health center. +1. Explore the system. -## Develop locally with DDEV +## Try out locally with DDEV -### Requirements + 1. https://ddev.readthedocs.io/en/latest/#installation . Minimum version: [v1.21.1](https://github.com/drud/ddev/releases/tag/v1.21.1) +1. cp .ddev/config.local.yaml.example .ddev/config.local.yaml +1. ddev restart +1. `cp client/src/elm/LocalConfig.Example.elm client/src/elm/LocalConfig.elm` +1. `ddev gulp` +1. Open the [app](http://localhost:3000) in the browser, typically it listens on port 3000. +1. Use `12345678` as the pairing code (tied to Device nodes at the Drupal side). +1. Use `1234` as the PIN code (tied to the Nurse nodes at the Drupal side). +1. Initiate a sync process. The device status page allows you to initiate a manual sync with the backend. + You can also choose which health centers to sync, for instance "Nyange Health Center" for the tests. +1. Choose the synced health center. +1. Explore the system. -- https://ddev.readthedocs.io/en/latest/#installation . Minimum version: [v1.21.1](https://github.com/drud/ddev/releases/tag/v1.21.1) +### Frontend -### Backend +#### Prerequisites + +Make sure the following is installed: + +1. Elm Format (`npm install -g elm-format@0.8.1`), not strictly required for the development, but the standard must be followed, as Travis checks that. Therefore it's highly suggested to run Elm Format upon save at your IDE (https://github.com/avh4/elm-format#editor-integration). #### Installation - cp .ddev/config.local.yaml.example .ddev/config.local.yaml - ddev restart +* Install backend first. +* `cp src/elm/LocalConfig.Example.elm src/elm/LocalConfig.elm` + +You may need to update `src/elm/LocalConfig.elm` if your local URLs are different from the default setting. + +#### Usage + +1. Serve locally, and watch file changes: `ddev gulp` +2. Prepare file for publishing (e.g. minify, and rev file names): `ddev gulp publish` +3. Deploy to GitHub's pages (`gh-pages` branch of your repository): `ddev gulp deploy` + +#### Getting started + +Frontend: http://localhost:3000 (that comes from inside DDEV after `ddev gulp`) + +The Drupal migration creates Devices, Nurses out of the box, so you can +1. Use `12345678` as the pairing code (tied to Device nodes at the Drupal side). +1. Use `1234` as the PIN code (tied to the Nurse nodes at the Drupal side). -Migrate content with either `ddev migrate default` or `ddev migrate sample` -depending on whether you want minimal development content or a full set of -sample content (takes much longer). +If you have a dump from another source, to be able to work locally, first of all, you need to create a Device and a Nurse. +1. `ddev drush uli` to login as `admin` +1. Fulfill https://eheza-app.ddev.site:4443/node/add/device , note the Pairing code. +1. Fulfill https://eheza-app.ddev.site:4443/node/add/nurse , note the PIN code, assign it to group(s) and health center(s). +1. Visit http://localhost:3000 (that comes from inside DDEV), supply the Pairing code and the PIN. + +#### Z-Scores -The installation script will perform following steps: +Our `gulpfile.js` has a task `ddev gulp zscore` which converts the raw Z-Score tables we +downloaded from the WHO web site into three formats: -1. Delete the /www folder. -2. Recreate the /www folder. -3. Download and extract all contrib modules, themes & libraries to the proper - subfolders of the profile. -4. Download and extract Drupal 7 core in the /www folder -5. Create an empty sites/default/files directory -6. Makes a symlink within the /www/profiles directory to the /hedley - directory. -7. Run the Drupal installer (Drush) using the Hedley profile. +- A JSON representation the client can download via an HTTP request (and + cache). +- A JSON representation that the backend can load (to calculate Z-Scores on the + backend. +- An Elm module which contains the JSON representation as a string, so we can + unit-test the Elm code. -***Warning!*** +This should all happen automatically when you run `ddev gulp`. -* The process above will not preserve the data located in the - sites/default/files directory. -* The database is dropped during the installation. +#### Develop how-to +After you edited an Elm file, and the compilation process is executed, the changes are not visible in the browser. +To activate the new version you've just created, click on the "Version" indication in the top-right corner of the app. +That will take you to a page which allows you to check for updates and activate updates. -#### Deploy +#### Deployment The default method assumes Pantheon as the hosting service provider. @@ -127,57 +161,3 @@ If that's a no-go, for the advancedqueue, `supervisord` is a better choice, as that queue needs to be processed all the time. For the reporting, a simple cron job might be sufficient. -### Frontend - -#### Prerequisites - -Make sure the following is installed: - -1. Elm Format (`npm install -g elm-format@0.8.1`), not strictly required for the development, but the standard must be followed, as Travis checks that. Therefore it's highly suggested to run Elm Format upon save at your IDE (https://github.com/avh4/elm-format#editor-integration). - -#### Installation - -* Install backend first. -* `cp src/elm/LocalConfig.Example.elm src/elm/LocalConfig.elm` - -You may need to update `src/elm/LocalConfig.elm` if your local URLs are different from the default setting. - -#### Usage - -1. Serve locally, and watch file changes: `ddev gulp` -2. Prepare file for publishing (e.g. minify, and rev file names): `ddev gulp publish` -3. Deploy to GitHub's pages (`gh-pages` branch of your repository): `ddev gulp deploy` - -#### Getting started - -Frontend: http://localhost:3000 (that comes from inside DDEV after `ddev gulp`) - -The Drupal migration creates Devices, Nurses out of the box, so you can -1. Use `12345678` as the pairing code (tied to Device nodes at the Drupal side). -1. Use `1234` as the PIN code (tied to the Nurse nodes at the Drupal side). - -If you have a dump from another source, to be able to work locally, first of all, you need to create a Device and a Nurse. -1. `ddev drush uli` to login as `admin` -1. Fulfill https://eheza-app.ddev.site:4443/node/add/device , note the Pairing code. -1. Fulfill https://eheza-app.ddev.site:4443/node/add/nurse , note the PIN code, assign it to group(s) and health center(s). -1. Visit http://localhost:3000 (that comes from inside DDEV), supply the Pairing code and the PIN. - -#### Z-Scores - -Our `gulpfile.js` has a task `ddev gulp zscore` which converts the raw Z-Score tables we -downloaded from the WHO web site into three formats: - -- A JSON representation the client can download via an HTTP request (and - cache). -- A JSON representation that the backend can load (to calculate Z-Scores on the - backend. -- An Elm module which contains the JSON representation as a string, so we can - unit-test the Elm code. - -This should all happen automatically when you run `ddev gulp`. - -#### Develop how-to - -After you edited an Elm file, and the compilation process is executed, the changes are not visible in the browser. -To activate the new version you've just created, click on the "Version" indication in the top-right corner of the app. -That will take you to a page which allows you to check for updates and activate updates. diff --git a/ci-scripts/docker_files/Dockerfile b/ci-scripts/docker_files/Dockerfile deleted file mode 100644 index 033ea989b1..0000000000 --- a/ci-scripts/docker_files/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM gizra/drupal-lamp - -COPY "$CIRCLE_WORKING_DIRECTORY/ci-scripts/docker_files/php-memory-limit.ini" "/usr/local/etc/php/conf.d/php-memory-limit.ini" - -ADD $CIRCLE_WORKING_DIRECTORY /var/www/html/Server -WORKDIR /var/www/html/Server - -# Add a bash script to finalize all -RUN chmod +x /var/www/html/Server/ci-scripts/docker_files/run.sh -ENTRYPOINT ["/var/www/html/Server/ci-scripts/docker_files/run.sh"] - -EXPOSE 80 3306 22 diff --git a/ci-scripts/docker_files/LocalConfig.elm b/ci-scripts/docker_files/LocalConfig.elm deleted file mode 100644 index 19c42217ce..0000000000 --- a/ci-scripts/docker_files/LocalConfig.elm +++ /dev/null @@ -1,24 +0,0 @@ -module LocalConfig exposing (localConfigs) - -import Config.Model as Config exposing (Model) -import Dict exposing (..) -import Rollbar - - -local : Model -local = - { backendUrl = "http://server.local" - , name = "local" - , debug = True - , rollbarToken = Rollbar.token "***REMOVED***" - , sandbox = False - } - - -localConfigs : Dict String Model -localConfigs = - Dict.fromList - -- Change "localhost" if you are serving this from a different local - -- URL. - [ ( "server.local", local ) - ] diff --git a/ci-scripts/docker_files/aliases.drushrc.php b/ci-scripts/docker_files/aliases.drushrc.php deleted file mode 100644 index f88aad5d89..0000000000 --- a/ci-scripts/docker_files/aliases.drushrc.php +++ /dev/null @@ -1,5 +0,0 @@ - 'http://server.local', - 'root' => '/var/www/html/Server/server/www', -]; diff --git a/ci-scripts/docker_files/default.apache2.conf b/ci-scripts/docker_files/default.apache2.conf deleted file mode 100644 index eefb4ce3a9..0000000000 --- a/ci-scripts/docker_files/default.apache2.conf +++ /dev/null @@ -1,63 +0,0 @@ -# see http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf - -Mutex file:/var/lock/apache2 default -PidFile /var/run/apache2/apache2.pid -Timeout 300 -KeepAlive On -MaxKeepAliveRequests 100 -KeepAliveTimeout 5 -User www-data -Group www-data -HostnameLookups Off -ErrorLog /proc/self/fd/2 -LogLevel warn - -IncludeOptional mods-enabled/*.load -IncludeOptional mods-enabled/*.conf - -# ports.conf -Listen 80 - - Listen 443 - - - Listen 443 - - - - Options FollowSymLinks - AllowOverride None - Require all denied - - - - Options Indexes FollowSymLinks - AllowOverride All - Require all granted - - -AccessFileName .htaccess - - Require all denied - - -LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined -LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined -LogFormat "%h %l %u %t \"%r\" %>s %O" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -CustomLog /proc/self/fd/1 combined - - - SetHandler application/x-httpd-php - - -# Multiple DirectoryIndex directives within the same context will add -# to the list of resources to look for rather than replace -# https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex -DirectoryIndex disabled -DirectoryIndex index.php index.html - -IncludeOptional conf-enabled/*.conf -IncludeOptional sites-enabled/*.conf diff --git a/ci-scripts/docker_files/docker-compose.yml b/ci-scripts/docker_files/docker-compose.yml deleted file mode 100644 index b1b0241ddd..0000000000 --- a/ci-scripts/docker_files/docker-compose.yml +++ /dev/null @@ -1,31 +0,0 @@ -version: '2' -services: - hub: - privileged: true - image: dosel/zalenium:3.3.1j - tty: true - command: > - start --chromeContainers 1 - --firefoxContainers 0 - --maxDockerSeleniumContainers 2 - --screenWidth 1600 --screenHeight 950 - --timeZone "Asia/Jerusalem" - --videoRecordingEnabled true - --sauceLabsEnabled false - --browserStackEnabled false - --testingBotEnabled false - --startTunnel false - volumes: - - /tmp/videos:/home/seluser/videos - - /var/run/docker.sock:/var/run/docker.sock - - /usr/bin/docker:/usr/bin/docker - - server.local: - privileged: true - image: server - volumes: - - /tmp/test_results:/tmp/test_results - - /tmp/cache:/tmp/travis-cache - environment: - - BUILD_WEBDRIVERIO - # This above means that we pass it from the shell env. diff --git a/ci-scripts/docker_files/helper_functions.sh b/ci-scripts/docker_files/helper_functions.sh deleted file mode 100644 index 9b31ea1f9c..0000000000 --- a/ci-scripts/docker_files/helper_functions.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -# Restore to default colours -RESTORE='\033[0m' -# Bold blue color -LBLUE='\033[01;34m' -RED='\033[00;31m' - -function print_message() { - echo - echo -e "${LBLUE} > $1 ${RESTORE}" -} - -function print_error_message() { - echo - echo -e "${RED} > $1 ${RESTORE}" -} -# Make sure nothing is wrong with the previous command. -function check_last_command() { - if [ $? -ne 0 ]; then - echo - print_error_message "Something went wrong." - exit 1 - fi -} - -export ROOT_DIR="/var/www/html/Server" diff --git a/ci-scripts/docker_files/php-memory-limit.ini b/ci-scripts/docker_files/php-memory-limit.ini deleted file mode 100644 index 5391bc87ca..0000000000 --- a/ci-scripts/docker_files/php-memory-limit.ini +++ /dev/null @@ -1 +0,0 @@ -memory_limit = 256M diff --git a/ci-scripts/docker_files/post_cache.sh b/ci-scripts/docker_files/post_cache.sh deleted file mode 100644 index a68b44677e..0000000000 --- a/ci-scripts/docker_files/post_cache.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -set -euo pipefail - -# Load helper functionality. -source helper_functions.sh - -# Load various configuration variables. -source "$ROOT_DIR"/server/travis.config.sh - -print_message "Post-build cache operations" -date - -TRAVIS_CACHE_DIR=/tmp/travis-cache - -# Populates cache if needed. -if [[ ! -d "$TRAVIS_CACHE_DIR"/node_modules && -d "$ROOT_DIR"/client/node_modules ]]; then - echo "Populating NPM cache from client" - cp -r "$ROOT_DIR"/client/node_modules "$TRAVIS_CACHE_DIR" -fi - -if [[ ! -d "$TRAVIS_CACHE_DIR"/www && -d "$ROOT_DIR"/server/www ]]; then - echo "Populating Drupal cache from server" - # --no-dereference will cause that we skip Hedley profile entirely. - cp --no-dereference -r "$ROOT_DIR"/server/www "$TRAVIS_CACHE_DIR" - - # But in Hedley profile, there are files and directories that are - # dynamic, not stored in the repository, like all the contrib modules. - mkdir -p "$TRAVIS_CACHE_DIR"/www_ignored - cd "$ROOT_DIR" - git ls-files -z --others -i --exclude-standard "$ROOT_DIR"/server/"$PROFILE_NAME" | xargs -I file -0 cp --parents file "$TRAVIS_CACHE_DIR"/www_ignored -fi - -date diff --git a/ci-scripts/docker_files/pre_cache.sh b/ci-scripts/docker_files/pre_cache.sh deleted file mode 100644 index 0f5c40a660..0000000000 --- a/ci-scripts/docker_files/pre_cache.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -set -euo pipefail - -# Load helper functionality. -source helper_functions.sh - -# Load various configuration variables. -source "$ROOT_DIR"/server/travis.config.sh - -print_message "Pre-build cache operations" -date -# Uses the cached objects from Travis cache or invalidate - -TRAVIS_CACHE_DIR=/tmp/travis-cache -NPM_HASH_FILE="$TRAVIS_CACHE_DIR"/.npm.sum -DRUPAL_HASH_FILE="$TRAVIS_CACHE_DIR"/.drupal.sum - -if [[ -f "$NPM_HASH_FILE" ]]; then - PREVIOUS_NPM_HASH=$(<"$NPM_HASH_FILE") -else - PREVIOUS_NPM_HASH="" -fi - -if [[ -f "$DRUPAL_HASH_FILE" ]]; then - PREVIOUS_DRUPAL_HASH=$(<"$DRUPAL_HASH_FILE") -else - PREVIOUS_DRUPAL_HASH="" -fi - -CURRENT_DRUPAL_HASH=$(cat "$ROOT_DIR"/server/"$PROFILE_NAME"/drupal-org.make "$ROOT_DIR"/server/"$PROFILE_NAME"/drupal-org-core.make | sha256sum | cut -f1 -d ' ') -CURRENT_NPM_HASH=$(sha256sum < "$ROOT_DIR"/client/package.json | cut -f1 -d ' ') - -echo "$CURRENT_DRUPAL_HASH" > "$DRUPAL_HASH_FILE" -echo "$CURRENT_NPM_HASH" > "$NPM_HASH_FILE" - -if [[ "$PREVIOUS_NPM_HASH" == "$CURRENT_NPM_HASH" && -d "$TRAVIS_CACHE_DIR"/node_modules ]]; then - echo "NPM build hash matches, copying node_modules ($PREVIOUS_NPM_HASH == $CURRENT_NPM_HASH)" - cp -r "$TRAVIS_CACHE_DIR"/node_modules "$ROOT_DIR"/client -else - echo "NPM build hash does not match, purging cache ($PREVIOUS_NPM_HASH <> $CURRENT_NPM_HASH)" - rm -rf "$TRAVIS_CACHE_DIR"/node_modules -fi - -if [[ "$PREVIOUS_DRUPAL_HASH" == "$CURRENT_DRUPAL_HASH" && -d "$TRAVIS_CACHE_DIR"/www ]]; then - echo "Drupal build hash matches, copying www ($PREVIOUS_DRUPAL_HASH == $CURRENT_DRUPAL_HASH)" - cp -r "$TRAVIS_CACHE_DIR"/www "$ROOT_DIR"/server - cp -r "$TRAVIS_CACHE_DIR"/www_ignored/* "$ROOT_DIR"/ -else - echo "Drupal build hash does not match, purging cache ($PREVIOUS_DRUPAL_HASH <> $CURRENT_DRUPAL_HASH)" - rm -rf "$TRAVIS_CACHE_DIR"/www -fi -date diff --git a/ci-scripts/docker_files/preparing_server.sh b/ci-scripts/docker_files/preparing_server.sh deleted file mode 100644 index 1a5261189e..0000000000 --- a/ci-scripts/docker_files/preparing_server.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash - -# Load helper functionality. -source helper_functions.sh - -# -------------------------------------------------- # -# Start MySQL. -# -------------------------------------------------- # -print_message "Start MySQL." -service mysql start -check_last_command - -# -------------------------------------------------- # -# Configure apache2. -# -------------------------------------------------- # -print_message "Configure apache2." -cd "$ROOT_DIR" || exit 1 -cp ci-scripts/docker_files/default.apache2.conf /etc/apache2/apache2.conf -service apache2 restart -cp ci-scripts/docker_files/server.conf /etc/apache2/sites-available/ -a2ensite server.conf -service apache2 reload -echo "127.0.0.1 server.local" >> /etc/hosts -check_last_command - -# -------------------------------------------------- # -# Installing Drush. -# -------------------------------------------------- # -print_message "Install drush." -export PATH="$HOME/.composer/vendor/bin:$PATH" -# Check drush version. -drush --version -cd "$ROOT_DIR" || exit 1 -cp ci-scripts/docker_files/aliases.drushrc.php ~/.drush/ -check_last_command - -# -------------------------------------------------- # -# Installing Profile. -# -------------------------------------------------- # -print_message "Install Drupal." -cd "$ROOT_DIR"/server || exit 1 -cp travis.config.sh config.sh -if [[ -d www ]]; then - bash scripts/reset -dy -else -./install -dy -fi -check_last_command diff --git a/ci-scripts/docker_files/run.sh b/ci-scripts/docker_files/run.sh deleted file mode 100644 index 846b44dc3f..0000000000 --- a/ci-scripts/docker_files/run.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash -set -e - -cd ci-scripts/docker_files - -if [ -z "$DOCKER_DEBUG" ]; then - # Regular Travis execution, failing on the first error is what we want. - bash pre_cache.sh - - bash preparing_server.sh - - bash run_simpletest.sh - - bash post_cache.sh - -else - # We keep going and open a Bash shell to interactively inspect what failed or - # what's the status of the application. - bash preparing_server.sh || : - - bash run_simpletest.sh || : - - bash -fi diff --git a/ci-scripts/docker_files/run_simpletest.sh b/ci-scripts/docker_files/run_simpletest.sh deleted file mode 100644 index 06f5df8ebb..0000000000 --- a/ci-scripts/docker_files/run_simpletest.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -set -e - -# We should not run the current test under the WebDriverIO build. -if [ "${BUILD_WEBDRIVERIO}" == 1 ]; then - exit 0; -fi - -# Load helper functionality. -source helper_functions.sh - -# -------------------------------------------------- # -# Run SimpleTest -# -------------------------------------------------- # -print_message "Run SimpleTest." -export PATH="$HOME/.composer/vendor/bin:$PATH" -drush @server.local en simpletest -y -cd "$ROOT_DIR"/server -php ./www/scripts/run-tests.sh --php "$(which php)" --concurrency 4 --verbose --color --url http://server.local Hedley 2>&1 | tee /tmp/simpletest-result.txt -grep -E -i "([1-9]+ fail)|(Fatal error)|([1-9]+ exception)|([0-9]+0 fail)|([0-9]+0 exception)" /tmp/simpletest-result.txt && exit 1 - -exit 0 diff --git a/ci-scripts/docker_files/server.conf b/ci-scripts/docker_files/server.conf deleted file mode 100644 index cf4e1e8cd6..0000000000 --- a/ci-scripts/docker_files/server.conf +++ /dev/null @@ -1,4 +0,0 @@ - - DocumentRoot /var/www/html/Server/server/www - ServerName server.local - diff --git a/ci-scripts/install_ddev.sh b/ci-scripts/install_ddev.sh index 3c700a16c4..2386ff0e5e 100755 --- a/ci-scripts/install_ddev.sh +++ b/ci-scripts/install_ddev.sh @@ -1,37 +1,28 @@ #!/usr/bin/env bash set -e -# -------------------------------------------------- # -# Installing ddev dependencies. -# -------------------------------------------------- # -echo "Install Docker Compose." -sudo rm /usr/local/bin/docker-compose -curl -s -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" > docker-compose -chmod +x docker-compose -sudo mv docker-compose /usr/local/bin +MAC=0 +if ! command -v docker &> /dev/null +then + echo "docker could not be found, trying to install it on Mac" + brew install openssh + brew install docker + brew install colima + colima start --cpu 2 --memory 2 --dns=1.1.1.1 + MAC=1 +fi -echo "Upgrade Docker." -sudo apt-get -y remove docker docker-engine docker.io containerd runc || true -sudo apt-key fingerprint 0EBFCD88 -sudo add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" -sudo apt -q update -y || true -sudo apt -q install --only-upgrade docker-ce -y - -# -------------------------------------------------- # -# Installing mkcert. -# -------------------------------------------------- # -echo "Install mkcert." -wget -nv https://github.com/FiloSottile/mkcert/releases/download/v1.4.0/mkcert-v1.4.0-linux-amd64 -sudo mv mkcert-v1.4.0-linux-amd64 /usr/bin/mkcert -chmod +x /usr/bin/mkcert -mkcert -install - -# -------------------------------------------------- # -# Installing ddev. -# -------------------------------------------------- # echo "Install ddev." -curl -s -LO https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh && bash install_ddev.sh v1.17.0 +curl -s -L https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh | bash -echo "Configure ddev." +echo "Configuring ddev." mkdir ~/.ddev -cp "$CIRCLE_WORKING_DIRECTORY"/ci-scripts/global_config.yaml ~/.ddev/ +cp "ci-scripts/global_config.yaml" ~/.ddev/ +docker network create ddev_default || ddev logs + +if [[ "$MAC" == 1 ]]; +then + ddev config global --mutagen-enabled +fi + +export MAC diff --git a/ci-scripts/install_drupal.sh b/ci-scripts/install_drupal.sh new file mode 100755 index 0000000000..289d190cce --- /dev/null +++ b/ci-scripts/install_drupal.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -e + +# -------------------------------------------------- # +# Installing Profile. +# -------------------------------------------------- # +echo "Install Drupal." + +cp .ddev/config.local.yaml.example .ddev/config.local.yaml +ddev restart || ddev logs diff --git a/ci-scripts/install_server.sh b/ci-scripts/install_server.sh deleted file mode 100755 index d8e2c3ac88..0000000000 --- a/ci-scripts/install_server.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -set -e - -# ---------------------------------------------------------------------------- # -# -# Install server dependencies. -# -# ---------------------------------------------------------------------------- # - -# Build our own Docker image based on https://github.com/Gizra/drupal-lamp. -cd /home/circleci/project -docker build -t server -f ci-scripts/docker_files/Dockerfile . - -# Simple Docker run, no need for Zalenium dependencies. -if [ -z "${BUILD_WEBDRIVERIO+x}" ]; then - exit 0; -fi - -# Zalenium requires to download this dependency image first. -docker pull elgalu/selenium:3.7 diff --git a/ci-scripts/test_server.sh b/ci-scripts/test_server.sh deleted file mode 100755 index 5833659569..0000000000 --- a/ci-scripts/test_server.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -euo pipefail - -# ---------------------------------------------------------------------------- # -# -# Run the Behat/WebDriverIO tests. -# -# ---------------------------------------------------------------------------- # - -# Simple Docker run to execute Behat. -mkdir -p /tmp/cache -docker run -v /tmp/cache:/tmp/travis-cache -e "BUILD_WEBDRIVERIO=0" -p 8080:80 server -exit $? diff --git a/server/hedley/drupal-org.make b/server/hedley/drupal-org.make index ec6691542d..6d5b35e7f2 100644 --- a/server/hedley/drupal-org.make +++ b/server/hedley/drupal-org.make @@ -26,7 +26,7 @@ projects[composer_manager][subdir] = "contrib" projects[composer_manager][version] = "1.8" projects[date][subdir] = "contrib" -projects[date][version] = "2.11-beta3" +projects[date][version] = "2.13" projects[diff][subdir] = "contrib" projects[diff][version] = "3.2" @@ -107,13 +107,13 @@ projects[strongarm][subdir] = "contrib" projects[strongarm][version] = "2.0" projects[title][subdir] = "contrib" -projects[title][version] = "1.0-alpha9" +projects[title][version] = "1.0-beta4" projects[token][subdir] = "contrib" projects[token][version] = "1.7" projects[views][subdir] = "contrib" -projects[views][version] = "3.22" +projects[views][version] = "3.27" projects[views_bulk_operations][subdir] = "contrib" projects[views_bulk_operations][version] = "3.5" diff --git a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulSync.class.php b/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulSync.class.php index 91e51e7d52..a079227601 100644 --- a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulSync.class.php +++ b/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulSync.class.php @@ -319,10 +319,17 @@ public function getForHealthCenterStatistics($uuid) { $cached_hash = hedley_stats_handle_cache(HEDLEY_STATS_CACHE_GET, HEDLEY_STATS_SYNC_STATS_CACHE, $health_center_id); if (empty($cached_hash)) { // There's no cached data for health center - trigger statistics - // calculation by adding an AQ item. - hedley_general_add_task_to_advanced_queue_by_id(HEDLEY_STATS_CALCULATE_STATS, $health_center_id, [ - 'health_center_nid' => $health_center_id, - ]); + // calculation, unless health center is member of exclusion list. + $excluded_health_centers = variable_get('hedley_statistics_excluded_health_centers', ''); + $excluded_health_centers = explode(',', $excluded_health_centers); + if (array_search($health_center_id, $excluded_health_centers) === FALSE) { + // This health center is not excluded - trigger statistics calculation + // by adding an AQ item. + hedley_general_add_task_to_advanced_queue_by_id(HEDLEY_STATS_CALCULATE_STATS, $health_center_id, [ + 'health_center_nid' => $health_center_id, + ]); + } + return $return; } diff --git a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/activity/HedleyRestfulActivityBase.class.php b/server/hedley/modules/custom/hedley_restful/plugins/restful/node/activity/HedleyRestfulActivityBase.class.php index edc05d327b..0005604dad 100644 --- a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/activity/HedleyRestfulActivityBase.class.php +++ b/server/hedley/modules/custom/hedley_restful/plugins/restful/node/activity/HedleyRestfulActivityBase.class.php @@ -166,6 +166,11 @@ protected function postExecuteQueryForViewWithDbSelect(array $items = []) { foreach ($this->multiDateFields as $field_name) { $public_name = str_replace('field_', '', $field_name); + + if (empty($item->{$public_name})) { + continue; + } + $dates = []; foreach ($item->{$public_name} as $raw_date) { $date = explode(' ', $raw_date); diff --git a/server/hedley/modules/custom/hedley_stats/hedley_stats.module b/server/hedley/modules/custom/hedley_stats/hedley_stats.module index 8e0ea0f3e0..ec9223e403 100644 --- a/server/hedley/modules/custom/hedley_stats/hedley_stats.module +++ b/server/hedley/modules/custom/hedley_stats/hedley_stats.module @@ -335,9 +335,7 @@ function hedley_stats_calculate_stats_for_health_center($health_center_id) { // Get all clinics of type 'FBF' for the HC. $fbf_clinics = hedley_health_center_get_clinics_by_health_center($health_center_id, 'fbf'); // Calculate statistics that are provided for FBF clinics only. - if (!empty($fbf_clinics)) { - hedley_stats_get_session_attendance_stats_by_health_center($health_center_id, $fbf_clinics); - } + hedley_stats_get_session_attendance_stats_by_health_center($health_center_id, $fbf_clinics); $villages_with_residents = hedley_stats_get_villages_with_residents($health_center_id);