Commit graph

8 commits

Author SHA1 Message Date
moson
122df968dc
feat: Switch to postgres
Migrate from MariaDB to PostgreSQL.

Signed-off-by: moson <moson@archlinux.org>
2024-12-10 16:13:12 +01:00
Kevin Morris
a2d08e441e
fix(docker): run pre-commit run -a once
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-09-11 17:59:45 -07:00
Leonidas Spyropoulos
310c469ba8
fix: run pre-commit checks instead of flake8 and isort
Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
2022-09-06 08:07:05 +01:00
Kevin Morris
7f1de72e08
fix(docker): remove logging setup in run-tests.sh
This was left in when we removed logging.prod.conf in a
previous patch. `test-mysql-entrypoint.sh` takes care of
test logging for us now, so this section is unnecessary.

Closes #261

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-18 05:22:00 -08:00
Kevin Morris
7831503c19
fix(docker): use logging.prod.conf for sharness
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-07 15:09:20 -08:00
Kevin Morris
d4d9f50b8f
change(docker): use ./data instead of ./cache
For the `git` service, ./data is always used to provide an
optional overriding of ssh host keys. In aur-dev production
containers, most services which use the data mount use an
internal Docker `data` volume instead.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-20 20:05:32 -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
5bd46d18a3 Improve Docker ecosystem
Instead of using Dockerfile for everything, we've introduced
a docker-compose.yml file and kept the Dockerfile to producing
a pure base image for the services defined.

docker-compose services:

- `mariadb` - Setup mariadb
- `sharness` - Run sharness suites
- `pytest-mysql` - Run pytest suites with MariaDB
- `pytest-sqlite` - Run pytest suites with SQLite
- `test` - Run all tests and produce a collective coverage report
    - This target mounts a cache volume and copies any successful
      coverage report back to `./cache/.coverage`. Users can run
      `./util/fix-coverage ./cache/.coverage` to rewrite source
      code paths and move coverage into place to view reports
      on your local system.

== Get Started ==

Build `aurweb:latest`.

    $ docker build -t aurweb:latest .

Run all tests via `docker-compose`.

    $ docker-compose up test

You can also purely run `pytest` in SQLite or MariaDB modes.

    $ docker-compose up pytest-sqlite
    $ docker-compose up pytest-mysql

Or `sharness` alone, which only uses SQLite internally.

    $ docker-compose up sharness

After running tests, coverage reports are stored in `./cache/.coverage`.
This database was most likely created in a different path, and so it
needs to be sanitized with `./util/fix-coverage`.

    $ ./util/fix-coverage cache/.coverage
    Copied coverage db to /path/to/aurweb/.coverage.
    $ coverage report
    ...
    $ coverage html
    $ coverage xml
    ...

Defined components:

**Entrypoints**

- mariadb-entrypoint.sh - setup mariadb and run its daemon
- test-mysql-entrypoint.sh - setup mysql configurations
- test-sqlite-entrypoint.sh - setup sqlite configurations
- tests-entrypoint.sh - setup mysql and sqlite configurations

**Scripts**

- run-mariadb.sh - setup databases
- run-pytests.sh - run pytest suites
- run-sharness.sh - run sharness suites
- run-tests.sh - run both pytests and sharness

**Health**

- mariadb.sh - A healthcheck script for the mariadb service
- pytest.sh - A healthcheck script for the pytest-* services
- sharness.sh - A healthcheck script for the sharness service

This Docker configuration is setup for tests, but should be
extendable for web and git servers.

**Changes to Makefile**

- Remove `.coverage` in the `clean` target
- Add a `coverage` target which prints a report and outputs xml

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-24 19:02:35 -07:00