diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..cc238997 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,33 @@ +--- +name: Default Issue template +about: Create an issue to help us improve +title: '' +labels: '' +assignees: '' +--- + +**Describe the issue** +A clear and concise description of what the issue is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '…' +1. Log in as '…' +1. Click on '…' +1. Scroll down to '…' +1. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Software version** +Tell us which version you're using: + + * from which server URL do you come from? ils.test or ilsdev? + * checks the version on homepage. Do you see the version as 0.5.0 or a hash as 2493ca6? + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..6c6f4202 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,19 @@ +## Why are you opening this PR? + +- Which task/US does it implement? +- Which issue does it fix? + +## How to test? + +- What command should I have to run to test your PR? +- What should I test through the UI? + +## Code review check list + +- [ ] Commit message template compliance. +- [ ] Commit message without typos. +- [ ] File names. +- [ ] Functions names. +- [ ] Functions docstrings. +- [ ] Unnecessary commited files? +- [ ] Extracted translations? diff --git a/.github/workflows/continuous-integration-test.yml b/.github/workflows/continuous-integration-test.yml new file mode 100644 index 00000000..62f1ad3f --- /dev/null +++ b/.github/workflows/continuous-integration-test.yml @@ -0,0 +1,49 @@ +name: build +on: [push, pull_request, workflow_dispatch] + +env: + TERM: xterm-256color + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Install Libraries + run: | + sudo apt-get install -y libxml2 libxml2-dev libxmlsec1 libxmlsec1-dev xpdf ghostscript imagemagick + sudo sed -i 's///g' /etc/ImageMagick-6/policy.xml + + - name: Setup node + uses: actions/setup-node@v1 + with: + node-version: '12' + + - name: Docker compose up + run: docker-compose up -d + + - name: Setup Python 3.6 + uses: actions/setup-python@v2 + with: + python-version: 3.6 + + - name: Install Poetry + uses: snok/install-poetry@v1.1.1 + with: + version: 1.0.10 + + - name: Run Bootstrap + run: | + poetry run ./scripts/bootstrap + poetry run pip install --upgrade coveralls + + - name: Run Test + run: poetry run ./scripts/test + + - name: Code Coverage + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + pip install --upgrade coveralls + coveralls diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9d0299cc..00000000 --- a/.travis.yml +++ /dev/null @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Swiss Open Access Repository -# Copyright (C) 2019 RERO -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, version 3 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -addons: - chrome: stable # https://docs.travis-ci.com/user/chrome - -# Chrome Webdriver fails if not on sudo -# See https://github.com/travis-ci/travis-ci/issues/8836 -sudo: true - -dist: trusty # Chrome driver fails if not trusty dist - -notifications: - email: # sent to the committer and the author - on_success: never # default: always - on_failure: always # default: always - -language: python - -matrix: - fast_finish: true - -cache: - - pip - -services: - - docker - -python: - - "3.6" - -before_install: - - sudo apt-get update - - sudo apt-get install -y libxml2 libxml2-dev libxmlsec1 libxmlsec1-dev xpdf ghostscript imagemagick - # Stop default travis services - - "sudo service mysql stop" - - "sudo service postgresql stop" - # Start docker services - - "docker-compose up -d" - # Chrome webdriver for Selenium - - "PATH=$PATH:$HOME/webdrivers" - - "nvm install 8; nvm use 8" - - "travis_retry pip install --upgrade pip setuptools py \"poetry<1.1.0\"" - - "travis_retry pip install twine wheel coveralls" - # patch default version of travis which is marked as unsafe by pipenv check - - "travis_retry pip install --upgrade numpy" - -install: - - "./scripts/bootstrap" - - "poetry show" - -before_script: - # https://docs.travis-ci.com/user/gui-and-headless-browsers/ - - "export DISPLAY=:99.0" - # Allow services running inside docker to start - - "./docker/wait-for-services.sh" - -script: - - "./scripts/test" - -after_success: - - coveralls diff --git a/README.rst b/README.rst index aaaeff21..fda95fb1 100644 --- a/README.rst +++ b/README.rst @@ -18,8 +18,9 @@ Swiss Open Access Repository ============================== -.. image:: https://img.shields.io/travis/rero/sonar.svg - :target: https://travis-ci.org/rero/sonar +.. image:: https://github.com/rero/sonar/workflows/build/badge.svg + :alt: Github actions status + :target: https://github.com/rero/sonar/actions?query=workflow%3Abuild .. image:: https://img.shields.io/coveralls/rero/sonar.svg :target: https://coveralls.io/r/rero/sonar diff --git a/tests/api/deposits/test_deposits_rest.py b/tests/api/deposits/test_deposits_rest.py index 5125108e..6067b3d2 100644 --- a/tests/api/deposits/test_deposits_rest.py +++ b/tests/api/deposits/test_deposits_rest.py @@ -87,10 +87,10 @@ def test_file_put(client, deposit): # With embargo date response = client.put(url.format(pid=deposit['pid'], key='main.pdf'), - data=json.dumps({'embargoDate': '2021-01-01'}), + data=json.dumps({'embargoDate': '2022-01-01'}), headers={'Content-Type': 'application/json'}) assert response.status_code == 200 - assert response.json['embargoDate'] == '2021-01-01' + assert response.json['embargoDate'] == '2022-01-01' # With wrong embargo date response = client.put(url.format(pid=deposit['pid'], key='main.pdf'), diff --git a/tests/api/test_api_simple_flow.py b/tests/api/test_api_simple_flow.py index f8047567..51f5bd40 100644 --- a/tests/api/test_api_simple_flow.py +++ b/tests/api/test_api_simple_flow.py @@ -57,5 +57,5 @@ def test_add_files_restrictions(client, document_with_file, superuser): assert res.status_code == 200 assert res.json['metadata']['_files'][0]['restriction'] == { 'restricted': True, - 'date': '01/01/2021' + 'date': '01/01/2022' } diff --git a/tests/conftest.py b/tests/conftest.py index 5501dee1..54d269fc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -391,7 +391,7 @@ def _make_document(organisation='org', with_file=False, pid=None): order=1, access='coar:c_f1cf', restricted_outside_organisation=False, - embargo_date='2021-01-01') + embargo_date='2022-01-01') record.commit() db.session.commit() @@ -525,7 +525,7 @@ def _make_deposit(role='submitter', organisation=None): record.files['main.pdf']['category'] = 'main' record.files['main.pdf']['type'] = 'file' record.files['main.pdf']['embargo'] = True - record.files['main.pdf']['embargoDate'] = '2021-01-01' + record.files['main.pdf']['embargoDate'] = '2022-01-01' record.files['main.pdf']['exceptInOrganisation'] = True record.files['additional.pdf'] = BytesIO(content) @@ -562,7 +562,7 @@ def deposit(app, db, user, pdf_file, bucket_location, deposit_json): deposit.files['main.pdf']['category'] = 'main' deposit.files['main.pdf']['type'] = 'file' deposit.files['main.pdf']['embargo'] = True - deposit.files['main.pdf']['embargoDate'] = '2021-01-01' + deposit.files['main.pdf']['embargoDate'] = '2022-01-01' deposit.files['main.pdf']['exceptInOrganisation'] = True deposit.files['additional.pdf'] = BytesIO(content) @@ -680,6 +680,7 @@ def project(app, db, user, organisation, project_json): def bucket_location(app, db): """Create a default location for managing files.""" tmppath = tempfile.mkdtemp() + print(tmppath) location = Location(name='default', uri=tmppath, default=True) db.session.add(location) db.session.commit() diff --git a/tests/ui/deposits/test_deposits_api.py b/tests/ui/deposits/test_deposits_api.py index 856821a3..56e357e9 100644 --- a/tests/ui/deposits/test_deposits_api.py +++ b/tests/ui/deposits/test_deposits_api.py @@ -161,7 +161,7 @@ def test_create_document(app, db, project, client, deposit, user): assert document.files['main.pdf']['access'] == 'coar:c_f1cf' assert document.files['main.pdf']['restricted_outside_organisation'] - assert document.files['main.pdf']['embargo_date'] == '2021-01-01' + assert document.files['main.pdf']['embargo_date'] == '2022-01-01' assert len(document.files) == 6 # Test without affiliation