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 *
- kubectl
- aws-cli
- aws credentials
- kubeconfig setup: to run any makefile targets that interact with staging or production.
make download-exploratory-test-from-prod
make exploratory-test-from-prod
To test locally, set content header Authorization: Bearer secret
.
- define beforehand the authorization variable
export SCIETY_TEAM_API_BEARER_TOKEN=the-secret-token-from-dotenv-or-1password
- adjust
expressionDoi
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 '{"expressionDoi": "10.21203/rs.3.rs-955726/v1", "listId": "5ac3a439-e5c6-4b15-b109-92928a740812"}'
Prior to adding a group three files need to be made available:
- square avatar Group static files
- large logo Sciety repo
- group description Sciety repo
Aim for a large horizontal logo of 600px width. Refer to the group page sass.
curl -v -H "Authorization: Bearer ${SCIETY_TEAM_API_BEARER_TOKEN}" \
-X POST https://staging.sciety.org/api/add-group \
-H "Content-type: application/json" \
-d '{"groupId": "cc4c8e79-402f-40e7-80fd-1062145d24ec", "avatarPath": "https://raw.githubusercontent.com/sciety/group-static-files/main/metaror.png", "descriptionPath": "metaror.md", "homepage": "https://metaror.org/", "name": "MetaROR", "shortDescription": "MetaROR is a collaborative initiative led jointly by the Research on Research Institute (RoRI) and the Association for Interdisciplinary Meta-Research and Open Science (AIMOS), which are working together to build a platform to leverage the strengths of the Publish – Review – Curate approach for the various metaresearch disciplines.", "slug": "metaror", "largeLogoPath": "/static/groups/large-logos/metaror.png"}'
We released this software under the MIT license. Copyright © 2020 eLife Sciences Publications, Ltd.