Skip to content

Commit

Permalink
refactor: remove bok-choy and replace xblockutils with `xblock.ut…
Browse files Browse the repository at this point in the history
…ils`
  • Loading branch information
farhan authored Oct 24, 2023
1 parent 9fde65e commit fc54d87
Show file tree
Hide file tree
Showing 45 changed files with 51 additions and 4,670 deletions.
17 changes: 1 addition & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,12 @@ concurrency:
jobs:
tests:
runs-on: ${{ matrix.os }}
services:
# Using SQLite3 for integration tests throws `django.db.utils.OperationalError: database table is locked: workbench_xblockstate`.
mysql:
image: mysql:8
env:
MYSQL_ROOT_PASSWORD: rootpw
ports:
- 3307:3306
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
python-version: [3.8]
toxenv: [py38-django32, py38-django42, integration-django32, integration-django42, quality, translations-django32, translations-django42]
toxenv: [py38-django32, py38-django42, quality, translations-django32, translations-django42]

steps:
- name: checkout repo
Expand All @@ -41,13 +33,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

# `libgtk2.0-0` and `libxt6` are required by an older version of Firefox.
- name: Install Required System Packages
if: ${{ startsWith(matrix.toxenv, 'integration') }}
run: |
sudo apt-get update
sudo apt-get install -y libxmlsec1-dev ubuntu-restricted-extras xvfb libxml2-dev libxslt-dev libevent-dev libgtk2.0-0 libxt6
- name: Install translations dependencies
if: ${{ startsWith(matrix.toxenv, 'translations') }}
run: |
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ coverage.xml
# Translations
*.pot

# Integration test output:
# test output:
/*.log
/tests.*.png
var/*
Expand All @@ -58,5 +58,3 @@ target/
# IDEs
.idea
.idea/*

test_helpers/
8 changes: 8 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ Drag and Drop XBlock changelog
Unreleased
---------------------------

Version 3.3.0 (2023-10-24)
---------------------------

* Removed xblock-utils package
* Replace `xblockutils.*` imports with `xblock.utils.*`. The old imports are used as a fallback for compatibility with older releases.
* Removed bok-choy package along with all integration tests.


Version 3.2.2 (2023-10-19)
---------------------------

Expand Down
29 changes: 6 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: clean help compile_translations dummy_translations extract_translations detect_changed_source_translations \
build_dummy_translations validate_translations pull_translations push_translations check_translations_up_to_date \
install_firefox requirements selfcheck test test.python test.unit test.quality upgrade mysql
requirements selfcheck test test.python test.unit test.quality upgrade

.DEFAULT_GOAL := help

Expand All @@ -11,8 +11,6 @@ EXTRACTED_DJANGO_PARTIAL := $(EXTRACT_DIR)/django-partial.po
EXTRACTED_DJANGOJS_PARTIAL := $(EXTRACT_DIR)/djangojs-partial.po
EXTRACTED_DJANGO := $(EXTRACT_DIR)/django.po

FIREFOX_VERSION := "43.0"

help: ## display this help message
@echo "Please use \`make <target>' where <target> is one of"
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'
Expand Down Expand Up @@ -62,36 +60,26 @@ push_translations: ## push translations to transifex

check_translations_up_to_date: extract_translations compile_translations dummy_translations detect_changed_source_translations ## extract, compile, and check if translation files are up-to-date

install_firefox:
@mkdir -p test_helpers
@test -f ./test_helpers/firefox/firefox && echo "Firefox already installed." || \
(cd test_helpers && \
wget -N "https://archive.mozilla.org/pub/firefox/releases/$(FIREFOX_VERSION)/linux-x86_64/en-US/firefox-$(FIREFOX_VERSION).tar.bz2" && \
tar -xjf firefox-$(FIREFOX_VERSION).tar.bz2)

piptools: ## install pinned version of pip-compile and pip-sync
pip install -r requirements/pip.txt
pip install -r requirements/pip-tools.txt

requirements: piptools ## install test requirements locally
pip-sync requirements/ci.txt

requirements_python: install_firefox piptools ## install all requirements locally
requirements_python: piptools ## install all requirements locally
pip-sync requirements/dev.txt requirements/private.*

test.quality: selfcheck ## run quality checkers on the codebase
tox -e quality

test.python: ## run python unit and integration tests
PATH=test_helpers/firefox:$$PATH xvfb-run python run_tests.py $(TEST)
test.python: ## run python unit tests in the local virtualenv
pytest --cov drag_and_drop_v2 $(TEST)

test.unit: ## run all unit tests
tox -- $(TEST)
tox $(TEST)

test.integration: ## run all integration tests
tox -e integration -- $(TEST)

test: test.unit test.integration test.quality ## Run all tests
test: test.unit test.quality ## Run all tests
tox -e translations

# Define PIP_COMPILE_OPTS=-v to get more information during make upgrade.
Expand All @@ -108,14 +96,9 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisfy
$(PIP_COMPILE) -o requirements/base.txt requirements/base.in
$(PIP_COMPILE) -o requirements/test.txt requirements/test.in
$(PIP_COMPILE) -o requirements/quality.txt requirements/quality.in
$(PIP_COMPILE) -o requirements/workbench.txt requirements/workbench.in
$(PIP_COMPILE) -o requirements/ci.txt requirements/ci.in
$(PIP_COMPILE) -o requirements/dev.txt requirements/dev.in
sed -i '/^[dD]jango==/d' requirements/test.txt
sed -i '/^[dD]jango==/d' requirements/workbench.txt

mysql: ## run mysql database for integration tests
docker run --rm -it --name mysql -p 3307:3306 -e MYSQL_ROOT_PASSWORD=rootpw -e MYSQL_DATABASE=db mysql:8

selfcheck: ## check that the Makefile is well-formed
@echo "The Makefile is well-formed."
13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,6 @@ Inside a fresh virtualenv, `cd` into the root folder of this repository
$ make requirements
```

To run integration tests, you need to start MySQL first:
```bash
$ make mysql
```

You can then run the entire test suite via:

Expand All @@ -480,7 +476,6 @@ To run specific test groups, use one of the following commands:

```bash
$ make test.unit
$ make test.integration
$ make test.quality
$ make test.translations
```
Expand All @@ -490,21 +485,15 @@ To run individual unit tests, use:
```bash
$ make test.unit TEST=tests/unit/test_basics.py::BasicTests::test_student_view_data
```
To run individual integration tests, use:

```bash
$ make test.integration TEST=tests.integration.test_studio.TestStudio.test_custom_image
```

Manual testing (without tox)
----------------------------

To run tests without tox, use:

```bash
$ make mysql
$ make requirements_python
$ make test.python TEST=tests.unit.test_basics.BasicTests.test_student_view_data
$ make test.python TEST=tests/unit/test_basics.py::BasicTests::test_student_view_data
```


Expand Down
2 changes: 1 addition & 1 deletion drag_and_drop_v2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Drag and Drop v2 XBlock """
from .drag_and_drop_v2 import DragAndDropBlock

__version__ = "3.2.2"
__version__ = "3.3.0"
8 changes: 6 additions & 2 deletions drag_and_drop_v2/drag_and_drop_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@
from xblock.exceptions import JsonHandlerError
from xblock.fields import Boolean, Dict, Float, Integer, Scope, String
from xblock.scorable import ScorableXBlockMixin, Score
try:
from xblock.utils.resources import ResourceLoader
from xblock.utils.settings import ThemableXBlockMixin, XBlockWithSettingsMixin
except ModuleNotFoundError: # For backward compatibility with releases older than Quince.
from xblockutils.resources import ResourceLoader
from xblockutils.settings import ThemableXBlockMixin, XBlockWithSettingsMixin
from web_fragments.fragment import Fragment
from xblockutils.resources import ResourceLoader
from xblockutils.settings import ThemableXBlockMixin, XBlockWithSettingsMixin

from .compat import get_grading_ignore_decoys_waffle_flag
from .default_data import DEFAULT_DATA
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

django-statici18n
bleach[css]
xblock-utils
XBlock[django]
18 changes: 5 additions & 13 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ asgiref==3.7.2
# via django
bleach[css]==6.1.0
# via -r requirements/base.in
boto3==1.28.68
boto3==1.28.69
# via fs-s3fs
botocore==1.31.68
botocore==1.31.69
# via
# boto3
# s3transfer
Expand Down Expand Up @@ -42,9 +42,7 @@ lazy==1.6
lxml==4.9.3
# via xblock
mako==1.2.4
# via
# xblock
# xblock-utils
# via xblock
markupsafe==2.1.3
# via
# mako
Expand All @@ -64,9 +62,7 @@ pyyaml==6.0.1
s3transfer==0.7.0
# via boto3
simplejson==3.19.2
# via
# xblock
# xblock-utils
# via xblock
six==1.16.0
# via
# bleach
Expand All @@ -82,18 +78,14 @@ typing-extensions==4.8.0
urllib3==1.26.18
# via botocore
web-fragments==2.1.0
# via
# xblock
# xblock-utils
# via xblock
webencodings==0.5.1
# via
# bleach
# tinycss2
webob==1.8.7
# via xblock
xblock[django]==1.8.1
# via xblock-utils
xblock-utils==4.0.0
# via -r requirements/base.in

# The following packages are considered to be unsafe in a requirements file:
Expand Down
2 changes: 1 addition & 1 deletion requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ tox==3.28.0
# tox-battery
tox-battery==0.6.2
# via -r requirements/ci.in
virtualenv==20.24.5
virtualenv==20.24.6
# via tox
1 change: 0 additions & 1 deletion requirements/dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
-r pip-tools.txt # pip-tools and its dependencies, for managing requirements files
-r quality.txt # Core and quality check dependencies
-r ci.txt # dependencies for setting up testing in CI
-r workbench.txt # workbench dependencies
Loading

0 comments on commit fc54d87

Please sign in to comment.