Skip to content

Commit e6efffc

Browse files
authored
Merge pull request #310 from open-craft/agrendalath/maintainership_pilot_2
build: update CI workflows and add pip-tools
2 parents deec906 + 66e8d35 commit e6efffc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2477
-657
lines changed

.github/pull_request_template.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!--
2+
Please give your pull request a short but descriptive title.
3+
Use conventional commits to separate and summarize commits logically:
4+
https://open-edx-proposals.readthedocs.io/en/latest/oep-0051-bp-conventional-commits.html
5+
6+
Use this template as a guide. Omit sections that don't apply.
7+
You may link to information rather than copy it, but only if the link is publicly
8+
readable. If your linked information must be private (because it has secrets),
9+
clearly label the link as private.
10+
-->
11+
12+
## Description
13+
14+
Describe what this pull request changes, and why. Include implications for people using this change.
15+
Design decisions and their rationales should be documented in the repo (docstring / ADR), per
16+
[OEP-19](https://open-edx-proposals.readthedocs.io/en/latest/oep-0019-bp-developer-documentation.html), and can be
17+
linked here.
18+
19+
Useful information to include:
20+
- Which edX user roles will this change impact? Common user roles are "Learner", "Course Author",
21+
"Developer", and "Operator".
22+
- Include screenshots for changes to the UI (ideally, both "before" and "after" screenshots, if applicable).
23+
- Provide links to the description of corresponding configuration changes. Remember to correctly annotate these
24+
changes.
25+
26+
## Supporting information
27+
28+
Link to other information about the change, such as Jira issues, GitHub issues, or Discourse discussions.
29+
Be sure to check they are publicly readable, or if not, repeat the information here.
30+
31+
## Testing instructions
32+
33+
Please provide detailed step-by-step instructions for testing this change.
34+
35+
## Deadline
36+
37+
"None" if there's no rush, or provide a specific date or event (and reason) if there is one.
38+
39+
## Other information
40+
41+
Include anything else that will help reviewers and consumers understand the change.
42+
- Does this change depend on other changes elsewhere?
43+
- Any special concerns or limitations? For example: deprecations, migrations, security, or accessibility.
44+
- If your [database migration](https://openedx.atlassian.net/wiki/spaces/AC/pages/23003228/Everything+About+Database+Migrations) can't be rolled back easily.

.github/workflows/ci.yml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,29 @@ on:
66
pull_request:
77
branches:
88
- '**'
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: "${{ github.workflow }}-${{ github.ref }}"
13+
cancel-in-progress: true
914

1015
jobs:
1116
tests:
1217
runs-on: ${{ matrix.os }}
18+
services:
19+
# Using SQLite3 for integration tests throws `django.db.utils.OperationalError: database table is locked: workbench_xblockstate`.
20+
mysql:
21+
image: mysql:8
22+
env:
23+
MYSQL_ROOT_PASSWORD: rootpw
24+
ports:
25+
- 3307:3306
1326
strategy:
27+
fail-fast: false
1428
matrix:
1529
os: [ubuntu-20.04]
1630
python-version: [3.8]
31+
toxenv: [py38, integration, quality, translations]
1732

1833
steps:
1934
- name: checkout repo
@@ -28,18 +43,21 @@ jobs:
2843

2944
# `libgtk2.0-0` and `libxt6` are required by an older version of Firefox.
3045
- name: Install Required System Packages
46+
if: matrix.toxenv == 'integration'
47+
run: |
48+
sudo apt-get update
49+
sudo apt-get install -y libxmlsec1-dev ubuntu-restricted-extras xvfb libxml2-dev libxslt-dev libevent-dev libgtk2.0-0 libxt6
50+
51+
- name: Install translations dependencies
52+
if: matrix.toxenv == 'translations'
3153
run: |
3254
sudo apt-get update
33-
sudo apt-get install -y libxmlsec1-dev ubuntu-restricted-extras xvfb libxml2-dev libxslt-dev python3-dev libevent-dev python3-pip python3-venv gettext libgtk2.0-0 libxt6
55+
sudo apt-get install -y gettext
3456
3557
- name: Install Dependencies
3658
run: make requirements
3759

38-
- name: Check if translations are up-to-date
39-
run: make check_translations_up_to_date
40-
41-
- name: Run quality checks
42-
run: make test.quality
43-
44-
- name: Run unit tests
45-
run: make test.unit
60+
- name: Run Tests
61+
env:
62+
TOXENV: ${{ matrix.toxenv }}
63+
run: tox

.github/workflows/pypi-publish.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
1-
name: pypi-publish
1+
name: Publish package to PyPI
22

33
on:
44
release:
55
types: [published]
66

77
jobs:
8-
publish-package:
8+
push:
99
runs-on: ubuntu-20.04
1010

1111
steps:
1212
- name: Checkout
1313
uses: actions/checkout@v3
1414

1515
- name: setup python
16-
uses: actions/setup-python@v3
16+
uses: actions/setup-python@v4
1717
with:
1818
python-version: 3.8
1919

20-
- name: Install pip
21-
run: pip install pip
22-
2320
- name: Install Dependencies
24-
run: pip install setuptools wheel
21+
run: pip install -r requirements/pip.txt
2522

2623
- name: Build package
2724
run: python setup.py sdist bdist_wheel
2825

2926
- name: Publish to PyPi
30-
uses: pypa/gh-action-pypi-publish@master
27+
uses: pypa/gh-action-pypi-publish@release/v1
3128
with:
3229
user: __token__
3330
password: ${{ secrets.PYPI_UPLOAD_TOKEN }}

.github/workflows/upgrade-python-requirements.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@ on:
66
workflow_dispatch:
77
inputs:
88
branch:
9-
description: "Target branch against which to create requirements PR"
9+
description: Target branch against which to create requirements PR
1010
required: true
11-
# If copying this template manually, you must provide your default branch name
12-
# in quotes, such as 'master'
13-
default: "master"
11+
default: master
1412

1513
jobs:
1614
call-upgrade-python-requirements-workflow:
1715
uses: openedx/.github/.github/workflows/upgrade-python-requirements.yml@master
16+
# Do not run on forks
17+
if: github.repository_owner == 'openedx'
1818
with:
19-
# If copying manually, also provide your default branch name in quotes here
20-
branch: ${{ github.event.inputs.branch || "master" }}
19+
branch: ${{ github.event.inputs.branch || 'master' }}
2120
# optional parameters below; fill in if you'd like github or email notifications
2221
# user_reviewers: ""
2322
# team_reviewers: ""

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include Changelog.md
2+
include LICENSE
3+
include README.md
4+
include requirements/base.in
5+
include requirements/constraints.txt

Makefile

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
.PHONY: clean compile_translations dummy_translations \
2-
extract_translations fake_translations help
1+
.PHONY: clean help compile_translations dummy_translations extract_translations detect_changed_source_translations \
2+
build_dummy_translations validate_translations pull_translations push_translations check_translations_up_to_date \
3+
install_firefox requirements selfcheck test test.python test.unit test.quality upgrade mysql
34

45
.DEFAULT_GOAL := help
56

@@ -10,6 +11,8 @@ EXTRACTED_DJANGO := $(EXTRACT_DIR)/django-partial.po
1011
EXTRACTED_DJANGOJS := $(EXTRACT_DIR)/djangojs-partial.po
1112
EXTRACTED_TEXT := $(EXTRACT_DIR)/text.po
1213

14+
FIREFOX_VERSION := "43.0"
15+
1316
help: ## display this help message
1417
@echo "Please use \`make <target>' where <target> is one of"
1518
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'
@@ -56,21 +59,57 @@ push_translations: ## push translations to transifex
5659
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
5760

5861
install_firefox:
59-
mkdir -p test_helpers
60-
cd test_helpers && wget "https://ftp.mozilla.org/pub/firefox/releases/43.0/linux-x86_64/en-US/firefox-43.0.tar.bz2" && tar -xjf firefox-43.0.tar.bz2
62+
@mkdir -p test_helpers
63+
@test -f ./test_helpers/firefox/firefox && echo "Firefox already installed." || \
64+
(cd test_helpers && \
65+
wget -N "https://archive.mozilla.org/pub/firefox/releases/$(FIREFOX_VERSION)/linux-x86_64/en-US/firefox-$(FIREFOX_VERSION).tar.bz2" && \
66+
tar -xjf firefox-$(FIREFOX_VERSION).tar.bz2)
67+
68+
piptools: ## install pinned version of pip-compile and pip-sync
69+
pip install -r requirements/pip.txt
70+
pip install -r requirements/pip-tools.txt
71+
72+
requirements: piptools ## install test requirements locally
73+
pip-sync requirements/ci.txt
6174

62-
requirements: install_firefox
63-
pip install wheel
64-
pip install -r xblock-sdk/requirements/base.txt -r xblock-sdk/requirements/test.txt
65-
pip install -r requirements.txt
66-
pip uninstall -y transifex-client
75+
requirements_python: install_firefox piptools ## install all requirements locally
76+
pip-sync requirements/dev.txt requirements/private.*
6777

68-
test.quality: ## run quality checkers on the codebase
69-
pycodestyle drag_and_drop_v2 tests --max-line-length=120
70-
pylint drag_and_drop_v2
71-
pylint tests --rcfile=tests/pylintrc
78+
test.quality: selfcheck ## run quality checkers on the codebase
79+
tox -e quality
7280

73-
test.unit: ## run python unit and integration tests
81+
test.python: ## run python unit and integration tests
7482
PATH=test_helpers/firefox:$$PATH xvfb-run python run_tests.py $(TEST)
7583

76-
test: test.quality test.unit ## Run all tests
84+
test.unit: ## run all unit tests
85+
tox -- $(TEST)
86+
87+
test.integration: ## run all integration tests
88+
tox -e integration -- $(TEST)
89+
90+
test: test.unit test.integration test.quality ## Run all tests
91+
tox -e translations
92+
93+
# Define PIP_COMPILE_OPTS=-v to get more information during make upgrade.
94+
PIP_COMPILE = pip-compile --upgrade --resolver=backtracking $(PIP_COMPILE_OPTS)
95+
96+
upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
97+
upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
98+
pip install -qr requirements/pip-tools.txt
99+
# Make sure to compile files after any other files they include!
100+
$(PIP_COMPILE) --allow-unsafe -o requirements/pip.txt requirements/pip.in
101+
$(PIP_COMPILE) -o requirements/pip-tools.txt requirements/pip-tools.in
102+
pip install -qr requirements/pip.txt
103+
pip install -qr requirements/pip-tools.txt
104+
$(PIP_COMPILE) -o requirements/base.txt requirements/base.in
105+
$(PIP_COMPILE) -o requirements/test.txt requirements/test.in
106+
$(PIP_COMPILE) -o requirements/quality.txt requirements/quality.in
107+
$(PIP_COMPILE) -o requirements/workbench.txt requirements/workbench.in
108+
$(PIP_COMPILE) -o requirements/ci.txt requirements/ci.in
109+
$(PIP_COMPILE) -o requirements/dev.txt requirements/dev.in
110+
111+
mysql: ## run mysql database for integration tests
112+
docker run --rm -it --name mysql -p 3307:3306 -e MYSQL_ROOT_PASSWORD=rootpw -e MYSQL_DATABASE=db mysql:8
113+
114+
selfcheck: ## check that the Makefile is well-formed
115+
@echo "The Makefile is well-formed."

README.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -455,39 +455,56 @@ Real event example (taken from a devstack):
455455
```
456456

457457

458-
Testing
459-
-------
458+
Testing with tox
459+
----------------
460460

461461
Inside a fresh virtualenv, `cd` into the root folder of this repository
462-
(`xblock-drag-and-drop-v2`) and run
462+
(`xblock-drag-and-drop-v2`) and run:
463463

464464
```bash
465-
$ git submodule update --init --recursive
466465
$ make requirements
467466
```
468467

469-
You can then run the entire test suite via
468+
To run integration tests, you need to start MySQL first:
469+
```bash
470+
$ make mysql
471+
```
472+
473+
You can then run the entire test suite via:
470474

471475
```bash
472476
$ make test
473477
```
474478

475-
To only run the quality checks, do
479+
To run specific test groups, use one of the following commands:
476480

477481
```bash
482+
$ make test.unit
483+
$ make test.integration
478484
$ make test.quality
485+
$ make test.translations
479486
```
480487

481-
Similarly, you can run unit and integration test suite via
488+
To run individual unit tests, use:
482489

483490
```bash
484-
$ make test.unit
491+
$ make test.unit TEST=tests/unit/test_basics.py::BasicTests::test_student_view_data
485492
```
493+
To run individual integration tests, use:
494+
495+
```bash
496+
$ make test.integration TEST=tests.integration.test_studio.TestStudio.test_custom_image
497+
```
498+
499+
Manual testing (without tox)
500+
----------------------------
486501

487-
You can run specific tests via
502+
To run tests without tox, use:
488503

489504
```bash
490-
$ make test.unit TEST=tests.unit.test_basics.BasicTests.test_student_view_data
505+
$ make mysql
506+
$ make requirements_python
507+
$ make test.python TEST=tests.unit.test_basics.BasicTests.test_student_view_data
491508
```
492509

493510

drag_and_drop_v2/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
""" Drag and Drop v2 XBlock """
22
from .drag_and_drop_v2 import DragAndDropBlock
3+
4+
__version__ = "3.1.1"

drag_and_drop_v2/drag_and_drop_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ def show_answer(self, data, suffix=''):
654654

655655
answer = self._get_correct_state()
656656

657-
if explanation := self.data.get('explanation', '').strip():
657+
if explanation := (self.data.get('explanation') or '').strip():
658658
if replace_urls_service := self.runtime.service(self, 'replace_urls'):
659659
explanation = replace_urls_service.replace_urls(explanation)
660660

0 commit comments

Comments
 (0)