Skip to content

Commit

Permalink
Merge pull request #576 from EyeSeeTea/development
Browse files Browse the repository at this point in the history
Release 2.0.0
  • Loading branch information
adrianq authored Aug 21, 2020
2 parents 851c48d + 71bb9ac commit 4bcccb4
Show file tree
Hide file tree
Showing 376 changed files with 47,030 additions and 17,969 deletions.
24 changes: 22 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,38 @@ module.exports = {
"react-app",
"prettier",
"eslint:recommended",
"plugin:react/recommended",
"plugin:cypress/recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended",
],
rules: {
"no-console": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/explicit-function-return-type": ["off"],
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
"react/prop-types": "off",
"react/display-name": "off",
"no-unused-expressions": "off",
"no-useless-concat": "off",
"no-useless-constructor": "off",
"no-unexpected-multiline": "off",
"default-case": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/member-delimiter-style": "off",
"@typescript-eslint/type-annotation-spacing": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"no-extra-semi": "off",
"no-mixed-spaces-and-tabs": "off",
"react-hooks/rules-of-hooks": "error",
Expand Down
8 changes: 4 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
### :pushpin: References

* **Issue:** Closes #?
- **Issue:** Closes #?

### :memo: Implementation

-

### :art: Screenshots


### :fire: Is there anything the reviewer should know to test it?


### :bookmark_tabs: Others

- Any change in the [GUI library](https://github.com/EyeSeeTea/d2-ui-components)? If so, what branch/PR?
- Any change in the [GUI library](https://github.com/EyeSeeTea/d2-ui-components)? If so, what branch/PR?

- Any change in the [D2 Api](https://github.com/EyeSeeTea/d2-api)? If so, what branch/PR?
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# production
manifest.webapp
/build
/dist
*.zip

# misc
Expand Down
69 changes: 54 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,61 @@
language: node_js
node_js:
- 8.15.0
- 12.13.0
dist: bionic
cache:
directories:
- "$HOME/.cache"
directories:
- "$HOME/.cache"
env:
- PORT=8081 REACT_APP_DHIS2_BASE_URL=http://localhost:8080 REACT_APP_CYPRESS=true CYPRESS_EXTERNAL_API=http://localhost:8080 CYPRESS_ROOT_URL=http://localhost:8081 FEEDBACK_REPO=EyeSeeTea/feedback-ci
before_install:
- echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
# Install python dependencies
- sudo apt-get update
- sudo apt-get install docker.io docker-compose python3 python3-setuptools httpie
# Install d2-docker
- git clone https://github.com/EyeSeeTea/d2-docker.git
- cd d2-docker/
- sudo python3 setup.py install
- cd ../
# Hack to not be prompted in the terminal
- sudo apt-get remove golang-docker-credential-helpers
# Start docker service
- sudo systemctl unmask docker.service
- sudo systemctl unmask docker.socket
- sudo systemctl start docker.service
# Login to docker and start DHIS2 instance
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- d2-docker start eyeseetea/dhis2-data:2.30-datasync-sender -d
install:
- yarn install --frozen-lockfile
- yarn cy:verify
- yarn build
- git clone --single-branch --branch gh-pages "https://${GITHUB_USERNAME}:${GITHUB_PASSWORD}@github.com/${FEEDBACK_REPO}" feedback-ci
- yarn install --frozen-lockfile
- yarn cy:verify
- yarn localize
- yarn test
- yarn start &
script:
- PORT=8081 REACT_APP_DHIS2_BASE_URL=http://dev2.eyeseetea.com:8083 REACT_APP_CYPRESS=true yarn start &
- yarn wait-on http-get://localhost:8081
- CYPRESS_EXTERNAL_API=http://dev2.eyeseetea.com:8083 CYPRESS_ROOT_URL=http://localhost:8081 yarn cy:e2e:run --key $CYPRESS_KEY
- kill $(jobs -p) || true
- yarn wait-on http-get://localhost:8080
- yarn wait-on http-get://localhost:8081
- yarn migrate "http://$CYPRESS_DHIS2_AUTH@localhost:8080"
- CYPRESS_E2E=true yarn node cypress/support/runner.js -b chrome
after_script:
- cd feedback-ci/
- if [[ $TRAVIS_PULL_REQUEST_BRANCH != "" ]]; then BRANCH="${TRAVIS_PULL_REQUEST_BRANCH}"; else BRANCH="${TRAVIS_BRANCH}"; fi;
- GITHUB_PAGES_ROOT=$(http -a ${GITHUB_USERNAME}:${GITHUB_PASSWORD} https://api.github.com/repos/${FEEDBACK_REPO}/pages | jq ".html_url" | tr -d '"')
- GITHUB_PAGES_PATH=$(cat ../pages_path)
- git add . && git commit -m "Results for $TRAVIS_EVENT_TYPE on $TRAVIS_COMMIT"
- git pull origin --no-edit
- git push origin gh-pages
- EXISTING_COMMENT=$(http -a ${GITHUB_USERNAME}:${GITHUB_PASSWORD} https://api.github.com/repos/${TRAVIS_REPO_SLUG}/issues/${TRAVIS_PULL_REQUEST}/comments | jq '[.[] | select(.user.login == "EyeSeeTeaBotTest")][0].id')
- if [[ $TRAVIS_TEST_RESULT == 0 ]]; then GITHUB_COMMENT_TITLE="Tests ran successfully :tada:"; else GITHUB_COMMENT_TITLE="Tests failed with errors :rotating_light:"; fi;
- GITHUB_COMMENT_MESSAGE="<h3>${GITHUB_COMMENT_TITLE}</h3><br />Build commit ${TRAVIS_COMMIT_MESSAGE} with commit id ${TRAVIS_COMMIT} on branch ${BRANCH}<br /><br />Travis log available at <a href="${TRAVIS_BUILD_WEB_URL}" target="_blank">builds/${TRAVIS_BUILD_ID}</a><br /><br />See cypress results at <a href="${GITHUB_PAGES_ROOT}${GITHUB_PAGES_PATH}" target="_blank">feedback-ci/${GITHUB_PAGES_PATH}</a>"
- if [[ $TRAVIS_PULL_REQUEST != "false" && $EXISTING_COMMENT == "null" ]]; then http -a ${GITHUB_USERNAME}:${GITHUB_PASSWORD} POST https://api.github.com/repos/${TRAVIS_REPO_SLUG}/issues/${TRAVIS_PULL_REQUEST}/comments body="${GITHUB_COMMENT_MESSAGE}"; fi;
- if [[ $TRAVIS_PULL_REQUEST != "false" && $EXISTING_COMMENT != "null" ]]; then http -a ${GITHUB_USERNAME}:${GITHUB_PASSWORD} PATCH https://api.github.com/repos/${TRAVIS_REPO_SLUG}/issues/comments/${EXISTING_COMMENT} body="${GITHUB_COMMENT_MESSAGE}"; fi;
- kill $(jobs -p) || true
addons:
apt:
packages:
- libgconf-2-4
apt:
packages:
- libgconf-2-4
notifications:
slack:
secure: R/tguoSgiUOK5qYmRoSv4qVkgGaF26PVnjqefXGc8oMc4scbssjbhQt+qVC2RuhB3ErXmez+BfaKcLLR6cEFY4cm+puBD+mU6fP2rDCiQRnmfaZmvdT/MY1KTSKlT2JzQ/YU9IQfdUetr/7lUbdyTcJQ8r+QOMwQu/drSGUEOt+eTHO5HQFVfhHnmoYWJ4oWxAWUyJx7DbXgRy9K5JlYlv2Vesol5vpSzjdXNlcXV3EPOD009ODO2+EboKujZHvLJakAjy/sCgtqB0ys22WXPv5dOj8FCJRjFSKpe9s5pZYjvjJfjD7GnIcP6/AAe+m3OC9/fDxdFtXeppJ95FNEQKyWCVAS9QNY50G4W0sHlR6VZ3OUhLnIQLKeNncTWG5QaUc4+/vYmbeEYFahOATMUX8I4uUVuT+5jDS883kHQ6Z8XxUWy3PztuM3kOz/cv3zppd2icpPtqDTkIql5CdA4ZHmBElD3GiIJgEfUOaUqn4isivALv024UnQhwrHCK55ymcphotzjdnhRQSlY2MeywA+TqaAtcYwoqKOBbvHQ2c8QMfanbT9UvmAE7+X0VruF5hgvaKA5DgT51RZl8YQVuLBbrfcT8+XrTypl2fwpJ4/23wltR/Ex9K7wJtjQeM1oz37mzFUW7zfvlHsXgWy2WtTkM/icAlxLM7ZN5YGMxI=
slack:
secure: R/tguoSgiUOK5qYmRoSv4qVkgGaF26PVnjqefXGc8oMc4scbssjbhQt+qVC2RuhB3ErXmez+BfaKcLLR6cEFY4cm+puBD+mU6fP2rDCiQRnmfaZmvdT/MY1KTSKlT2JzQ/YU9IQfdUetr/7lUbdyTcJQ8r+QOMwQu/drSGUEOt+eTHO5HQFVfhHnmoYWJ4oWxAWUyJx7DbXgRy9K5JlYlv2Vesol5vpSzjdXNlcXV3EPOD009ODO2+EboKujZHvLJakAjy/sCgtqB0ys22WXPv5dOj8FCJRjFSKpe9s5pZYjvjJfjD7GnIcP6/AAe+m3OC9/fDxdFtXeppJ95FNEQKyWCVAS9QNY50G4W0sHlR6VZ3OUhLnIQLKeNncTWG5QaUc4+/vYmbeEYFahOATMUX8I4uUVuT+5jDS883kHQ6Z8XxUWy3PztuM3kOz/cv3zppd2icpPtqDTkIql5CdA4ZHmBElD3GiIJgEfUOaUqn4isivALv024UnQhwrHCK55ymcphotzjdnhRQSlY2MeywA+TqaAtcYwoqKOBbvHQ2c8QMfanbT9UvmAE7+X0VruF5hgvaKA5DgT51RZl8YQVuLBbrfcT8+XrTypl2fwpJ4/23wltR/Ex9K7wJtjQeM1oz37mzFUW7zfvlHsXgWy2WtTkM/icAlxLM7ZN5YGMxI=
53 changes: 40 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,44 @@ $ yarn install

File `public/app-config.json` must be created by duplicating `public/app-config.template.json` and filling in the encryptionKey.

## Migrations

The app uses the DHIS2 data store to persist custom data. Whenever the schema of the data store changes, we'll create a [migration task](src/migrations/tasks) with an incremental version. \*.ts files in this folder are automatically loaded.

When writing a migration, we must define the old/new types of data structures used in that migration task. Note that we cannot rely on types on the app, as they may have diverged. For fields/objects we must reference but don't care the type, we will use `unknown` (not `any`).

When the app starts, it will check the data store version and open a dialog if a migration is required. You can also run the migrations on the CLI:

```
$ yarn migrate 'http://admin:PASSWORD@localhost:8080'
```

## Development

Start development server:
### Start the development server of the main application:

```
$ yarn start
```

This will open the development server at port 8081 and will connect to DHIS 2 instance http://localhost:8080.
This will open the development server for the main application at port 8081 and will connect to DHIS 2 instance http://localhost:8080.

Use custom values passing environment variables:
### Start the development server of a given widget:

```
$ PORT=8082 REACT_APP_DHIS2_URL="https://play.dhis2.org/dev" yarn start
$ yarn start-widget -p 8082 modules-list|package-exporter
```

This will open the development server for the given widget at port 8082 and will connect to DHIS 2 instance http://localhost:8080.

### Customize DHIS2 instance url

```
REACT_APP_DHIS2_BASE_URL=http://localhost:8080
```

To use a different DHIS2 instance url set this environment variable before running a ``start`` command.

## Tests

Run unit tests:
Expand All @@ -36,19 +58,32 @@ Run integration tests locally:
$ export CYPRESS_DHIS2_AUTH='admin:district'
$ export CYPRESS_EXTERNAL_API="http://localhost:8080"
$ export CYPRESS_ROOT_URL=http://localhost:8081
$ export CYPRESS_ENCRYPTION_KEY=anyKey
$ yarn cy:e2e:run # non-interactive
$ yarn cy:e2e:open # interactive UI
```

For this to work in Travis CI, you will have to create an environment variable CYPRESS_DHIS2_AUTH (Settings -> Environment Variables) with the password used in your testing DHIS2 instance.
Application should be running at CYPRESS_ROOT_URL with as the environment variable REACT_APP_CYPRESS set to True.

For this to work in Travis CI, you will have to create an environment variables (Settings -> Environment Variables) CYPRESS_DHIS2_AUTH with the password used in your testing DHIS2 instance and CYPRESS_ENCRYPTION_KEY used to encrypt passwords of receiver instances.

Note tests only pass on the testing docker instance eyeseetea/dhis2-data:2.30-datasync-sender

## Build

To build the web app:

```
$ yarn build-webapp
```

To build the widget:

```
$ yarn build-widget modules-list|package-exporter
```

## i18n

### Update an existing language
Expand All @@ -58,11 +93,3 @@ $ yarn update-po
# ... add/edit translations in po files ...
$ yarn localize
```

### Create a new language

```
$ cp i18n/en.pot i18n/es.po
# ... add translations to i18n/es.po ...
$ yarn localize
```
9 changes: 6 additions & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module.exports = process.env.CYPRESS_ENV ? {} : {
"presets": ["@babel/typescript", "babel-preset-react-app"]
};
module.exports = process.env.CYPRESS_E2E
? {}
: {
presets: ["@babel/typescript", "babel-preset-react-app"],
plugins: [["@babel/plugin-proposal-decorators", { legacy: true }]],
};
19 changes: 13 additions & 6 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
{
"baseUrl": "http://localhost:8081",
"defaultCommandTimeout": 15000,
"requestTimeout": 30000,
"chromeWebSecurity": false,
"_comment": "chromeWebSecurity flag disabled to allow cypress to test redirection to external pages - TEMPORARY",
"projectId": "5smeca"
"defaultCommandTimeout": 25000,
"requestTimeout": 120000,
"responseTimeout": 120000,
"chromeWebSecurity": false,
"reporter": "mochawesome",
"reporterOptions": {
"reportDir": "mochawesome-report",
"charts": true,
"overwrite": false,
"html": false,
"json": true,
"timestamp": "mmddyyyy_HHMMss"
}
}
26 changes: 26 additions & 0 deletions cypress/fixtures/aggregated-sync-rule.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"builder": {
"targetInstances": ["Y5QsHDoD4I0"],
"metadataIds": ["qNtxTrp56wV"],
"excludedIds": [],
"metadataTypes": [],
"dataParams": {
"strategy": "NEW_AND_UPDATES",
"allAttributeCategoryOptions": true,
"dryRun": false,
"allEvents": true,
"enableAggregation": false,
"orgUnitPaths": ["/E4h5WBOg71F"],
"events": []
},
"syncParams": {
"importStrategy": "CREATE_AND_UPDATE",
"includeSharingSettings": true,
"useDefaultIncludeExclude": true,
"atomicMode": "ALL",
"mergeMode": "MERGE",
"importMode": "COMMIT",
"metadataIncludeExcludeRules": {}
}
}
}
46 changes: 46 additions & 0 deletions cypress/fixtures/aggregated-sync-rules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"id": "Vmo16jI0yYo",
"name": "Aggregated sync rule name",
"code": "Aggregated sync rule code",
"created": "2020-03-30T05:26:16.518Z",
"description": "Aggregated sync rule description",
"enabled": false,
"lastUpdated": "2020-03-30T05:40:24.285Z",
"lastUpdatedBy": {
"id": "M5zQapPyTZI",
"name": "admin admin"
},
"publicAccess": "rw------",
"user": {
"id": "M5zQapPyTZI",
"name": "admin admin"
},
"userAccesses": [],
"userGroupAccesses": [],
"type": "aggregated",
"targetInstances": ["Y5QsHDoD4I0"]
},
{
"id": "Vmo16jI0yYo",
"name": "Aggregated sync rule name 2",
"code": "Aggregated sync rule code 2",
"created": "2020-03-30T05:26:16.518Z",
"description": "Aggregated sync rule description 2",
"enabled": false,
"lastUpdated": "2020-03-30T05:40:24.285Z",
"lastUpdatedBy": {
"id": "M5zQapPyTZI",
"name": "admin admin"
},
"publicAccess": "rw------",
"user": {
"id": "M5zQapPyTZI",
"name": "admin admin"
},
"userAccesses": [],
"userGroupAccesses": [],
"type": "aggregated",
"targetInstances": ["Y5QsHDoD4I0"]
}
]
25 changes: 25 additions & 0 deletions cypress/fixtures/events-sync-rule.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"builder": {
"targetInstances": ["Y5QsHDoD4I0"],
"metadataIds": ["G9hvxFI8AYC"],
"excludedIds": [],
"dataParams": {
"strategy": "NEW_AND_UPDATES",
"allAttributeCategoryOptions": true,
"allEvents": false,
"dryRun": false,
"orgUnitPaths": ["/E4h5WBOg71F/RnDSNvg7zR2/KwLlNNoREes/GY1mRd2suuj/PzO3UvH7za0"],
"events": ["PoKTdJQa8pV"],
"periods": "ALL"
},
"syncParams": {
"importStrategy": "CREATE_AND_UPDATE",
"includeSharingSettings": true,
"useDefaultIncludeExclude": true,
"atomicMode": "ALL",
"mergeMode": "MERGE",
"importMode": "COMMIT",
"metadataIncludeExcludeRules": {}
}
}
}
Loading

0 comments on commit 4bcccb4

Please sign in to comment.