Git Product home page Git Product logo

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.

Running make dev creates 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 lint

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

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

To check only the SASS code, execute:

make lint-sass

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:

Local exploratory testing with copy of production DB

Requirements
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 INGESTION_AUTH_BEARER_TOKEN=the-secret-token-from-dotenv-or-1password
  • adjust articleId and listId as needed
curl -v -H "Authorization: Bearer $INGESTION_AUTH_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 secret" -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"}'

License

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

Sciety's Projects

sciety icon sciety

Where research is evaluated and curated by the communities you trust

sciety-labs icon sciety-labs

Early stage experiments related to discovery of preprints and the Sciety community.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.