Skip to content

Commit

Permalink
Merge pull request #209 from CSCfi/develop
Browse files Browse the repository at this point in the history
release 0.9.0
  • Loading branch information
blankdots authored Mar 22, 2021
2 parents cde5d50 + 78ff088 commit 88423b9
Show file tree
Hide file tree
Showing 53 changed files with 2,147 additions and 1,258 deletions.
29 changes: 29 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
labels:
- "pip dependencies"
target-branch: "develop"
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
labels:
- "github actions"
target-branch: "develop"
open-pull-requests-limit: 10
- package-ecosystem: docker
directory: "/"
schedule:
interval: "weekly"
day: "monday"
labels:
- "docker dependencies"
target-branch: "develop"
open-pull-requests-limit: 10
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
max-parallel: 4
matrix:
os: [ubuntu-latest]
python-version: [3.7]
python-version: [3.8]

runs-on: ${{ matrix.os }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/int.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
max-parallel: 4
matrix:
os: [ubuntu-latest]
python-version: [3.7]
python-version: [3.8]

runs-on: ${{ matrix.os }}

Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
max-parallel: 4
matrix:
os: [ubuntu-latest]
python-version: [3.7]
python-version: [3.8]

runs-on: ${{ matrix.os }}

Expand All @@ -31,6 +31,15 @@ jobs:
with:
driver-opts: network=host

- name: Set build target branch
run: |
if [[ ${{ github.event.pull_request.base.ref }} == master ]]; then
BRANCH=master
else
BRANCH=develop
fi
echo "BUILD_BRANCH=$BRANCH" >> $GITHUB_ENV
- name: Build
uses: docker/build-push-action@v2
with:
Expand All @@ -40,6 +49,8 @@ jobs:
tags: localhost:5000/metadata-submitter:latest
cache-from: localhost:5000/metadata-submitter:latest
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
BRANCH=${{ env.BUILD_BRANCH }}
- name: Run production container
run: docker run --rm -p 5430:5430 --name ms -d -t localhost:5000/metadata-submitter:latest
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ jobs:
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
BRANCH=master
elif [[ $GITHUB_REF == refs/heads/* ]]; then
BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [[ $BRANCH == master ]]; then
VERSION=latest
BRANCH=master
elif [[ $BRANCH == develop ]]; then
VERSION=stage
BRANCH=develop
fi
fi
echo "BUILD_BRANCH=$BRANCH" >> $GITHUB_ENV
TAGS="${DOCKER_IMAGE}:${VERSION}"
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
Expand All @@ -51,6 +55,8 @@ jobs:
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
build-args: |
BRANCH=${{ env.BUILD_BRANCH }}
cache-from: type=registry,ref=cscfi/metadata-submitter:latest
cache-to: type=local,dest=/tmp/.buildx-cache
labels: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
max-parallel: 4
matrix:
os: [ubuntu-latest]
python-version: [3.7]
python-version: [3.8]

runs-on: ${{ matrix.os }}

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
max-parallel: 4
matrix:
os: [ubuntu-latest]
python-version: [3.7]
python-version: [3.8]

runs-on: ${{ matrix.os }}

Expand All @@ -26,8 +26,8 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Run unit tests for python 3.7
if: ${{ matrix.python-version == '3.7' }}
- name: Run unit tests for python 3.8
if: ${{ matrix.python-version == '3.8' }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: tox -e py37
run: tox -e py38
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ RUN apk add --update \
&& apk add --no-cache git\
&& rm -rf /var/cache/apk/*

RUN git clone https://github.com/CSCfi/metadata-submitter-frontend.git
ARG BRANCH=master

RUN git clone -b ${BRANCH} https://github.com/CSCfi/metadata-submitter-frontend.git

WORKDIR /metadata-submitter-frontend
RUN npm install && npm run build --production
RUN npm install -g [email protected] \
&& npx --quiet pinst --disable \
&& npm install --production \
&& npm run build --production

FROM python:3.7-alpine3.13 as BUILD-BACKEND
FROM python:3.8-alpine3.13 as BUILD-BACKEND

RUN apk add --update \
&& apk add --no-cache build-base curl-dev linux-headers bash git musl-dev libffi-dev \
Expand All @@ -27,15 +32,15 @@ RUN pip install --upgrade pip && \
pip install -r /root/submitter/requirements.txt && \
pip install /root/submitter

FROM python:3.7-alpine3.13
FROM python:3.8-alpine3.13

RUN apk add --no-cache --update bash

LABEL maintainer="CSC Developers"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.vcs-url="https://github.com/CSCfi/metadata-submitter"

COPY --from=BUILD-BACKEND /usr/local/lib/python3.7/ /usr/local/lib/python3.7/
COPY --from=BUILD-BACKEND /usr/local/lib/python3.8/ /usr/local/lib/python3.8/

COPY --from=BUILD-BACKEND /usr/local/bin/gunicorn /usr/local/bin/

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7-slim
FROM python:3.8-slim

RUN apt-get install ca-certificates

Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Service also validates submitted metadata objects against EGA XSD metadata model
## Install and run

Requirements:
- Python 3.7+
- Python 3.8+
- MongoDB
- Docker + docker-compose

Expand All @@ -22,9 +22,11 @@ For more detailed setup, do following:
- Install project by running: `pip install .` in project root
- Setup mongodb and env variables via desired way, details:
- Server expects to find mongodb instance running, specified with following environment variables:
- `MONGO_INITDB_ROOT_USERNAME`, username for admin user to mondogdb instance
- `MONGO_INITDB_ROOT_PASSWORD`, password for admin user to mondogdb instance
- `MONGO_USERNAME`, username for connecting to mondogdb instance
- `MONGO_PASSWORD`, password for connecting to mondogdb instance
- `MONGO_HOST`, host and port for mongodb instance (e.g. `localhost:27017`)
- `MONGO_DATABASE`, If a specific database is to be used, set the name here.
- `MONGO_AUTHDB`, if `MONGO_DATABASE` is set and the user doesn't exists in the database, set this to the database where the user exists (e.g. `admin`)
- Out of the box, metadata submitter is configured with default values from MongoDB Docker image
- Suitable mongodb instance can be launched with Docker by running `docker-compose up database`
- After installing and setting up database, server can be launched with `metadata_submitter`
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ services:
- "AUTH_REFERER=http://mockauth:8000"
- "JWK_URL=http://mockauth:8000/keyset"
- "LOG_LEVEL=DEBUG"
- "MONGO_DATABASE=default"
- "MONGO_AUTHDB=admin"
database:
image: "mongo"
container_name: "metadata_submitter_database_dev"
Expand Down
1 change: 1 addition & 0 deletions docs/code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Metadata Backend API

metadata_backend.api.auth
metadata_backend.api.handlers
metadata_backend.api.health
metadata_backend.api.middlewares
metadata_backend.api.operators

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
author = "CSC Developers"

# The full version, including alpha/beta/rc tags
release = "0.8.1"
release = "0.9.0"


# -- General configuration ---------------------------------------------------
Expand Down
115 changes: 110 additions & 5 deletions docs/frontend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ To run the frontend from command line use:
After installing and running, frontend can be found from ``http://localhost:3000``.

.. hint:: Some functionality in frontend required a working backend.
.. hint:: Some functionality in frontend requires a working backend.
Follow the instructions in :ref:`deploy` for setting it up.



Internal structure
------------------

Expand All @@ -61,11 +60,117 @@ Form components
Form components are crucial part of the application:

- All submissions and folder creation are made with `react-hook-form <https://react-hook-form.com/>`_.
Latter uses form as a reference so submission can be triggered outside the form.
- Form for json schema based forms are created with custom json schema parser, which builds
``react-hook-form`` based forms from given json schema. Json schema-based forms are validated against json schema with ``Ajv``.
Latter uses form as a reference so submission can be triggered outside the form. JSON schema based forms are created with custom JSON schema parser, which builds
``react-hook-form`` based forms from given schema. The forms are validated against the JSON schema with ``Ajv``.
React-hook-form is used for performance reasons: it uses uncontrolled components so adding a lot of fields to array doesn't slow rendering of the application.

Constants
---------

Folder ``src/constants`` holds all the constants used in the application. The constants are uniquely defined and separated into different files according to its related context. For example, the file ``constants/wizardObject.js`` contains unique constants regarding to ``wizardObject`` such as: ``ObjectTypes, ObjectStatus, etc.``

The purposes of using these `constants` are:

- to avoid hard coding the values of variables repeatedly
- to keep the consistency when defining the values of variables
- to reuse those predefined values across the application

Example of defining and using a constant:

- First, define the constant object ``ObjectSubmissionTypes`` in ``constants/wizardObject.js``

.. code-block:: javascript
export const ObjectSubmissionTypes = {
form: "Form",
xml: "XML",
existing: "Existing",
}
- Then, use this constant in `WizardComponents/WizardObjectIndex`:

.. code-block:: javascript
import { ObjectSubmissionTypes } from "constants/wizardObject"
switch (currentSubmissionType) {
case ObjectSubmissionTypes.form: {
target = "form"
break
}
case ObjectSubmissionTypes.xml: {
target = "XML upload"
break
}
case ObjectSubmissionTypes.existing: {
target = "drafts"
break
}
}
Commonly used data types
------------------------

All commonly used data types of variables are defined in the file ``index.js`` in folder ``src/types``. The purposes are:

- to avoid hard coding the same data types frequently in different files
- to keep track and consistency of the data types across different files

For example:

- declare and export these data types in ``src/types/index.js``

.. code-block:: javascript
export type ObjectInsideFolder = {
accessionId: string,
schema: string,
}
export type ObjectTags = {
submissionType: string,
fileName?: string,
}
export type ObjectInsideFolderWithTags = ObjectInsideFolder & { tags: ObjectTags }
- import and reuse the data types in different files:
- Reuse type ``ObjectInsideFolder`` in ``features/wizardSubmissionFolderSlice.js``:

.. code-block:: javascript
import type { ObjectInsideFolder } from "types"
export const addObjectToFolder = (
folderID: string,
objectDetails: ObjectInsideFolder
) => {}
export const addObjectToDrafts = (
folderID: string,
objectDetails: ObjectInsideFolder
) => {}
- Reuse type ``ObjectInsideFolderWithTags`` consequently in both ``WizardComponents/WizardSavedObjectsList.js`` and ``WizardSteps/WizardShowSummaryStep.js``:

.. code-block:: javascript
import type { ObjectInsideFolderWithTags } from "types"
type WizardSavedObjectsListProps = { submissions: Array<ObjectInsideFolderWithTags> }
.. code-block:: javascript
import type { ObjectInsideFolderWithTags } from "types"
type GroupedBySchema = {| [Schema]: Array<ObjectInsideFolderWithTags> |}
Redux store
-----------

Expand Down
Loading

0 comments on commit 88423b9

Please sign in to comment.