Commit graph

49 commits

Author SHA1 Message Date
moson-mo
8ca63075e9
housekeep: remove PHP implementation
removal of the PHP codebase

Signed-off-by: moson-mo <mo-son@mailbox.org>
2023-04-28 16:10:32 +02:00
Leonidas Spyropoulos
ef2baad7b3
feat: expand on update.py tests and show on Gitlab UI
Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
2023-01-27 17:16:25 +00:00
Kevin Morris
929bb756a8
ci(lint): add .pre-commit cache for pre-commit
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-08-23 02:32:35 -07:00
Kevin Morris
fbb3e052fe
ci: use cache/virtualenv for test dependencies
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-08-23 02:19:16 -07:00
Joakim Saario
de5538a40f
ci(lint): Use pre-commit 2022-08-22 22:42:10 +02:00
Jelle van der Waa
8598ea6f74
fix(gitlab-ci): update coverage reporting in CI
Gitlab 14.10 introduced a coverage_report key which obsoletes the old
way of reporting coverage data.
2022-06-27 21:05:05 +02:00
Kevin Morris
8cca03a3f6
gitlab-ci: add lint job (stage: .pre)
- directories to be linted can be configured in .gitlab-ci.yml's
  `REQUIRES_LINT` variable
- removed linting from the test job

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-23 15:47:26 -08:00
Kevin Morris
7bcc8d7ce7
feat: support LOG_CONFIG environment variable
This variable allows users to override the logging.conf used
for Python logging configuration. By default, this is set
to logging.conf, which is a production config. LOG_CONFIG
is treated relative to [options] aurwebdir.

This patch allows us to specify the logging config as opposed
to copying over logging.conf in our test docker and gitlab
test scripts, as well as ease-of-testing as a developer.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-18 07:27:36 -08:00
Kevin Morris
290ef1a2ed
fix(gitlab-ci): remove logging.prod.conf copy
No longer needed; logging.conf, which is the default config
used, is now setup for production INFO logging.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-17 12:27:06 -08:00
Kevin Morris
bf4662e26f
change(logging): restrict logging.conf & add logging.test.conf
We'll override logging.conf with logging.test.conf for debug logging
needed for tests now, so we can rely on the default logging.conf
for production use.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-17 12:11:08 -08:00
Kevin Morris
d31a51742b
fix(gitlab-ci): compile asciidoc
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-13 22:16:17 -08:00
Kevin Morris
6d4e8028eb
change(gitlab-ci): explicitly down containers before upping
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-10 00:26:11 -08:00
Kevin Morris
d0e183a738
Revert "fix(gitlab-ci): only run services we need for deployment"
We'll need to update the nginx config to do this; putting
this off into an MR.

This reverts commit 19bd3766d2.
2021-12-09 21:24:26 -08:00
Kevin Morris
19bd3766d2
fix(gitlab-ci): only run services we need for deployment
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-09 21:11:23 -08:00
Kevin Morris
061e828f16
fix(gitlab-ci): use logging.prod.conf for sharness
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-07 15:09:20 -08:00
Kevin Morris
3a65e33abe
fix(gitlab-ci): prepare conf/config for setup
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-28 19:35:32 -08:00
Kevin Morris
47d83244bb
change(gitlab-ci): add 'fast-single-thread' tag to the test stage
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-22 22:26:56 -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
f26cd1e994
fix(gitlab-ci): add docker dep to deploy target
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-31 16:13:01 -07:00
Kevin Morris
cef69b6342
fix(gitlab-ci): prune dangling images and build cache
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-31 15:48:11 -07:00
Kevin Morris
a3a5ec678c
fix(gitlab-ci): enable options.disable_http_login on aur-dev
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-28 08:19:20 -07:00
Kevin Morris
7ee32a4ea1
fix(gitlab-ci): set GIT_DATA_DIR=git_data on aur-dev
This uses the internally defined docker volume `git_data`,
but the variable is configurable for changes in the future.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-28 08:19:20 -07:00
Kevin Morris
8239dcdd1b
feat(docker): configure fastapi's commit_hash based on $COMMIT_HASH
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-28 08:19:20 -07:00
Kevin Morris
b49b629395
feat(gitlab-ci): set FASTAPI_WORKERS=5 on aur-dev
In addition, specify FASTAPI_BACKEND=gunicorn for deployment.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-28 08:19:19 -07:00
Kevin Morris
1c0543c07e
feat(docker): fixup and utilize AURWEB_(SSHD|FASTAPI|PHP)_PREFIX
Previously CGIT_CLONE_PREFIX_(PHP|FASTAPI), we found that we could
use the same env var in multiple places, including non-cgit-clone-prefix
areas.

So, they were renamed, and one additional prefix was added.

- CGIT_CLONE_PREFIX_PHP -> AURWEB_PHP_PREFIX
    - Used for cgit's clone prefix and AUR_CONFIG's aur_location for PHP
- CGIT_CLONE_PREFIX_FASTAPI -> AURWEB_FASTAPI_PREFIX
    - Used for cgit's clone prefix and AUR_CONFIG's aur_location for FastAPI
- AURWEB_SSHD_PREFIX
    - Used for aurweb's sshd clone prefix shown on package pages

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-28 08:19:19 -07:00
Kristian Klausen
651c1cd8c6
feat(gitlab-ci): Add logic for deploying aur-dev with docker-compose
The infrastructure changes are here[1].

[1] https://gitlab.archlinux.org/archlinux/infrastructure/-/merge_requests/492
2021-10-28 08:19:16 -07:00
Kevin Morris
94d494866f
fix(fastapi): increase recursion limit during tests
The default recursion limit used by Docker's archlinux:base-devel
Python package becomes problematic in some cases when running tests
against our FastAPI application using starlette.testclient.TestClient
(aliased to fastapi.testclient.TestClient). starlette ends up with
test failures because it exceeds the recursion limit, but this only
happens when using the `TestClient`. When the ASGI servers are run,
this is not an issue and so in that case, the recursion limit has
not been touched.

This change uses a `TEST_RECURSION_LIMIT` environment variable to
modify the recursion limit of the FastAPI application. This variable
is, by default, only supplied when running pytests in Docker, but
can be force-supplied by the user.

TEST_RECURSION_LIMIT=10000 has been added to `.env` and `.gitlab-ci.yml`.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-23 20:15:53 -07:00
Kevin Morris
dc5dc233ec
.gitlab-ci.yml: add coverage regex
This was required for the GitLab coverage badge to get the %
of coverage.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-09-21 00:13:29 -07:00
Kevin Morris
2f9994807b
use Poetry to deal with deps and package install
As the new-age Python package manager, Poetry brings a lot
of good additions to the table. It allows us to more easily
deal with virtualenvs for the project and resolve dependencies.

As of this commit, `requirements.txt` is replaced by Poetry,
configured at `pyproject.toml`.

In Docker and GitLab, we currently use Poetry in a root fashion.
We should work toward purely using virtualenvs in Docker, but,
for now we'd like to move forward with other things. The project
can still be installed to a virtualenv and used on a user's system
through Poetry; it is just not yet doing so in Docker.

Modifications:

* docker/scripts/install-deps.sh
    * Remove python dependencies.
* conf/config.defaults
    * Script paths have been updated to use '/usr/bin'.
* docker/git-entrypoint.sh
    * Use '/usr/bin/aurweb-git-auth' instead of
      '/usr/local/bin/aurweb-git-auth'.

Additions:

* docker/scripts/install-python-deps.sh
    * A script used purely to install Python dependencies with Poetry.
      This has to be used within the aurweb project directory and
      requires system-wide dependencies are installed beforehand.
    * Also upgrades system-wide pip.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-09-04 15:46:40 -07:00
Hunter Wittenborn
eff7d478ab Updated CI tests for pip dependencies; Changed styling in install-deps.sh 2021-08-28 20:12:35 -05:00
Kevin Morris
f4406ccf5c Docker: Centralize repo dependencies
Now, we have `docker/scripts/install-deps.sh`, a script used
by both Docker and .gitlab-ci.yml. We can now focus on changing
deps in this script along as well as documentation going forward.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-29 21:53:18 -07:00
Kevin Morris
8abb096d7b use aurweb_test for default mysql dev database
This also updates `test/README.md` to be a bit more specific
and precise with our current state of testing.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-24 19:02:35 -07:00
Kevin Morris
e865a6347f .gitlab-ci.yml: enforce isort and flake8 compliance
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 21:31:57 -07:00
Kevin Morris
4d1faca447 test both mysql and sqlite in .gitlab-ci.yml
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:17:48 -07:00
Kevin Morris
62e58b122f fix test_accounts_routes test coverage
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:17:48 -07:00
Kevin Morris
d323c1f95b add python-lxml to dependencies
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:11:17 -07:00
Kevin Morris
19b4a896f1 add openssh to test dependencies
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:11:17 -07:00
Kevin Morris
7a6a38592e add python-email-validator dependency
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:11:17 -07:00
Kevin Morris
a33d076d8b add passreset routes
Introduced `get|post` `/passreset` routes. These routes mimic the
behavior of the existing PHP implementation, with the exception of
HTTP status code returns.

Routes added:
    GET /passreset
    POST /passreset

Routers added:
    aurweb.routers.accounts

* On an unknown user or mismatched resetkey (where resetkey must ==
  user.resetkey), return HTTP status NOT_FOUND (404).
* On another error in the request, return HTTP status BAD_REQUEST (400).

Both `get|post` routes requires that the current user is **not**
authenticated, hence `@auth_required(False, redirect="/")`.

+ Added auth_required decorator to aurweb.auth.
+ Added some more utility to aurweb.models.user.User.
+ Added `partials/error.html` template.
+ Added `passreset.html` template.
+ Added aurweb.db.ConnectionExecutor functor for paramstyle logic.
  Decoupling the executor logic from the database connection logic
  is needed for us to easily use the same logic with a fastapi
  database session, when we need to use aurweb.scripts modules.

At this point, notification configuration is now required to complete
tests involved with notifications properly, like passreset.
`conf/config.dev` has been modified to include [notifications] sendmail,
sender and reply-to overrides. Dockerfile and .gitlab-ci.yml have been
updated to setup /etc/hosts and start postfix before running tests.

* setup.cfg: ignore E741, C901 in aurweb.routers.accounts

These two warnings (shown in the commit) are not dangerous and a bi-product
of maintaining compatibility with our current code flow.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:11:17 -07:00
Kevin Morris
137c050f99 add python-bcrypt dependency
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:11:17 -07:00
Kristian Klausen
ac31f520ea Add coverage report for "Test Coverage Visualization"[1]
[1] https://docs.gitlab.com/ee/user/project/merge_requests/test_coverage_visualization.html
2021-06-05 20:11:17 -07:00
Kevin Morris
c1e29e90ca aurweb: Globalize a Translator instance, add more utility
+ Added SUPPORTED_LANGUAGES, a global constant dictionary of
  language => display pairs for languages we support.
+ Add Translator.get_translator, a function used to retrieve a
  translator after initializing it (if needed). Use `fallback=True`
  while creating languages, in case we setup a language that we
  don't have a translation for, it will noop the translation.
  This is particularly useful for "en," since we do not translate
  it, but doing this will allow us to go through our normal translation
  flow in any case.
+ Added typing.
+ Added get_request_language, a function that grabs the language for
  a request session, defaulting to aurweb.config [options] default_lang.
+ Added get_raw_translator_for_request, a function that retrieves
  the concrete translation object for a given language.
+ Added tr, a jinja2 contextfilter that can be used to inline translate
  strings in jinja2 templates.
+ Added `python-jinja` dep to .gitlab-ci.yml. This needs to be
  included in documentation before this set is merged in.
+ Introduce pytest units (test_l10n.py) in `test` along with
  __init__.py, which marks `test` as a test package.
+ Additionally, fix up notify.py to use the global translator. Also
  reduce its source width to <= 80 by newlining some code.
+ Additionally, prepare locale in .gitlab-ci.yml and add
  aurweb.config [options] localedir to config.dev with YOUR_AUR_ROOT
  like others.

Signed-off-by: Kevin Morris <kevr@0cost.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-06-05 19:49:42 -07:00
Kevin Morris
57c11ae13f install aurweb package & init db on GitLab CI
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 19:49:19 -07:00
Kevin Morris
e800cefe95 Makefile: run pytest units
Important note: Python tests will repeatedly clear out tables
that they test against; for this reason, one should always run
the shell tests first. The __init__.py file is necessary for
coverage to collect data from the tests being run.

At this point in FastAPI development, I'd like to encourage a
few things going forward:

1. Any time you contribute to the FastAPI codebase, you **must**
   maintain equal or increased coverage on the overall source.
   Developers are highly appreciated for adding tests in your
   specific domain of addition or modification that may be missing
   coverage. Our goal is 100% coverage, and all newly added files
   **must** have 100% coverage through tests.
2. All source should be formatted with the autopep8 tool and
   kept within an 80 column width, with the exception of HTML
   templates.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 19:49:19 -07:00
Kevin Morris
19652d6cbe
swap uvicorn out for hypercorn
uvicorn is subjectively nicer to play with for local dev work, but
hypercorn is required in order to do HTTP/2 which is fairly
performance-important.

Signed-off-by: Kevin Morris <kevr@0cost.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Co-authored-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2021-05-10 23:22:00 -04:00
Frédéric Mangano-Tarumi
3b347d3989 Crude OpenID Connect client using Authlib
Developers can go to /sso/login to get redirected to the SSO. On
successful login, the ID token is displayed.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:24:30 -05:00
Frédéric Mangano-Tarumi
5be07a8a9e aurweb.spawn: Integrate FastAPI and nginx
aurweb.spawn used to launch only PHP’s built-in server. Now it spawns a
dummy FastAPI application too. Since both stacks spawn their own HTTP
server, aurweb.spawn also spawns nginx as a reverse proxy to mount them
under the same base URL, defined by aur_location in the configuration.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:24:30 -05:00
Filipe Laíns
23f6dd16a7 ci: add cache to gitlab ci
Signed-off-by: Filipe Laíns <lains@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:24:30 -05:00
Filipe Laíns
db02227cc4 ci: add gitlab ci
Signed-off-by: Filipe Laíns <lains@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:24:30 -05:00