From 33392593468cacfea1d0a72fa4d188ca39faacf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Fri, 5 Nov 2021 21:26:55 +0100 Subject: [PATCH] Setup env vars for tests --- .env.test | 13 +++++++++++++ .github/workflows/ci.yml | 4 ++-- README.md | 4 +++- pyproject.toml | 7 ++++--- requirements-test.txt | 14 ++++++++++++++ 5 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 .env.test create mode 100644 requirements-test.txt diff --git a/.env.test b/.env.test new file mode 100644 index 0000000..ad24921 --- /dev/null +++ b/.env.test @@ -0,0 +1,13 @@ +RUNBOAT_SUPPORTED_REPOS=["OCA/mis-builder", "shopinvader/odoo-shopinvader", "OCA/server-env"] +RUNBOAT_API_ADMIN_USER="admin" +RUNBOAT_API_ADMIN_PASSWD="admin" +RUNBOAT_BUILD_NAMESPACE=runboat-builds +RUNBOAT_BUILD_PGHOST=postgres14.runboat-builds-db +RUNBOAT_BUILD_PGPORT=5432 +RUNBOAT_BUILD_PGUSER=runboat-build +RUNBOAT_BUILD_PGPASSWORD=... +RUNBOAT_BUILD_ADMIN_PASSWD=... +RUNBOAT_BUILD_DOMAIN=runboat.odoo-community.org +RUNBOAT_BUILD_ENV={} +RUNBOAT_GITHUB_TOKEN= +RUNBOAT_LOG_CONFIG=log-config.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3cdc938..b564379 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,8 +22,8 @@ jobs: - name: Install project run: | pip install -U "pip>=21.3.1" - pip install -e .[test] -c requirements.txt + pip install -e .[test] -c requirements.txt -c requirements-test.txt - name: Run tests run: | - pytest -v --cov --cov-report=xml + pytest -v --cov --cov-report=xml ./tests - uses: codecov/codecov-action@v1 diff --git a/README.md b/README.md index 29692fc..3ab3e56 100644 --- a/README.md +++ b/README.md @@ -68,8 +68,10 @@ in a different cluster. - setup environment variables (start from `.env.sample`) - create a virtualenv, make sure to have pip>=21.3.1 and `pip install -c - requirements.txt -e .` + requirements.txt -e .[test]` - run with `uvicorn runboat.app:app --log-config=log-config.yaml` +- run tests with `pytest` (environment variables used in tests are declared in + `.env.test`) ## Running in production diff --git a/pyproject.toml b/pyproject.toml index d2ed388..1bdf869 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,9 +24,7 @@ dynamic = ["version", "description"] test = [ "pytest", "pytest-cov", -] -mypy = [ - "mypy", + "pytest-dotenv", ] [project.urls] @@ -35,4 +33,7 @@ Home = "https://github.com/sbidoul/runboat" [tool.isort] profile = 'black' +[tool.pytest.ini_options] +env_files = [".env.test"] + # flake8 config is in .flake8 diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 0000000..cbfc30f --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,14 @@ +# frozen requirements generated by pip-deepfreeze +attrs==21.2.0 +coverage==6.1.1 +iniconfig==1.1.1 +packaging==21.2 +pluggy==1.0.0 +py==1.11.0 +pyparsing==2.4.7 +pytest==6.2.5 +pytest-cov==3.0.0 +pytest-dotenv==0.5.2 +python-dotenv==0.19.1 +toml==0.10.2 +tomli==1.2.2