Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
build: add python 3.11 and python 3.12 ci checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Danyal-Faheem committed May 28, 2024
1 parent 5e54f4c commit 0190f4d
Show file tree
Hide file tree
Showing 23 changed files with 1,444 additions and 535 deletions.
48 changes: 30 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,71 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- django-env: django32
testname: quality-and-jobs
targets: PYTHON_ENV=py38 requirements.js check_translations_up_to_date validate_translations clean_static static quality validate_js check_keywords
- django-env: django32
testname: test-python
targets: PYTHON_ENV=py38 requirements.js clean_static static validate_python
- django-env: django32
testname: acceptance-python
targets: PYTHON_ENV=py38 requirements.js clean_static static acceptance

python-version: ['py38', 'py311', 'py312']
django-env: ['django32']
test: ['acceptance-python', 'test-python', 'quality-and-jobs']
steps:
- uses: actions/checkout@v2
- name: Setup and Format Python Version
id: format_python_version
shell: bash
run: |
# Remove 'py' and insert a dot to format the version
FORMATTED_VERSION=${{ matrix.python-version }} # e.g., py38
FORMATTED_VERSION=${FORMATTED_VERSION/py3/3.} # becomes 3.8
# Set environment variables
echo "PYTHON_VERSION=$FORMATTED_VERSION" >> $GITHUB_ENV
- name: Start container
run: |
docker-compose -f ./.ci/docker-compose-ci.yml up -d
docker compose -f ./.ci/docker-compose-ci.yml up -d
docker exec ecommerce_testing bash -c "
sudo apt-get update -y &&
sudo apt-get install python$PYTHON_VERSION \
python$PYTHON_VERSION-dev \
python$PYTHON_VERSION-distutils \
default-libmysqlclient-dev build-essential pkg-config -y &&
curl -sS https://bootstrap.pypa.io/get-pip.py | python$PYTHON_VERSION;"
# Need to install pip from source here^ otherwise some packages don't get installed
- name: Install dependencies
run: |
docker exec -t ecommerce_testing bash -c "
cd /edx/app/ecommerce/ecommerce/ &&
python3 -m pip install tox
python$PYTHON_VERSION -m pip install tox
"
- name: Run tests
run: |
docker exec -t -e CI=1 ecommerce_testing bash -c "
cd /edx/app/ecommerce/ecommerce/ &&
PATH=\$PATH:/edx/app/ecommerce/nodeenvs/ecommerce/bin:/snap/bin
DJANGO_ENV=${{ matrix.django-env }} make ${{ matrix.targets }}
DJANGO_ENV=${{ matrix.django-env }} PYTHON_ENV=${{ matrix.python-version }} PYTHON_VERSION=$PYTHON_VERSION make ${{ matrix.test }}
"
- name: Run coverage
if: matrix.testname == 'test-python'
if: matrix.test == 'test-python'
run: |
docker exec ecommerce_testing /edx/app/ecommerce/ecommerce/.ci/run_coverage.sh
- name: Setup Python
if: matrix.testname == 'test-python'
if: matrix.test == 'test-python' && matrix.python-version == 'py38'
uses: actions/setup-python@v2
with:
python-version: "3.8"
architecture: x64
- name: Report coverage
if: matrix.testname == 'test-python'
if: matrix.test == 'test-python' && matrix.python-version == 'py38'
uses: codecov/codecov-action@v3
with:
flags: unittests
fail_ci_if_error: false

docs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.11', '3.12']
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: ${{matrix.python-version}}
architecture: x64
- name: Install Dependencies
run: pip install -r requirements/docs.txt -r requirements/tox.txt
Expand Down
51 changes: 29 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
NODE_BIN=./node_modules/.bin
DIFF_COVER_BASE_BRANCH=master
PYTHON_ENV=py38
PYTHON_ENV_VAR=$(if $(PYTHON_ENV),$(PYTHON_ENV),py312)
DJANGO_ENV_VAR=$(if $(DJANGO_ENV),$(DJANGO_ENV),django32)
PYTHON_VERSION_VAR=$(if $(PYTHON_VERSION),$(PYTHON_VERSION),3.12)

help:
@echo ''
Expand Down Expand Up @@ -45,17 +46,17 @@ requirements: requirements.js
pip3 install -r requirements/dev.txt --exists-action w

requirements.tox:
pip3 install -U pip==20.0.2
pip3 install -U pip
pip3 install -r requirements/tox.txt --exists-action w

production-requirements: requirements.js
pip3 install -r requirements.txt --exists-action w

migrate: requirements.tox
tox -e $(PYTHON_ENV)-${DJANGO_ENV_VAR}-migrate
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-${DJANGO_ENV_VAR}-migrate

serve: requirements.tox
tox -e $(PYTHON_ENV)-${DJANGO_ENV_VAR}-serve
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-${DJANGO_ENV_VAR}-serve

clean:
find . -name '*.pyc' -delete
Expand All @@ -65,18 +66,18 @@ clean_static:
rm -rf assets/* ecommerce/static/build/*

run_check_isort: requirements.tox
tox -e $(PYTHON_ENV)-check_isort
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-check_isort

run_isort: requirements.tox
tox -e $(PYTHON_ENV)-${DJANGO_ENV_VAR}-run_isort
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-${DJANGO_ENV_VAR}-run_isort

run_pycodestyle: requirements.tox
tox -e $(PYTHON_ENV)-${DJANGO_ENV_VAR}-pycodestyle
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-${DJANGO_ENV_VAR}-pycodestyle

run_pep8: run_pycodestyle

run_pylint: requirements.tox
tox -e $(PYTHON_ENV)-${DJANGO_ENV_VAR}-pylint
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-${DJANGO_ENV_VAR}-pylint

quality: run_check_isort run_pycodestyle run_pylint

Expand All @@ -86,42 +87,42 @@ validate_js:
$(NODE_BIN)/gulp lint

validate_python: clean requirements.tox
tox -e $(PYTHON_ENV)-${DJANGO_ENV_VAR}-tests
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-${DJANGO_ENV_VAR}-tests

acceptance: clean requirements.tox
tox -e $(PYTHON_ENV)-${DJANGO_ENV_VAR}-acceptance
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-${DJANGO_ENV_VAR}-acceptance

fast_validate_python: clean requirements.tox
DISABLE_ACCEPTANCE_TESTS=True tox -e $(PYTHON_ENV)-${DJANGO_ENV_VAR}-tests
DISABLE_ACCEPTANCE_TESTS=True python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-${DJANGO_ENV_VAR}-tests

validate: validate_python validate_js quality

theme_static: requirements.tox
tox -e $(PYTHON_ENV)-${DJANGO_ENV_VAR}-theme_static
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-${DJANGO_ENV_VAR}-theme_static

static: requirements.js theme_static requirements.tox
$(NODE_BIN)/r.js -o build.js
tox -e $(PYTHON_ENV)-${DJANGO_ENV_VAR}-static
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-${DJANGO_ENV_VAR}-static

html_coverage: requirements.tox
tox -e $(PYTHON_ENV)-coverage_html
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-coverage_html

diff_coverage: validate fast_diff_coverage

fast_diff_coverage: requirements.tox
tox -e $(PYTHON_ENV)-fast_diff_coverage
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-fast_diff_coverage

e2e: requirements.tox
tox -e $(PYTHON_ENV)-e2e
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-e2e

extract_translations: requirements.tox
tox -e $(PYTHON_ENV)-${DJANGO_ENV_VAR}-extract_translations
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-${DJANGO_ENV_VAR}-extract_translations

dummy_translations: requirements.tox
tox -e $(PYTHON_ENV)-${DJANGO_ENV_VAR}-dummy_translations
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-${DJANGO_ENV_VAR}-dummy_translations

compile_translations: requirements.tox
tox -e $(PYTHON_ENV)-${DJANGO_ENV_VAR}-compile_translations
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-${DJANGO_ENV_VAR}-compile_translations

fake_translations: extract_translations dummy_translations compile_translations

Expand All @@ -134,18 +135,18 @@ update_translations: pull_translations fake_translations

# extract_translations should be called before this command can detect changes
detect_changed_source_translations: requirements.tox
tox -e $(PYTHON_ENV)-${DJANGO_ENV_VAR}-detect_changed_translations
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-${DJANGO_ENV_VAR}-detect_changed_translations

# @FIXME: skip detect_changed_source_translations until git diff works again (REV-2737)
check_translations_up_to_date: fake_translations # detect_changed_source_translations

# Validate translations
validate_translations: requirements.tox
tox -e $(PYTHON_ENV)-${DJANGO_ENV_VAR}-validate_translations
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-${DJANGO_ENV_VAR}-validate_translations

# Scan the Django models in all installed apps in this project for restricted field names
check_keywords: requirements.tox
tox -e $(PYTHON_ENV)-${DJANGO_ENV_VAR}-check_keywords
python$(PYTHON_VERSION_VAR) -m tox -e $(PYTHON_ENV_VAR)-${DJANGO_ENV_VAR}-check_keywords

COMMON_CONSTRAINTS_TXT=requirements/common_constraints.txt
.PHONY: $(COMMON_CONSTRAINTS_TXT)
Expand Down Expand Up @@ -173,6 +174,12 @@ upgrade: $(COMMON_CONSTRAINTS_TXT)
docs:
tox -e docs

quality-and-jobs: requirements.js check_translations_up_to_date validate_translations clean_static static quality validate_js check_keywords

test-python: requirements.js clean_static static validate_python

acceptance-python: requirements.js clean_static static acceptance

# Targets in a Makefile which do not produce an output file with the same name as the target name
.PHONY: help requirements migrate serve clean validate_python quality validate_js validate html_coverage e2e \
extract_translations dummy_translations compile_translations fake_translations pull_translations \
Expand Down
18 changes: 18 additions & 0 deletions ecommerce/extensions/basket/migrations/0018_line_tax_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.25 on 2024-05-28 07:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('basket', '0017_alter_lineattribute_value'),
]

operations = [
migrations.AddField(
model_name='line',
name='tax_code',
field=models.CharField(blank=True, max_length=64, null=True, verbose_name='VAT rate code'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 3.2.25 on 2024-05-28 07:54

from django.db import migrations
import oscar.models.fields


class Migration(migrations.Migration):

dependencies = [
('catalogue', '0057_auto_20231205_1034'),
]

operations = [
migrations.AddField(
model_name='attributeoption',
name='code',
field=oscar.models.fields.NullCharField(max_length=255, unique=True, verbose_name='Unique identifier'),
),
migrations.AddField(
model_name='attributeoptiongroup',
name='code',
field=oscar.models.fields.NullCharField(max_length=255, unique=True, verbose_name='Unique identifier'),
),
migrations.AddField(
model_name='category',
name='code',
field=oscar.models.fields.NullCharField(max_length=255, unique=True, verbose_name='Code'),
),
migrations.AddField(
model_name='historicalcategory',
name='code',
field=oscar.models.fields.NullCharField(db_index=True, max_length=255, verbose_name='Code'),
),
migrations.AddField(
model_name='productimage',
name='code',
field=oscar.models.fields.NullCharField(max_length=255, unique=True, verbose_name='Code'),
),
]
51 changes: 51 additions & 0 deletions ecommerce/extensions/offer/migrations/0056_auto_20240528_0754.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Generated by Django 3.2.25 on 2024-05-28 07:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('offer', '0055_auto_20231108_1355'),
]

operations = [
migrations.CreateModel(
name='FixedUnitDiscountBenefit',
fields=[
],
options={
'verbose_name': 'Fixed unit discount benefit',
'verbose_name_plural': 'Fixed unit discount benefits',
'proxy': True,
'indexes': [],
'constraints': [],
},
bases=('offer.absolutediscountbenefit',),
),
migrations.AddField(
model_name='rangeproductfileupload',
name='upload_type',
field=models.CharField(choices=[('included', 'Included products upload'), ('excluded', 'Excluded products upload')], default='included', max_length=8),
),
migrations.AlterField(
model_name='benefit',
name='type',
field=models.CharField(blank=True, choices=[('Percentage', "Discount is a percentage off of the product's value"), ('Absolute', "Discount is a fixed amount off of the basket's total"), ('Fixed', "Discount is a fixed amount off of the product's value"), ('Multibuy', 'Discount is to give the cheapest product for free'), ('Fixed price', 'Get the products that meet the condition for a fixed price'), ('Shipping absolute', 'Discount is a fixed amount of the shipping cost'), ('Shipping fixed price', 'Get shipping for a fixed price'), ('Shipping percentage', 'Discount is a percentage off of the shipping cost')], max_length=128, verbose_name='Type'),
),
migrations.AlterField(
model_name='historicalbenefit',
name='type',
field=models.CharField(blank=True, choices=[('Percentage', "Discount is a percentage off of the product's value"), ('Absolute', "Discount is a fixed amount off of the basket's total"), ('Fixed', "Discount is a fixed amount off of the product's value"), ('Multibuy', 'Discount is to give the cheapest product for free'), ('Fixed price', 'Get the products that meet the condition for a fixed price'), ('Shipping absolute', 'Discount is a fixed amount of the shipping cost'), ('Shipping fixed price', 'Get shipping for a fixed price'), ('Shipping percentage', 'Discount is a percentage off of the shipping cost')], max_length=128, verbose_name='Type'),
),
migrations.AlterField(
model_name='historicalrange',
name='description',
field=models.TextField(blank=True, verbose_name='Description'),
),
migrations.AlterField(
model_name='range',
name='description',
field=models.TextField(blank=True, verbose_name='Description'),
),
]
Loading

0 comments on commit 0190f4d

Please sign in to comment.