diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0eba3fc..b0a3e33f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04] - python-version: [3.8] + python-version: [3.8, 3.11, 3.12] test-target: [test, quality] steps: @@ -29,17 +29,35 @@ jobs: - name: Build Docker run: | - docker-compose -f .github/docker-compose-ci.yml up -d - docker exec ecomworker bash -c "sudo apt update -y; sudo apt install python3-dev -y;" - + docker compose -f .github/docker-compose-ci.yml up -d + docker exec ecomworker bash -c " + sudo apt-get update -y && + sudo apt-get install python${{ matrix.python-version }} \ + python${{ matrix.python-version }}-dev \ + python${{ matrix.python-version }}-distutils -y && + curl -sS https://bootstrap.pypa.io/get-pip.py | python${{ matrix.python-version }};" + # Need to install pip from source here^ otherwise some packages don't get installed + - name: Format Python Version + run: | + PYTHON_VERSION=${{ matrix.python-version }} + FORMATTED_VERSION=${PYTHON_VERSION/3./py3} + echo "PYTHON_VERSION=$FORMATTED_VERSION" >> $GITHUB_ENV + - name: Install dependencies + run: | + docker exec -t ecomworker bash -c " + cd /edx/app/ecomworker/ecomworker && + python${{ matrix.python-version }} -m pip install tox + " - name: Run Tests env: TARGETS: ${{ matrix.test-target }} run: | - docker exec ecomworker bash -c "cd /edx/app/ecomworker/ecomworker && make $TARGETS" + docker exec ecomworker bash -c " + cd /edx/app/ecomworker/ecomworker && + PYTHON_VERSION=${{ matrix.python-version }} PYTHON_ENV=$PYTHON_VERSION make $TARGETS" - name: Run Coverage - if: matrix.test-target == 'test' + if: matrix.test-target == 'test' && matrix.python-version == '3.8' run: | pip install -U codecov codecov diff --git a/Makefile b/Makefile index d865b0dc..b02207e1 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ PACKAGE = ecommerce_worker -PYTHON_VERSION = py38 +PYTHON_VERSION_VAR=$(if $(PYTHON_VERSION),$(PYTHON_VERSION),3.12) +PYTHON_ENV_VAR=$(if $(PYTHON_ENV),$(PYTHON_ENV),py312) help: ## display this help message @echo "Please use \`make ' where is one of" @@ -15,7 +16,7 @@ worker: ## start the Celery worker process celery -A ecommerce_worker worker --app=$(PACKAGE).celery_app:app --loglevel=info --queue=fulfillment,email_marketing test: requirements_tox ## run unit tests and report on coverage - tox -e ${PYTHON_VERSION} + python${PYTHON_VERSION_VAR} -m tox -e ${PYTHON_ENV_VAR} quality: requirements_tox ## run pep8 and pylint tox -e quality diff --git a/ecommerce_worker/configuration/base.py b/ecommerce_worker/configuration/base.py index eb1fa8ba..ea149559 100644 --- a/ecommerce_worker/configuration/base.py +++ b/ecommerce_worker/configuration/base.py @@ -33,9 +33,9 @@ # See http://celery.readthedocs.org/en/4.0/userguide/configuration.html#std:setting-worker_hijack_root_logger. CELERYD_HIJACK_ROOT_LOGGER = False -# Specify allowed serializers that are consistent with Celery 3 defaults -CELERY_TASK_SERIALIZER = 'pickle' -CELERY_RESULT_SERIALIZER = 'pickle' +# Sync settings with LMS/CMS +CELERY_TASK_SERIALIZER = 'json' +CELERY_RESULT_SERIALIZER = 'json' CELERY_EVENT_SERIALIZER = 'json' CELERY_ACCEPT_CONTENT = ['json', 'pickle', 'yaml'] # END CELERY diff --git a/tox.ini b/tox.ini index a073a96b..cc93af0d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{38},quality +envlist = py{38, 311, 312},quality skipsdist = true [isort]