UNPKG

7.65 kBMarkdownView Raw
1---
2title: Contributing to Auspice development
3---
4
5Thank you for helping us to improve Nextstrain!
6
7> **To get started, please see [the contributing guide](https://github.com/nextstrain/.github/blob/master/CONTRIBUTING.md) for useful information about how to pick an issue, submit your contributions, and so on.**
8
9This project strictly adheres to the [Contributor Covenant Code of Conduct](https://github.com/nextstrain/.github/blob/master/CODE_OF_CONDUCT.md).
10
11Please see the [project boards](https://github.com/orgs/nextstrain/projects) for currently available issues.
12
13## Contributing code
14
15Code contributions are welcomed! [Please see the main auspice docs](https://nextstrain.github.io/auspice/introduction/install) for details on how to install and run auspice from source.
16
17Please comment on an open issue if you are working on it.
18For changes unrelated to an open issue, please make an issue outlining what you would like to change/add.
19
20Where possible, **please rebase** your work onto master rather than merging changes from master into your PR.
21
22From a fork: `git pull --rebase upstream master`
23
24### Make sure tests are passing
25
26We use the following libraries for all kinds of testing, so it'd help to read the docs to get familiar with their APIs and features:
27
281. [`Jest`](https://github.com/facebook/jest)
292. [`Puppeteer`](https://github.com/puppeteer/puppeteer/)
303. [`Jest-Puppeteer`](https://github.com/smooth-code/jest-puppeteer)
314. [`Jest-Image-Snapshot`](https://github.com/americanexpress/jest-image-snapshot)
32
33When you submit a pull request to the auspice repository, a variety of integration and unit tests will need to pass before it can be merged.
34
35You will likely want to run these tests locally before submitting:
36
37First, install the dependencies with `npm i`, then:
38
39#### For unit tests
40
41Run `npm test`.
42
43#### For linting
44
45Run `npm run lint`. If there are issues run `npm run lint:fix`.
46
47#### For integration tests
48
49> For integration tests to work, you'll need to have `git-lfs` installed (see below) as it stores the images that the snapshot tests will use.
50
511. Fetch the datasets with `npm run get-data` and `npm run get-narratives`.
522. Ensure you are **not** currently running the site locally, then run `npm run integration-test:ci`.
53
54
55#### How to update test snapshots
56
571. Unit tests: `npm run test -- -u`
582. Integration tests `npm run integration-test -- -u`
59
60
61#### For smoke tests
62
631. Fetch the datasets with `npm run get-data` and `npm run get-narratives`.
642. Ensure you are **not** currently running the site locally, then run `npm run smoke-test:ci`.
65
66
67#### Test Tips
68
691. Run a single `describe()`, `it()`, or `test()` **within a file**, add `.only()`:
70
71 E.g., `describe.only()`, `it.only()`, or `test.only()`
72
732. Run a single test file, append the following to your test command `-- relative_or_absolute_path/to/file`:
74
75 E.g., `npm run integration-test -- test/integration/zika.test.js`
76
773. Run integration tests in headful mode, prepend `HEADLESS=false` to your command:
78
79 E.g., `HEADLESS=false npm run integration-test`
80
814. For integration tests, please try to use [`expect-puppeteer`](https://github.com/smooth-code/jest-puppeteer/blob/master/packages/expect-puppeteer/README.md#api) as much as possible, and only resort to `puppeteer`'s native API when we can't do it with `expect-puppeteer`. The reason is because `expect-puppeteer` has better DX, as explained [here](https://github.com/smooth-code/jest-puppeteer/blob/master/packages/expect-puppeteer/README.md#why-do-i-need-it)
82
835. How to add a new integration image test:
84
85 1. Wrap your image test with helper function `toMatchImageSnapshot()` from `test/integration/helpers.js`, and it will take a screenshot every `100ms` until it matches the expected snapshot or timeout (default: `10s`)
86
87 2. Temporarily add `page.waitFor(__ENOUGH__MS__)` before taking the new snapshot to give the browser enough time to render a complete image
88
89 3. Example: `test/integration/zika.test.js`
90
91
92## git-lfs
93
94We use [Git Large File Storage](https://github.com/git-lfs/git-lfs) to manage certain assets.
95Currently these are limited to images within the `./test` directory (which we use for snapshot integration testing) but this may change in the future.
96If you are not using these images, you don't need to have `git-lfs` installed; however **will not be able to run integration tests without it**.
97See [here](https://git-lfs.github.com/) for installation instructions.
98
99Helpful commands:
100```bash
101git lfs status
102git lfs ls-files # list LFS tracked tiles
103```
104
105
106## Contributing to Documentation
107
108Nextstrain documentation is available at [nextstrain.github.io/auspice/](https://nextstrain.github.io/auspice/).
109
110This documentation is built from files contained within the Auspice GitHub repo -- see the [docs-src/README](https://github.com/nextstrain/auspice/tree/master/docs-src) within the `docs-src` directory for more details and instructions on how to contribute.
111
112Note that currently the documentation must be rebuilt & pushed to GitHub _after_ a new version is released in order for the changelog to correctly appear at [nextstrain.github.io/auspice/releases/changelog](https://nextstrain.github.io/auspice/releases/changelog).
113
114## Contributing to Internationalization and Localization (i18n/l18n)
115
116If you can assist in efforts to translate the Auspice interface to more languages your assistance would be very much appreciated.
117The currently available languages are displayed via a drop-down at the bottom of the sidebar.
118
119## Adding a new language
120
121 1) Add the language to the `getlanguageOptions` function in [this file](https://github.com/nextstrain/auspice/blob/master/src/components/controls/language.js#L24)
122 2) If this is a new language, copy the folder (and the JSONs within it) `src/locales/en` and name it to match the language code for the new translation -- e.g. for Spanish this would be `src/locales/es`
123 3) For each key-value in the JSONs, translate the english phrase to the new locale. (Do not modify the strings within `{{...}}` sections.)
124
125For example, a spanish translation would change the English:
126
127```json
128 "sampled between {{from}} and {{to}}": "sampled between {{from}} and {{to}}",
129 "and comprising": "and comprising",
130```
131
132to
133
134```json
135 "sampled between {{from}} and {{to}}": "aislados entre {{from}} y {{to}}",
136 "and comprising": "y compuesto de",
137```
138
139## Helper script to check what parts of a translation are out-of-date or missing
140
141Run `npm run diff-lang -- X`, where `X` is the language you wish to check, for instance `es`.
142This will display the strings which:
143
144* need to be added to the translation
145* are present but should be removed as they are no longer used
146* are present but are simply a copy of the English version & need to be translated
147
148> Running `npm run diff-lang` will check all available languages.
149
150## Improving an existing translation
151
152If a translation of a particular string is not yet available, then auspice will fall-back to the english version.
153
154 1) Find the relevant key in the (EN) JSONs [in this directory](https://github.com/nextstrain/auspice/tree/master/src/locales/en)
155 2) Add the key to the JSON with the same name, but in the directory corresponding to the language you are translating into (see above for an example).
156
157## Releases & versioning
158
159New versions are released via the `./releaseNewVersion.sh` script from an up-to-date `master` branch. It will prompt you for the version number increase, push changes to the `release` branch and, as long as Travis-CI is successful then a new version will be automatically published to [npm](https://www.npmjs.com/package/auspice).