The repo for sciety.org.
Developed and maintained by Sciety's remote first ensemble programming team.
Requirements
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
.
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.
Use the GCP console to create a GCP key. This is used to access NCRC evaluations and needs to be stored in a file named .gcp-ncrc-key.json
.
These tests live in test/
and use Jest. You can run them by executing:
make test
Browser-based tests live in feature-test/
and use Taiko or Axios. We use them for user journeys or API calls.
make feature-test
To run just one test file, execute:
make feature-test 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"
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
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.
Logs from all kubernetes pods from the last 30 days are viewable on Grafana Cloud.
Authentication is based on elifesciences Google account.
Example queries:
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 *
make download-exploratory-test-from-prod
make exploratory-test-from-prod
- define beforehand the authorization variable
export SCIETY_TEAM_API_BEARER_TOKEN=the-secret-token-from-dotenv-or-1password
- adjust
articleId
andlistId
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"}'
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"}'
Aim for a horizontal logo of 600px width. Refer to the group page sass.
We released this software under the MIT license. Copyright © 2020 eLife Sciences Publications, Ltd.