diff --git a/.github/workflows/test_on_push.yaml b/.github/workflows/test_on_push.yaml index 6d313b0b..0f5975e7 100644 --- a/.github/workflows/test_on_push.yaml +++ b/.github/workflows/test_on_push.yaml @@ -1,4 +1,4 @@ -name: 'Test' +name: "Test" on: push: @@ -9,7 +9,7 @@ on: jobs: api-tests: name: "jobbergate-api tests" - runs-on: "ubuntu-latest" + runs-on: "ubuntu-20.04" services: test-db: image: postgres @@ -25,14 +25,15 @@ jobs: ports: - 5433:5432 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: '3.8' - architecture: 'x64' - - uses: Gr1N/setup-poetry@v7 + - uses: actions/checkout@v3 + - name: Install poetry + run: pipx install poetry==1.1.14 + - uses: actions/setup-python@v4 with: - poetry-version: 1.1.14 + python-version: "3.8" + architecture: "x64" + cache: "poetry" + cache-dependency-path: jobbergate-api/poetry.lock - name: "run quality control checks" working-directory: jobbergate-api env: @@ -41,25 +42,25 @@ jobs: TEST_DATABASE_USER: test TEST_DATABASE_PSWD: test-pswd TEST_DATABASE_NAME: test-jobbergate - POETRY_HTTP_BASIC_PYPICLOUD_USERNAME: admin - POETRY_HTTP_BASIC_PYPICLOUD_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: make qa + run: | + poetry env use "3.8" + make qa cli-tests: name: "jobbergate-cli tests" runs-on: "ubuntu-20.04" steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v3 + - name: Install poetry + run: pipx install poetry==1.1.14 + - uses: actions/setup-python@v4 with: python-version: "3.6" - architecture: 'x64' - - uses: Gr1N/setup-poetry@v7 - with: - poetry-version: 1.1.14 + architecture: "x64" + cache: "poetry" + cache-dependency-path: jobbergate-cli/poetry.lock - name: "run quality control checks" working-directory: jobbergate-cli - env: - POETRY_HTTP_BASIC_PYPICLOUD_USERNAME: admin - POETRY_HTTP_BASIC_PYPICLOUD_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: make qa + run: | + poetry env use "3.6" + make qa diff --git a/jobbergate-api/jobbergate_api/tests/apps/applications/test_routers.py b/jobbergate-api/jobbergate_api/tests/apps/applications/test_routers.py index b8101cf4..1d42b6df 100644 --- a/jobbergate-api/jobbergate_api/tests/apps/applications/test_routers.py +++ b/jobbergate-api/jobbergate_api/tests/apps/applications/test_routers.py @@ -14,6 +14,10 @@ from jobbergate_api.apps.permissions import Permissions from jobbergate_api.storage import database, fetch_instance +# Force the async event loop at the app to begin. +# Since this is a time consuming fixture, it is just used where strict necessary. +pytestmark = pytest.mark.usefixtures("startup_event_force") + @pytest.mark.asyncio async def test_create_application( diff --git a/jobbergate-api/jobbergate_api/tests/apps/job_scripts/test_routers.py b/jobbergate-api/jobbergate_api/tests/apps/job_scripts/test_routers.py index 0578e3bd..9f7afdd2 100644 --- a/jobbergate-api/jobbergate_api/tests/apps/job_scripts/test_routers.py +++ b/jobbergate-api/jobbergate_api/tests/apps/job_scripts/test_routers.py @@ -18,6 +18,10 @@ from jobbergate_api.apps.permissions import Permissions from jobbergate_api.storage import database +# Force the async event loop at the app to begin. +# Since this is a time consuming fixture, it is just used where strict necessary. +pytestmark = pytest.mark.usefixtures("startup_event_force") + @pytest.fixture def job_script_data_as_string(): diff --git a/jobbergate-api/jobbergate_api/tests/apps/job_submissions/test_routers.py b/jobbergate-api/jobbergate_api/tests/apps/job_submissions/test_routers.py index 41edc746..986914b2 100644 --- a/jobbergate-api/jobbergate_api/tests/apps/job_submissions/test_routers.py +++ b/jobbergate-api/jobbergate_api/tests/apps/job_submissions/test_routers.py @@ -16,6 +16,10 @@ from jobbergate_api.apps.permissions import Permissions from jobbergate_api.storage import database +# Force the async event loop at the app to begin. +# Since this is a time consuming fixture, it is just used where strict necessary. +pytestmark = pytest.mark.usefixtures("startup_event_force") + @pytest.mark.asyncio async def test_create_job_submission__with_client_id_in_token( diff --git a/jobbergate-api/jobbergate_api/tests/conftest.py b/jobbergate-api/jobbergate_api/tests/conftest.py index 5d2f9970..e9aca115 100644 --- a/jobbergate-api/jobbergate_api/tests/conftest.py +++ b/jobbergate-api/jobbergate_api/tests/conftest.py @@ -56,8 +56,7 @@ async def enforce_empty_database(database_engine): metadata.drop_all(database_engine) -@pytest.fixture(autouse=True) -@pytest.mark.enforce_empty_database() +@pytest.fixture() async def startup_event_force(): """ Force the async event loop to begin. diff --git a/jobbergate-api/jobbergate_api/tests/test_pagination.py b/jobbergate-api/jobbergate_api/tests/test_pagination.py index 8b24d7ff..e649b899 100644 --- a/jobbergate-api/jobbergate_api/tests/test_pagination.py +++ b/jobbergate-api/jobbergate_api/tests/test_pagination.py @@ -12,6 +12,10 @@ from jobbergate_api.pagination import Pagination, Response, package_response from jobbergate_api.storage import database +# Force the async event loop at the app to begin. +# Since this is a time consuming fixture, it is just used where strict necessary. +pytestmark = pytest.mark.usefixtures("startup_event_force") + def test_init_fails_on_invalid_parameters(): """ diff --git a/jobbergate-api/jobbergate_api/tests/test_storage.py b/jobbergate-api/jobbergate_api/tests/test_storage.py index 7c6d0ce5..69f871c9 100644 --- a/jobbergate-api/jobbergate_api/tests/test_storage.py +++ b/jobbergate-api/jobbergate_api/tests/test_storage.py @@ -10,6 +10,10 @@ from jobbergate_api.metadata import metadata from jobbergate_api.storage import build_db_url, database, sort_clause +# Force the async event loop at the app to begin. +# Since this is a time consuming fixture, it is just used where strict necessary. +pytestmark = pytest.mark.usefixtures("startup_event_force") + def test_build_db_url__creates_database_url_from_parts(tweak_settings): """