Commit graph

3466 commits

Author SHA1 Message Date
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
Kevin Morris
20f5519b99
fix(fastapi): hide keywords when there are none or they can't be edited
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 18:13:21 -08:00
Kevin Morris
363afff332
feat(fastapi): add /pkgbase/{name}/keywords (post)
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 17:36:08 -08:00
Kevin Morris
5f5fa44d0d
fix(fastapi): fix licenses check
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 17:12:13 -08:00
Kevin Morris
cef217388a
add labels to gitlab issue templates
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 16:50:16 -08:00
Kevin Morris
0da11f068b
fix(fastapi): check for prometheus info.response
When this is unchecked, exceptions cause the resulting stack
trace to be oblivious to the original exception thrown.

This commit changes that behavior so that metrics are created
only when info.response exists.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 16:24:10 -08:00
Kevin Morris
567090547d
add labels to gitlab issue templates
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-11 13:12:23 -08:00
Kevin Morris
66978e40a4
fix(mkpkglists): fix isort order (master)
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-10 13:57:33 -08:00
Kevin Morris
8788f99005
fix(mkpkglists): restore isort order
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-10 13:54:18 -08:00
Kevin Morris
6e344ce9da
fix(mkpkglists): default keys to result[1]
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-10 13:41:53 -08:00
Kevin Morris
52110b7db5
fix(mkpkglists): default keys to result[1]
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-10 13:41:34 -08:00
Kevin Morris
daef98080e
fix(fastapi): fix broken official package query
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-10 13:05:19 -08:00
Kevin Morris
4b2be7fff8
feat(docker): add poetry caching
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-10 13:00:01 -08:00
Kevin Morris
0c57c53da1
fix(sharness): fix AUR_CONFIG generation for mkpkglists test
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-10 07:39:23 -08:00
Kevin Morris
4f7aeafa8d
feat(docker): host gzip archive downloads
- added config option [mkpkglists] archivedir
    - created by mkpkglists

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-10 07:39:23 -08:00
Kevin Morris
abbecf5194
change(mkpkglists): remove header comments
These comments change every time mkpkglists is run; which
would invalidate the ETag headers disbursed by the gzip
host. This commit removes those changing headers.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-10 07:39:17 -08:00
Kevin Morris
107367f958
feat(docker): use mkpkglists --extended flag
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-09 02:29:39 -08:00
Kevin Morris
068b067e14
feat(docker): log cron executions
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-09 02:28:52 -08:00
Kevin Morris
0403b89f53
feat: add packagesmeta[ext]file option to conf/config.dev
Better defaults for Docker here.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-09 02:08:03 -08:00
Kevin Morris
0155f4ea84
fix(mkpkglists): remove caching
We really need caching for this; however, our current caching
method will cause the script to bypass changes to columns
if they have nothing to do with IDs.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-09 02:07:13 -08:00
Kevin Morris
d62af4ceb5
feat(mkpkglists): added metadata archives
Two new archives are available:

- packages-meta-v1.json.gz
    - RPC search formatted data for all packages
    - ~2.1MB at the time of writing.
- packages-meta-ext-v1.json.gz (via --extended)
    - RPC multiinfo formatted data for all packages.
    - ~9.8MB at the time of writing.

New dependencies are required for this update:

- `python-orjson`

All archives served out by aur.archlinux.org distribute the Last-Modified
header and support the If-Modified-Since header, which should be
populated with Last-Modified's value. These should be used by clients
to avoid redownloading the archive when unnecessary.

Additionally, the new meta archives contain a format suitable for
streaming the data as the file is retrieved. It is still in JSON
format, however, users can parse package objects line by line after
the first '[' found in the file, until the last ']'; both contained
on their own lines.

Note: This commit is a documentation change and commit body.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-09 02:07:04 -08:00
Kevin Morris
f3f662c696
fix(mkpkglists): improve package meta archive
The SQL logic in this file for package metadata now exactly
reflects RPC's search logic, without searching for specific
packages.

Two command line arguments are available:

    --extended | Include License, Keywords, Groups, relations
                 and dependencies.

When --extended is passed, the script will create a
packages-meta-ext-v1.json.gz, configured via packagesmetaextfile.

Archive JSON is in the following format: line-separated package objects
enclosed in a list:

    [
    {...},
    {...},
    {...}
    ]

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-09 02:06:50 -08:00
Kristian Klausen
f606140050
feat(PHP): Add packages dump file with more metadata 2021-11-09 02:04:58 -08:00
Kevin Morris
10fcf93991
fix(fastapi): use correct official pkg base url
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-09 01:51:23 -08:00
Kevin Morris
4b8963b7ba
feat(docker): add cron service (aurblup + mkpkglists)
Normally, these scripts are used to update official providers
in the aurweb database along with archives that can be retrieved.

Run both of these scripts in a 5 minute cron job, to both reflect
the live instance database and production load.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-09 00:29:19 -08:00
Kevin Morris
338a44839f
fix: override aurblup's db-path option in config.dev
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-09 00:18:54 -08:00
Kevin Morris
b8d7619dbc
change: add mkpkglists options to config.dev
Here, we default to using root as the storage directory. Primarily
because it makes sense in Docker; config.dev can always be fixed up
by developers to reflect local system changes.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-09 00:17:52 -08:00
Kevin Morris
464540c9a9
fix: use https for aurblup's default mirror instead of ftp
It seems the ftp mirror from kernel.org cannot be used anymore,
but the https mirror can. So, the default config has been updated
to reflect this; otherwise, aurblup bugs out.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-09 00:14:24 -08:00