Skip to content

sciety/sciety

Repository files navigation

Sciety

The repo for sciety.org.

Developed and maintained by Sciety's remote first ensemble programming team.

Development

Requirements

Running the app

To build and run the app for development, execute:

make dev

You can now access the app at http://localhost:8080.

Certain parts of the application require you to have set up credentials for external services on your machine.

Most content will be missing as the database will be empty, see the Operations section below on how to populate it.

Containers restart automatically on most code changes. If they don't, ctrl-c and rerun make dev. An example of when this is needed, is changes to package.json.

Configuring environment variables and credentials

Environment variables control certain behaviour.

For the application to be able to interact with external services, credentials need to be provided via the .env file as well as dedicated credential files.

Before running make dev you have to create a .env file based on .env.example. This includes instructions on how to populate and use it.

You'll need to re-run make dev after modifying the .env file.

If you've been added to the appropriate GCP organisation, you can run make .gcp-ncrc-key.json to create the necessary credential file (used for the content of the NCRC group).

Running the tests

Fast tests

These tests live in test/ and use Jest. You can run them by executing:

make test

Slow tests

Browser-based tests live in feature-test/ and use Taiko. We use them for user journeys.

make taiko

To run just one test file, execute:

make taiko TEST=[file-name].ts

Visual regression tests are defined in backstop.json. They rely on approved screenshots in backstop_data/ stored with Git LFS.

make backstop-test
make backstop-approve

If you want to only run a subset of scenarios, execute:

make backstop-test SCENARIO=article
make backstop-test SCENARIO="header|footer"

Linting

The following target runs all static code checks:

make check

You can fix problems, where possible, by executing:

make lint-fix

The above is quite heavy weight and can take a while. To increase feedback speed you can gain partial coverage:

make watch-typescript

To temporarily ignore unused exports:

// ts-unused-exports:disable-next-line
export const iAmUnused = true;

In our team we also rely on eslint feedback from our IDEs.

To check only for unused TypeScript exports, execute:

make unused-exports

Operations

The application is deployed on a Kubernetes cluster via an Helm chart.

A staging environment and production environment are updated with every new commit on main that passes CI.

There is a #sciety-errors Slack channel.

View logs, k8s metrics and create dashboard on sciety.grafana.net.

Looking at logs

Logs from all kubernetes pods from the last 30 days are viewable on Grafana Cloud.

Authentication is based on elifesciences Google account.

Example queries:

Looking at the cache

Create a container from which you can connect to the production cache:

make connect-to-cache

From there, start the redis CLI with:

redis-cli -h sciety--prod--cache

List the keys with:

KEYS *

Local exploratory testing with copy of production DB

Requirements

Commands to get and run copy of production DB

make download-exploratory-test-from-prod
make exploratory-test-from-prod

Calling staging and production APIs

Adding an article to a group list

  • define beforehand the authorization variable export SCIETY_TEAM_API_BEARER_TOKEN=the-secret-token-from-dotenv-or-1password
  • adjust articleId and listId as needed
curl -v -H "Authorization: Bearer $SCIETY_TEAM_API_BEARER_TOKEN" -X POST https://sciety.org/api/add-article-to-list -H "Content-type: application/json" -d '{"articleId": "10.21203/rs.3.rs-955726/v1", "listId": "5ac3a439-e5c6-4b15-b109-92928a740812"}'

Adding a group

curl -v -H "Authorization: Bearer $SCIETY_TEAM_API_BEARER_TOKEN" -X POST http://localhost:8080/api/add-group -H "Content-type: application/json" -d '{"groupId": "1480d2dd-463f-4834-8e81-d89c8ae2b86f", "avatarPath": "https://raw.githubusercontent.com/sciety/group-static-files/main/example-group.png", "descriptionPath": "life-science-editors--1480d2dd-463f-4834-8e81-d89c8ae2b86f.md", "homepage": "https://www.lifescienceeditors.com", "name": "Life Science Editors", "shortDescription": "Life Science Editors is a group of former journal editors and grant specialists who are passionate about helping scientists and science reach their full potential.", "slug": "life-science-editors"}'

Group large logos

Aim for a horizontal logo of 600px width. Refer to the group page sass.

License

We released this software under the MIT license. Copyright © 2020 eLife Sciences Publications, Ltd.