Skip to content

Commit

Permalink
update test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
liptakpanna committed Sep 11, 2024
1 parent 2dab243 commit 3d1b33d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 59 deletions.
80 changes: 31 additions & 49 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2020 CERN.
# Copyright (C) 2022 Graz University of Technology.
# Copyright (C) 2024 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -19,41 +18,31 @@ on:
- cron: '0 3 * * 6'
workflow_dispatch:
inputs:
reason:
description: 'Reason'
required: false
default: 'Manual trigger'
python-version:
description: "Python versions"
type: string
# NOTE: There is no "array" type, so we use "string" and parse it in the matrix
default: '["3.9", "3.12"]'
db-service:
description: "DB service"
type: string
default: '[postgresql11, postgresql14, mysql8, sqlite]'
search-service:
description: "Search service"
type: string
default: '["opensearch2"]'

jobs:
Tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9]
requirements-level: [pypi]
db-service: [postgresql11, postgresql14, mysql8, sqlite]
exclude:
- python-version: 3.7
db-service: postgresql14
requirements-level: pypi
python-version: ${{ fromJson(inputs.python-version) }}
db-service: ${{ fromJson(inputs.db-service) }}
search-service: ${{ fromJson(inputs.search-service) }}

- python-version: 3.7
db-service: mysql8
requirements-level: pypi

- python-version: 3.8
db-service: postgresql11

- python-version: 3.9
db-service: postgresql11

- python-version: 3.7
db-service: sqlite

- python-version: 3.8
db-service: sqlite

include:
include:
- db-service: postgresql11
EXTRAS: "tests,postgresql"

Expand All @@ -68,35 +57,28 @@ jobs:

env:
DB: ${{ matrix.db-service }}
EXTRAS: ${{ matrix.EXTRAS }}
SEARCH: ${{ matrix.search-service }}

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: setup.cfg

- name: Generate dependencies
run: |
pip install wheel requirements-builder
requirements-builder -e "$EXTRAS" --level=${{ matrix.requirements-level }} setup.py > .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('.${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt') }}
- name: Pre-install
uses: ./.github/actions/pre-install
if: ${{ hashFiles('.github/actions/pre-install/action.yml') != '' }}

- name: Install dependencies
run: |
pip install -r .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt -c constraints-${{ matrix.requirements-level }}.txt
pip install ".[$EXTRAS]"
pip freeze
docker --version
docker-compose --version
docker version
- name: Run tests
run: |
./run-tests.sh
run: ./run-tests.sh
10 changes: 0 additions & 10 deletions invenio_db/services/uow.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ def create(self, ... , uow=None):
# ...
# Do not use `db.session.commit()` in service.
Any private method that need to run operations after the database transaction
commit should take the unit of work as input:
.. code-block:: python
def _send_a_task(uow, ...):
# Run a celery task after the database transaction commit.
uow.register(TaskOp(my_celery_task, myarg, ... ))
**When not to use?**
If you're not changing the database state there's no need to use the unit of
Expand Down

0 comments on commit 3d1b33d

Please sign in to comment.