From c68907b2527dc4d77615d34e9d60fdf2dbb514c7 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Wed, 5 Jan 2022 14:18:42 +0100 Subject: [PATCH] Runs Ci on ubuntu-latest Signed-off-by: Carl Schwan --- .github/workflows/yarn.yml | 4 +++- Makefile | 5 +---- docs/devinstall.rst | 12 +++++++++--- .../commands/createdbtranslations.py | 3 +-- .../core/tests/e2e/test_app_upload.py | 10 ++++------ .../core/tests/e2e/test_user_register.py | 9 +-------- nextcloudappstore/settings/base.py | 10 +++++----- poetry.lock | 4 ++-- pyproject.toml | 2 +- requirements/base.txt | 18 ------------------ requirements/development.txt | 7 ------- requirements/production.txt | 3 --- scripts/development/settings/base.py | 6 +++++- 13 files changed, 32 insertions(+), 61 deletions(-) delete mode 100644 requirements/base.txt delete mode 100644 requirements/development.txt delete mode 100644 requirements/production.txt diff --git a/.github/workflows/yarn.yml b/.github/workflows/yarn.yml index dcf6e38105..6ac65d5df6 100644 --- a/.github/workflows/yarn.yml +++ b/.github/workflows/yarn.yml @@ -11,7 +11,7 @@ env: jobs: test: - runs-on: ubuntu-16.04 + runs-on: ubuntu-latest strategy: matrix: @@ -41,6 +41,8 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + - name: Install poetry + run: pip install poetry==1.1.12 - uses: browser-actions/setup-firefox@latest with: firefox-version: latest diff --git a/Makefile b/Makefile index c643dcc598..c82392a2b0 100644 --- a/Makefile +++ b/Makefile @@ -41,10 +41,7 @@ dev-setup: rm -f db.sqlite3 $(yarn) install $(yarn) run build - poetry install -ifeq ($(db), postgres) - $(pip) install -r $(CURDIR)/requirements/production.txt -endif + $(poetry) install cp $(CURDIR)/scripts/development/settings/base.py $(CURDIR)/nextcloudappstore/settings/development.py cat $(CURDIR)/scripts/development/settings/$(db).py >> $(CURDIR)/nextcloudappstore/settings/development.py $(MAKE) initdb diff --git a/docs/devinstall.rst b/docs/devinstall.rst index 1aad009cd5..d7550be573 100644 --- a/docs/devinstall.rst +++ b/docs/devinstall.rst @@ -35,6 +35,12 @@ Clone the repository using git and change into it:: git clone https://github.com/nextcloud/appstore.git cd appstore +Install poetry +-------------- +Install poetry to handle python dependencies:: + + pip install poetry==1.1.12 + App Store Setup --------------- The project root contains a **Makefile** which allows you to quickly set everything up by running:: @@ -47,7 +53,7 @@ Launching the Development Server -------------------------------- The server can be started after activating the virtual environment first:: - source venv/bin/activate + poetry shell export DJANGO_SETTINGS_MODULE=nextcloudappstore.settings.development python manage.py runserver @@ -55,12 +61,12 @@ The website is available at `http://127.0.0.1:8000 `_. Co Every time you start a new terminal session you will need to reactive the virtual environment and set the development settings:: - source venv/bin/activate + poetry shell export DJANGO_SETTINGS_MODULE=nextcloudappstore.settings.development We therefore recommend creating a small bash alias in your **~/.bashrc**:: - alias cda='cd path/to/appstore && source venv/bin/activate && export DJANGO_SETTINGS_MODULE=nextcloudappstore.settings.development' + alias cda='cd path/to/appstore && poetry shell && export DJANGO_SETTINGS_MODULE=nextcloudappstore.settings.development' Keeping Up to Date ------------------ diff --git a/nextcloudappstore/core/management/commands/createdbtranslations.py b/nextcloudappstore/core/management/commands/createdbtranslations.py index 550043cf8a..9105c05c0e 100644 --- a/nextcloudappstore/core/management/commands/createdbtranslations.py +++ b/nextcloudappstore/core/management/commands/createdbtranslations.py @@ -12,8 +12,7 @@ def escape_tpl_string(string): class Command(BaseCommand): - translation_file = ('nextcloudappstore/core/templates/translation/' - 'db_translations.txt') + translation_file = ('core/templates/translation/' 'db_translations.txt') help = ( 'Goes through all translated database models (hardcoded) and creates ' 'translations in %s' % translation_file) diff --git a/nextcloudappstore/core/tests/e2e/test_app_upload.py b/nextcloudappstore/core/tests/e2e/test_app_upload.py index d2fd1bb38c..bdc89320a9 100644 --- a/nextcloudappstore/core/tests/e2e/test_app_upload.py +++ b/nextcloudappstore/core/tests/e2e/test_app_upload.py @@ -34,12 +34,10 @@ class UploadAppReleaseTest(BaseStoreTest, AppDevSteps): self.assertEqual(NEWS_ARCHIVE_URL, a.get_attribute('href')) def upload_app(el): - with self.settings(VALIDATE_CERTIFICATES=True): - self._upload_app(NEWS_ARCHIVE_URL, NEWS_ARCHIVE_SIGNATURE) - self.wait_for('.global-success-msg', check_app_version_page) + self._upload_app(NEWS_ARCHIVE_URL, NEWS_ARCHIVE_SIGNATURE) + self.wait_for('.global-success-msg', check_app_version_page) - # this signature is secret so ignore cert checks here - with self.settings(VALIDATE_CERTIFICATES=False): + with self.settings(VALIDATE_CERTIFICATES=True): self.register_app(NEWS_CERT, 'test') # and run them for uploading the app archive @@ -49,4 +47,4 @@ class UploadAppReleaseTest(BaseStoreTest, AppDevSteps): self.go_to_app_upload() self.by_id('id_download').send_keys(url) self.by_id('id_signature').send_keys(sig) - self.by_id('id_signature').submit() + self.by_id('submit').click() diff --git a/nextcloudappstore/core/tests/e2e/test_user_register.py b/nextcloudappstore/core/tests/e2e/test_user_register.py index f028f8e315..adb87b9e55 100644 --- a/nextcloudappstore/core/tests/e2e/test_user_register.py +++ b/nextcloudappstore/core/tests/e2e/test_user_register.py @@ -7,16 +7,13 @@ from django.test import tag @tag('e2e') class UserRegisterTest(BaseStoreTest): - def setUp(self): - super().setUp() - os.environ['RECAPTCHA_DISABLE'] = 'True' - def test_register(self): self.go_to('account_signup') self.by_id('id_first_name').send_keys('john') self.by_id('id_last_name').send_keys('doe') self.by_id('id_username').send_keys('johndoe') self.by_id('id_email').send_keys('john@doe.com') + self.by_id('id_captcha_1').send_keys('PASSED') self.by_id('id_password1').send_keys('oalx77rkdf') self.by_id('id_password2').send_keys('oalx77rkdf') @@ -35,7 +32,3 @@ class UserRegisterTest(BaseStoreTest): self.by_id('id_password').send_keys('oalx77rkdf') self.by_css('.auth-form button[type="submit"]').click() self.assertOnPage('home') - - def tearDown(self): - super().tearDown() - del os.environ['RECAPTCHA_DISABLE'] diff --git a/nextcloudappstore/settings/base.py b/nextcloudappstore/settings/base.py index 7c8a634ccc..fa1fc8bf46 100644 --- a/nextcloudappstore/settings/base.py +++ b/nextcloudappstore/settings/base.py @@ -242,7 +242,7 @@ LOGGING = { }, } LOCALE_PATHS = ( - BASE_DIR / 'locale/', + BASE_DIR.parent / 'locale/', ) # Disable in order for cooldown periods to work properly @@ -272,10 +272,8 @@ ARCHIVE_FOLDER_BLACKLIST = { } # certificate location configuration -NEXTCLOUD_CERTIFICATE_LOCATION = BASE_DIR / \ - 'nextcloudappstore/certificate/nextcloud.crt' -NEXTCLOUD_CRL_LOCATION = BASE_DIR / \ - 'nextcloudappstore/certificate/nextcloud.crl' +NEXTCLOUD_CERTIFICATE_LOCATION = BASE_DIR / 'certificate/nextcloud.crt' +NEXTCLOUD_CRL_LOCATION = BASE_DIR / 'certificate/nextcloud.crl' # whitelist for serializing markdown MARKDOWN_ALLOWED_TAGS = [ @@ -313,3 +311,5 @@ GITHUB_API_TOKEN = None # Nextcloud Email NEXTCLOUD_FROM_EMAIL = 'appstore@nextcloud.com' NEXTCLOUD_INTEGRATIONS_APPROVAL_EMAILS = ['marketing-team@nextcloud.com'] + +DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' diff --git a/poetry.lock b/poetry.lock index aa7369bd49..1a8323300d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -933,8 +933,8 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytes [metadata] lock-version = "1.1" -python-versions = "3.6" -content-hash = "05a1a51adc9094bcc5e2b6a201a4defa83f59080b0d6e6e1427945852e5f92f5" +python-versions = "^3.6" +content-hash = "8026c80d4a1aedc95b27c88427b556dd155555b3df468b46d674efa19d626201" [metadata.files] asgiref = [ diff --git a/pyproject.toml b/pyproject.toml index a0a70406a5..dd1f61f8e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ description = "App store for Nextcloud apps" authors = ["Morris Jobke "] [tool.poetry.dependencies] -python = "3.6" +python = "^3.6" Django = "3.2" django-braces = "~1.13" djangorestframework-camel-case = "^1.3.0" diff --git a/requirements/base.txt b/requirements/base.txt deleted file mode 100644 index 85167e5308..0000000000 --- a/requirements/base.txt +++ /dev/null @@ -1,18 +0,0 @@ -Django==3.0.13 -djangorestframework==3.12.4 -semantic-version==2.8.5 -djangorestframework-camel-case==1.2.0 -django-parler==2.2 -django-parler-rest==2.1 -django-allauth==0.44.0 -django-recaptcha2==1.4.1 -lxml==4.6.3 -pytz==2021.1 -requests==2.25.1 -pymple==0.1.3 -django-csp==3.7 -django-cors-middleware==1.5.0 -pyOpenSSL==20.0.1 -pem==21.2.0 -Markdown==3.2.1 -bleach==3.3.0 diff --git a/requirements/development.txt b/requirements/development.txt deleted file mode 100644 index 2a671eff56..0000000000 --- a/requirements/development.txt +++ /dev/null @@ -1,7 +0,0 @@ -pycodestyle -mypy -bandit -django-debug-toolbar -coverage -selenium -coveralls diff --git a/requirements/production.txt b/requirements/production.txt deleted file mode 100644 index d2b82deffa..0000000000 --- a/requirements/production.txt +++ /dev/null @@ -1,3 +0,0 @@ -uWSGI==2.0.19.1 -newrelic==5.24.0.153 -psycopg2==2.8.6 diff --git a/scripts/development/settings/base.py b/scripts/development/settings/base.py index 45aac8652f..c7d7be3b01 100644 --- a/scripts/development/settings/base.py +++ b/scripts/development/settings/base.py @@ -14,7 +14,7 @@ INTERNAL_IPS = ('127.0.0.1',) VALIDATE_CERTIFICATES = False FIXTURE_DIRS = ( - BASE_DIR / 'nextcloudappstore/core/tests/e2e/fixtures', + BASE_DIR / 'core/tests/e2e/fixtures', ) LOGGING['handlers']['console'] = { @@ -40,3 +40,7 @@ if 'test' in sys.argv: EMAIL_HOST = 'localhost' EMAIL_HOST_USER = "noreply@nextcloud.com" + +# Disable testing in tests +TESTING = bool(len(sys.argv) > 1 and sys.argv[1] == 'test') +CAPTCHA_TEST_MODE = TESTING