Commit graph

3743 commits

Author SHA1 Message Date
Kevin Morris
c7feecd4b8
housekeep(docker): remove configuration regexes in the nginx service
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-20 19:34:33 -08:00
Kevin Morris
a1e547c057
feat(docker): allow configurable SSH_CMDLINE in git service
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-20 19:04:38 -08:00
Kevin Morris
ba3ef742ce
feat(docker): allow user-customizable ssh host keys
There is a new ./data bind mount used here. If ssh_host_* keys are
in ./data when the git service starts, they'll override the
container-generated host keys.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-20 18:40:32 -08:00
Kevin Morris
233d25b1c3
feat: add test_spawn, an aurweb.spawn test
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-20 15:47:25 -08:00
Kevin Morris
19191fa8b5
fix: update nginx config in aurweb.spawn
Host a specific FastAPI nginx frontend as well as a PHP
nginx frontend, configurable by the (PHP|FASTAPI)_NGINX_PORT
environment variables.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-20 15:47:25 -08:00
Kevin Morris
47d0df76e6
feat: support gunicorn in aurweb.spawn
This also comes with a -w|--workers argument that allows
the caller to set the number of gunicorn workers.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-20 15:47:24 -08:00
Kevin Morris
82ca4ad9a0
feat: check php configuration in aurweb.spawn
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-20 15:47:24 -08:00
Kevin Morris
191198ca41
housekeep(fastapi): simplify aurweb.spawn.stop()
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-20 15:47:24 -08:00
Kevin Morris
0b5d088016
fix(fastapi): catch ProgrammingError instead of OperationalError in conftest
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-20 13:20:47 -08:00
Kevin Morris
008a8824ce
housekeep(fastapi): simplify package_base_comaintainers_post
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-20 13:20:46 -08:00
Kevin Morris
f897411ddf
change(fastapi): let conftest bypass create database errors
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-18 21:27:09 -08:00
Kevin Morris
7f981b9ed7
fix(fastapi): utilize auto_{orphan,deletion}_age
Didn't get this in when the initial request port went down;
here it is.

Auto-accept orphan requests when the package has been out of
date for longer than auto_orphan_age.

Auto-accept deletion requests by the package's maintainer
if the package has been uploaded within auto_deletion_age
seconds ago.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-18 21:27:03 -08:00
Kevin Morris
a348cdaac3
housekeep(fastapi): cleanup unneeded jinja set statement
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-18 16:44:13 -08:00
Kevin Morris
7739b2178e
fix(fastapi): fix comment edit image sources
These were using the old comment image sources. Slipped in
due to cache and not checking without cache.

Fixed them to use src="/static/images/...".

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-18 16:43:10 -08:00
Kevin Morris
dbe5cb4a33
fix(fastapi): only include comment-edit.js where needed
Closes: #178

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-18 16:42:26 -08:00
Kevin Morris
672af707ad
remove C901 and E741 per-file-ignores exclusion
We no longer have C901 violations and we're already ignoring
E741 (short variable names) in the overall `ignore` option.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 06:00:12 -08:00
Kevin Morris
2df7187514
fix global test_ssh_pub_key E501 flake8 violation
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 06:00:12 -08:00
Kevin Morris
2892d21ff1
remove global aurweb.models flake8 F401 ignore
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 06:00:12 -08:00
Kevin Morris
303585cdbf
change(fastapi): decouple update logic from account edit
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 06:00:07 -08:00
Kevin Morris
94972841d6
change(fastapi): decouple error logic from process_account_form
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 05:58:08 -08:00
Kevin Morris
ccf50cbdf5
change: rework test_rpc's TestClient usage into a fixture
This is the first step on our path to reworking the test
suite in general.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 02:30:06 -08:00
Kevin Morris
abe8c0630c
fix(rpc): improve type=info performance
Now, we use an equivalent query to PHP's query, yet we grab
every piece of data we need for all packages asked for in one
database query.

At this time, local benchmarks have shown a slight performance
improvement when compared to PHP.

fastapi 262 requests/sec
php 250 requests/sec

Extras:

- Moved RPCError to the aurweb.exceptions module

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 02:30:06 -08:00
Kevin Morris
912b7e0c11
fix(docker): fix database user/password for git-entrypoint
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 02:29:36 -08:00
Kevin Morris
a5c0c47e5b
change(.gitlab-ci): adapt for new conftest
No longer do we need to create any database in .gitlab-ci.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 01:36:19 -08:00
Kevin Morris
fb92fb509b
change(fastapi): use sys.getrecursionlimit() + 1000 as default
Without the increment, we've seen tests failed due to recursion
errors caused by starlette's base middleware. Just make it safe
in case nobody supplies TEST_RECURSION_LIMIT.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 01:36:19 -08:00
Kevin Morris
60f63876c4
change(.gitignore): ignore archives
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 01:36:18 -08:00
Kevin Morris
a025118344
change(docker): get python-poetry from arch instead of poetry
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 01:36:18 -08:00
Kevin Morris
fa26c8078b
fix(docker): modify db configuration for new tests
A user that can create databases is now required for tests,
we use the 'root' user in Docker.

Added docker services:
---------------------
- mariadb_test - host localhost:13307

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 01:36:16 -08:00
Kevin Morris
fa43f6bc3e
change(aurweb): add parallel tests and improve aurweb.db
This change utilizes pytest-xdist to perform a multiproc test
run and reworks aurweb.db's code. We no longer use a global
engine, session or Session, but we now use a memo of engines
and sessions as they are requested, based on the PYTEST_CURRENT_TEST
environment variable, which is available during testing.

Additionally, this change strips several SQLite components
out of the Python code-base.

SQLite is still compatible with PHP and sharness tests, but
not with our FastAPI implementation.

More changes:
------------
- Remove use of aurweb.db.session global in other code.
- Use new aurweb.db.name() dynamic db name function in env.py.
- Added 'addopts' to pytest.ini which utilizes multiprocessing.
    - Highly recommended to leave this be or modify `-n auto` to
      `-n {cpu_threads}` where cpu_threads is at least 2.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 01:34:59 -08:00
Kevin Morris
07aac768d6
change(fastapi): remove sqlite support
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 01:34:59 -08:00
Kevin Morris
0abdf8d468
fix(fastapi): close connection used for initdb
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 01:34:58 -08:00
Kevin Morris
40b21203ed
feat(poetry): add filelock
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 01:34:58 -08:00
Kevin Morris
cea9104efb
feat(poetry): add pytest-xdist
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 01:34:58 -08:00
Kevin Morris
b0b05df193
fix(fastapi): pin markdown to 3.3.4
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-16 21:11:35 -08:00
Kevin Morris
e3fff9e357
Merge branch 'feat-csrf-login-check' into pu 2021-11-15 12:00:07 -08:00
Kevin Morris
91b570ff0d
Merge branch 'db-rework' into pu 2021-11-15 00:02:56 -08:00
Kevin Morris
7f6d9966e5
fix: initialize engine and session in util/adduser.py
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-15 00:01:13 -08:00
Kevin Morris
9424341b55
fix(docker): fix cgit css config
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-14 23:41:42 -08:00
Kevin Morris
12400147fc
fix: initialize engine and session in util/adduser.py
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-14 16:15:56 -08:00
Kevin Morris
4103ab49c9
housekeep(fastapi): rework aurweb.db session API
Changes:
-------
- Add aurweb.db.get_session()
    - Returns aurweb.db's global `session` instance
    - Provides us a way to change the implementation of the session
      instance without interrupting user code.
- Use aurweb.db.get_session() in session API methods
- Add docstrings to session API methods
- Refactor aurweb.db.delete
    - Normalize aurweb.db.delete to an alias of session.delete
- Refresh instances in places we depend on their non-PK columns
  being up to date.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-14 16:15:50 -08:00
Kevin Morris
f8ba2c5342
cleanup(fastapi): simplify aurweb.routers.accounts.accounts_post
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-14 15:32:23 -08:00
Kevin Morris
cee7512e4d cleanup(fastapi): simplify PackageDependency.is_package()
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-12 20:50:08 -08:00
Kevin Morris
bd59adc886
fix(fastapi): use NumVotes for votes field in package details
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-12 17:39:26 -08:00
Kevin Morris
686c032290
feat(fastapi): add id="licenses" to package details licenses
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 19:55:04 -08:00
Kevin Morris
7aa959150e
feat(fastapi): add id="conflicts" to package details conflicts
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 19:54:30 -08:00
Kevin Morris
e8e9edbb21
change(fastapi): simplify package details database queries
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 19:30:21 -08:00
Kevin Morris
a33e9bd571
feat(fastapi): add Replaces field to package details
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 19:15:29 -08:00
Kevin Morris
50a9690c2d
feat(fastapi): add Provides field in package details
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 19:15:03 -08:00
Kevin Morris
2016b80ea9
fix(fastapi): hide conflicts when there are none
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 18:14:50 -08:00
Kevin Morris
2dc6cfec23
fix(fastapi): reorganize licenses display
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 18:14:15 -08:00