Skip to content

Commit

Permalink
Merge branch 'wjs-develop' into feature/issue-785-special-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorenzo Gramaccioni committed Aug 20, 2024
2 parents 61fe597 + 0a41843 commit 77adc96
Show file tree
Hide file tree
Showing 33 changed files with 8,477 additions and 94 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ src/files/press
src/files/temp
src/files/xsl
src/plugins/*
src/media/*

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,5 @@ src/utils/management/commands/test_command.py
!/src/static/admin/
/src/static/admin/hypothesis/**
jenkins/test-results

.python-version
120 changes: 120 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
default:
cache:
key: cache-default
paths:
- .cache
- /var/cache

stages:
- build
- deploy

include:
- project: 'wjs/wjs-profile-project'
ref: master
file: '.gitlab-ci-pkg-deploy.yml'


deploy_to_test:
extends:
- .deploy
tags:
- inasset
variables:
SERVER_IP: "$TEST_SERVER_IP"
SERVER_USER: "$TEST_SERVER_USER"
DEPLOY_CMD: "deploy-test-janeway"
environment:
name: development
url: https://wjs-test-test-journals.wjapp.it/
rules:
- if: $CI_COMMIT_BRANCH == "wjs-develop"


deploy_to_dev:
extends:
- .deploy
tags:
- inasset
variables:
SERVER_IP: "$TEST_SERVER_IP"
SERVER_USER: "$TEST_SERVER_USER"
DEPLOY_CMD: "deploy-dev-janeway"
environment:
name: development
url: https://wjs-test-dev-journals.wjapp.it/
rules:
- if: $CI_COMMIT_BRANCH == "wjs-develop"
when: manual

deploy_to_pp:
extends:
- .deploy
tags:
- inasset
variables:
SERVER_IP: "$TEST_SERVER_IP"
SERVER_USER: "$TEST_SERVER_USER"
DEPLOY_CMD: "deploy-pp-janeway"
environment:
name: pre-production
url: https://wjs-test-pp-journals.wjapp.it/
when: manual


deploy_to_production:
extends:
- .deploy
tags:
- inasset
variables:
SERVER_IP: "$PROD_SERVER_IP"
SERVER_USER: "$PROD_SERVER_USER"
DEPLOY_CMD: "deploy-prod-janeway"
environment:
name: production
url: https://journals.sissamedialab.it/
when: manual


.build_janeway_image:
stage: build

# Important: runners that should support dind must have
# volumes = ["/certs/client",...
# privileged = true
tags:
- dind
- inasset

# We get
# *** WARNING: Service ... probably didn't start properly.
# Ignore for now; see:
# https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4550
services:
- docker:dind

# I wasn't able to find a way to use the group-level container registry from CI/CD
# See https://gitlab.com/gitlab-org/gitlab/-/issues/218285
# So here I just use the project's registry.
variables:
TAG: "$CI_REGISTRY_IMAGE/debian-python-git-janeway"

# To cache from the previous image (--cache-from), see
# https://docs.docker.com/engine/reference/commandline/build/#cache-from
#
# To authenticate with the Container Registry, see
# https://docs.gitlab.com/ee/user/packages/container_registry/authenticate_with_container_registry.html
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $TAG || true
- docker build --tag $TAG --cache-from $TAG --build-arg BUILDKIT_INLINE_CACHE=1 --build-arg CI_JOB_TOKEN=$CI_JOB_TOKEN --build-arg BRANCH=$CI_COMMIT_BRANCH --file ./dockerfiles/Dockerfile.wjs ./dockerfiles
- docker push $TAG

build_janeway_image_wjs_develop:
extends:
- .build_janeway_image
variables:
TAG: "$CI_REGISTRY_IMAGE/debian-python-git-janeway:develop"
rules:
- if: $CI_COMMIT_BRANCH == "wjs-develop"
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ services:
janeway-web:
build:
context: .
dockerfile: dockerfiles/Dockerfile
dockerfile: dockerfiles/Dockerfile.wjs
volumes:
- ./src:/vol/janeway/src
- ./lib:/vol/janeway/lib
Expand All @@ -87,9 +87,9 @@ services:
- JANEWAY_EMAIL_HOST
- JANEWAY_EMAIL_PORT
- JANEWAY_EMAIL_USE_TLS

depends_on:
- "start_dependencies"
#
# depends_on:
# - "start_dependencies"
cap_add:
- SYS_PTRACE

Expand Down
27 changes: 27 additions & 0 deletions dockerfiles/Dockerfile.wjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# A docker image with Janeway ready to `runserver` from branch jcom
# and with BB typesetting plugin linked into Janeway's plugins folder.
FROM python:3.11
# The two cache mounts seem to have no effect
# (at least when the image is build from a dind in a CI/CD job)
ARG CI_JOB_TOKEN
ENV CI_JOB_TOKEN ${CI_JOB_TOKEN}
ARG BRANCH
ENV BRANCH ${BRANCH}
RUN --mount=type=cache,mode=0755,target=/var/cache/apt \
apt-get update && \
apt-get install -y file \
python3 python3-dev pip \
git \
mariadb-client libmariadb-dev \
libssl-dev \
postgresql-client
RUN echo "Cloning Janeway code ${BRANCH}..." && \
git clone --branch ${BRANCH} --single-branch https://github.com/sissamedialab/janeway.git && \
cd /janeway && \
git checkout origin/${BRANCH} && \
git pull
RUN echo "Installing Janeway requirements..." && \
pip install -r /janeway/requirements.txt
RUN echo "Cloning typesetting plugin at tag v1.3.0-RC-1..." && \
cd / && git clone --branch master --single-branch https://github.com/BirkbeckCTP/typesetting && \
ln -s /typesetting /janeway/src/plugins/
20 changes: 20 additions & 0 deletions finalize-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

if [[ $# -lt 1 ]]; then
echo -e "Missing parameter\nCommand: $0 /path/to/python"
exit 1
fi

PYTHON=$1

$PYTHON manage.py link_plugins
$PYTHON manage.py install_themes

$PYTHON manage.py migrate
$PYTHON manage.py build_assets
$PYTHON manage.py collectstatic --noinput

$PYTHON manage.py add_coauthors_submission_email_settings
$PYTHON manage.py add_generic_analytics_code_setting
$PYTHON manage.py add_publication_alert_settings
$PYTHON manage.py add_user_as_main_author_setting
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ django-bleach==3.0.1
django-bootstrap4==23.2
-e git+https://github.com/BirkbeckCTP/django-foundation-form.git@284fc5f08e58d8655c7301eddb49f920fda516d2#egg=foundationform
django-countries[pyuca]==7.5.1
-e git+https://github.com/kalwalkden/django-materializecss-form.git@7018fe0659ad12e74cfea80e281faa1390a3132f#egg=django-materializecss-form
https://github.com/kalwalkden/django-materializecss-form/archive/refs/heads/saemideluxe-patch-1.zip#egg=django-materializecss-form
django-debug-toolbar==3.7.0
django-hCaptcha==0.2.0
django-hijack==3.2.1
Expand Down Expand Up @@ -50,7 +50,7 @@ pycparser==2.14
PyJWT==2.4.0
Pillow==10.2.0
python-crontab==2.2.3
python-dateutil==2.8.1
python-dateutil~=2.8.2
python-docx==0.8.11
python-magic==0.4.13
requests==2.31.0
Expand Down
16 changes: 12 additions & 4 deletions src/core/include_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@
re_path(r'^reset/step/2/(?P<token>[\w-]+)/$', core_views.reset_password, name='core_reset_password'),
re_path(r'^profile/$', core_views.edit_profile, name='core_edit_profile'),
re_path(r'^logout/$', core_views.user_logout, name='core_logout'),
re_path(r'^dashboard/$', core_views.dashboard, name='core_dashboard'),
re_path(r'^dashboard/active/$', core_views.active_submissions, name='core_active_submissions'),
re_path(r'^dashboard/active/filters/$', core_views.active_submission_filter, name='core_submission_filter'),
re_path(r'^dashboard/article/(?P<article_id>\d+)/$', core_views.dashboard_article, name='core_dashboard_article'),

re_path(r'^press/cover/$', press_views.serve_press_cover, name='press_cover_download'),
re_path(r'^press/file/(?P<file_id>\d+)/$',
Expand Down Expand Up @@ -276,6 +272,18 @@
if hasattr(val, 'notify_hook'):
settings.NOTIFY_FUNCS.append(val.notify_hook)

if "plugins.wjs_review" not in settings.INSTALLED_APPS:
urlpatterns += [
re_path(r'^dashboard/$', core_views.dashboard, name='core_dashboard'),
re_path(r'^dashboard/active/$', core_views.active_submissions, name='core_active_submissions'),
re_path(r'^dashboard/active/filters/$', core_views.active_submission_filter, name='core_submission_filter'),
re_path(r'^dashboard/article/(?P<article_id>\d+)/$', core_views.dashboard_article, name='core_dashboard_article'),
]
else:
urlpatterns += [
path('dashboard/', include('wjs.jcom_profile.dashboard.urls')),
]

urlpatterns += [
re_path(r'^site/(?P<page_name>.*)/$', cms_views.view_page, name='cms_page'),
]
Loading

0 comments on commit 77adc96

Please sign in to comment.