Skip to content

Commit

Permalink
Merge branch 'feature-ncd' into feature-ncda
Browse files Browse the repository at this point in the history
  • Loading branch information
anvmn committed Nov 24, 2022
2 parents 6a79916 + 9588f7b commit 0baeec1
Show file tree
Hide file tree
Showing 29 changed files with 134 additions and 532 deletions.
16 changes: 5 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ workflows:
- lint_phpcs
- lint_elm
- lint_shellcheck
- test:
- test_simpletest_linux:
requires:
- lint_phpcs
- lint_elm
Expand Down Expand Up @@ -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
5 changes: 5 additions & 0 deletions .ddev/commands/web/simpletest
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .ddev/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
6 changes: 3 additions & 3 deletions .ddev/gitpod-setup-ddev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ cat <<CONFIGEND > ${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 <<DRUSH_CFG > web/sites/all/drush/drush.yml
options:
Expand Down
4 changes: 2 additions & 2 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -54,7 +54,7 @@ ports:
onOpen: ignore
visibility: private
# Drupal
- port: 8888
- port: 8080
onOpen: ignore
visibility: public
# Elm
Expand Down
10 changes: 0 additions & 10 deletions Dockerfile

This file was deleted.

150 changes: 65 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]`), 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.

Expand Down Expand Up @@ -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 [email protected]`), 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.
12 changes: 0 additions & 12 deletions ci-scripts/docker_files/Dockerfile

This file was deleted.

24 changes: 0 additions & 24 deletions ci-scripts/docker_files/LocalConfig.elm

This file was deleted.

5 changes: 0 additions & 5 deletions ci-scripts/docker_files/aliases.drushrc.php

This file was deleted.

63 changes: 0 additions & 63 deletions ci-scripts/docker_files/default.apache2.conf

This file was deleted.

Loading

0 comments on commit 0baeec1

Please sign in to comment.