Skip to content

Commit

Permalink
feat: added github workflow to run tests for all open-edx plugins on …
Browse files Browse the repository at this point in the history
…different edx distributions (#277)

* feat: added ci actions

* feat: added ci actions new

* feat: added ci actions new1

* feat: added ci actions new2

* feat: added ci actions new2

* feat: added ci actions final

* feat: added ci actions final

* feat: added ci actions finalv2

* feat: added ci actions finalv2

* feat: added ci actions finalv2

* feat: added ci actions finalv2

* feat: added ci actions finalv2

* feat: added ci actions finalv2

* feat: added ci actions finalv2

* feat: removed the pylint and pycodestyle

* feat: pytest github step

* feat: looping through plugins and running tests

* feat: looping through plugins and running tests

* feat: looping through plugins and running tests

* feat: enabling tests for different edx distributions

* feat: some cleanup

* feat: added ruff in git workflow

---------

Co-authored-by: root <[email protected]>
  • Loading branch information
Anas12091101 and root authored Feb 9, 2024
1 parent 7e3c695 commit a8444d2
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 10 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: CI
on: [push]
jobs:
integration-tests:
runs-on: ubuntu-latest
strategy:
matrix:
devstack-branch:
- master
- open-release/quince.master
- open-release/palm.master
- open-release/olive.master
# Add more branches as needed

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8.15"

- name: Set up Pants
run: |
# Install Pants
export PATH=$PATH:/root/.local/bin
curl --proto '=https' --tlsv1.2 -fsSL https://static.pantsbuild.org/setup/get-pants.sh | bash
pants package ::
- name: Checking formatting with Ruff
run: |
pip install ruff
ruff check --extend-ignore=D1
- name: Setup edX & Run Tests
run: |
cd ..
git clone https://github.com/edx/devstack.git
cd devstack
sed -i 's/:cached//g' ./docker-compose-host.yml
git checkout ${{ matrix.devstack-branch }}
make dev.clone.https
DEVSTACK_WORKSPACE=$PWD/.. docker-compose -f docker-compose.yml -f docker-compose-host.yml run -v $PWD/../open-edx-plugins:/open-edx-plugins lms /open-edx-plugins/run_devstack_integration_tests.sh
- name: Upload coverage to CodeCov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
fail_ci_if_error: false
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ ignore = [
"D205",
"D301",
"D400",
"E902",
"N803",
"N806",
"N999",
Expand Down
62 changes: 62 additions & 0 deletions run_devstack_integration_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
set -e

source /edx/app/edxapp/venvs/edxapp/bin/activate

cd /edx/app/edxapp/edx-platform
mkdir -p reports

pip install -r ./requirements/edx/testing.txt
pip install -r ./requirements/edx/paver.txt

mkdir -p test_root # for edx
paver update_assets lms --settings=test_static_optimized

cp test_root/staticfiles/lms/webpack-stats.json test_root/staticfiles/webpack-stats.json


cd /open-edx-plugins

pip install dist/edx-sysadmin-0.3.0.tar.gz
pip install dist/ol-openedx-canvas-integration-0.3.0.tar.gz
pip install dist/ol-openedx-checkout-external-0.1.3.tar.gz
pip install dist/ol-openedx-course-export-0.1.2.tar.gz
pip install dist/ol-openedx-course-structure-api-0.1.3.tar.gz
pip install dist/ol-openedx-git-auto-export-0.3.1.tar.gz
pip install dist/ol-openedx-logging-0.1.0.tar.gz
pip install dist/ol-openedx-rapid-response-reports-0.3.0.tar.gz
pip install dist/ol-openedx-sentry-0.1.2.tar.gz

# Install codecov so we can upload code coverage results
pip install codecov

# output the packages which are installed for logging
pip freeze

set +e


set +e
for subdir in "src"/*; do
if [ -d "$subdir" ]; then
tests_directory="$subdir/tests"

# Check if tests directory exists
if [ -d "$tests_directory" ]; then
cp -r /edx/app/edxapp/edx-platform/test_root/ "/open-edx-plugins/$subdir/test_root"
echo "==============Running $subdir test==================="
cd "$subdir"
pytest . --cov .
PYTEST_SUCCESS=$?

if [[ $PYTEST_SUCCESS -ne 0 ]]
then
echo "pytest exited with a non-zero status"
exit $PYTEST_SUCCESS
fi
coverage xml
cd ../..
fi
fi
done
set -e
7 changes: 0 additions & 7 deletions src/edx_sysadmin/api/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import ddt
from django.test import TestCase, override_settings
from django.urls import reverse
from git import Repo
from rest_framework import status as _status
from rest_framework.test import APIClient

Expand All @@ -28,12 +27,6 @@ def setUp(self):

@override_settings(SYSADMIN_GITHUB_WEBHOOK_KEY=SYSADMIN_GITHUB_WEBHOOK_KEY)
@override_settings(SYSADMIN_DEFAULT_BRANCH="master")
@patch(
"edx_sysadmin.api.views.get_local_active_branch",
return_value="refs/heads/master",
)
@patch("edx_sysadmin.api.views.get_local_course_repo", return_value=Repo())
@patch("edx_sysadmin.api.views.add_repo")
@ddt.data(
(
"d3a2424a1ad48d8441712400fd75392d56707a7b3e1dc4869239d87ee381cfa9", # pragma: allowlist secret # noqa: E501
Expand Down
30 changes: 30 additions & 0 deletions src/edx_sysadmin/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[tool:pytest]
pep8maxlinelength = 119
DJANGO_SETTINGS_MODULE = lms.envs.test
addopts = --nomigrations --reuse-db --durations=20
# Enable default handling for all warnings, including those that are ignored by default;
# but hide rate-limit warnings (because we deliberately don't throttle test user logins)
# and field_data deprecation warnings (because fixing them requires a major low-priority refactoring)
filterwarnings =
default
ignore::xblock.exceptions.FieldDataDeprecationWarning
ignore::pytest.PytestConfigWarning
ignore:No request passed to the backend, unable to rate-limit:UserWarning
ignore:Flags not at the start of the expression:DeprecationWarning
ignore:Using or importing the ABCs from 'collections' instead of from 'collections.abc':DeprecationWarning
ignore:invalid escape sequence:DeprecationWarning
ignore:`formatargspec` is deprecated since Python 3.5:DeprecationWarning
ignore:the imp module is deprecated in favour of importlib:DeprecationWarning
ignore:"is" with a literal:SyntaxWarning
ignore:defusedxml.lxml is no longer supported:DeprecationWarning
ignore: `np.int` is a deprecated alias for the builtin `int`.:DeprecationWarning
ignore: `np.float` is a deprecated alias for the builtin `float`.:DeprecationWarning
ignore: `np.complex` is a deprecated alias for the builtin `complex`.:DeprecationWarning
ignore: 'etree' is deprecated. Use 'xml.etree.ElementTree' instead.:DeprecationWarning
ignore: defusedxml.cElementTree is deprecated, import from defusedxml.ElementTree instead.:DeprecationWarning


junit_family = xunit2
norecursedirs = .* *.egg build conf dist node_modules test_root cms/envs lms/envs
python_classes =
python_files = tests.py test_*.py tests_*.py *_tests.py __init__.py
6 changes: 3 additions & 3 deletions src/edx_sysadmin/tests/test_sysadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from django.test.client import Client
from django.test.utils import override_settings
from django.urls import reverse
from edx_sysadmin.git_import import GitImportErrorNoDir
from edx_sysadmin.git_import import GitImportNoDirError
from edx_sysadmin.models import CourseGitLog
from opaque_keys.edx.locator import CourseLocator
from openedx.core.djangolib.markup import Text
Expand Down Expand Up @@ -114,7 +114,7 @@ def _mkdir(self, path):


@override_settings(
GIT_REPO_DIR="/edx-sysadmin" / settings.TEST_ROOT / f"course_repos_{uuid4().hex}",
GIT_REPO_DIR=settings.TEST_ROOT / f"course_repos_{uuid4().hex}",
)
class TestSysAdminMongoCourseImport(SysadminBaseTestCase):
"""
Expand Down Expand Up @@ -153,7 +153,7 @@ def test_missing_repo_dir(self):
# Create git loaded course
response = self._add_edx4edx()
self.assertContains(
response, Text(str(GitImportErrorNoDir(settings.GIT_REPO_DIR)))
response, Text(str(GitImportNoDirError(settings.GIT_REPO_DIR)))
)

def test_mongo_course_add_delete(self):
Expand Down

0 comments on commit a8444d2

Please sign in to comment.