diff --git a/.coveragerc b/.coveragerc index c26b17a..888e66e 100644 --- a/.coveragerc +++ b/.coveragerc @@ -8,3 +8,4 @@ omit = *admin.py *static* *templates* + *tests* diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml new file mode 100644 index 0000000..92e7b00 --- /dev/null +++ b/.github/workflows/integration-tests.yml @@ -0,0 +1,98 @@ +name: Integration Tests + +on: + pull_request: + push: + branches: [main] + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + tests: + name: ${{ matrix.edx-platform.branch }} (${{ matrix.edx-platform.release }}) + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + edx-platform: + - branch: opencraft-release/nutmeg.2 + remote: open-craft + release: nutmeg + - branch: fox/bb-7295-direct-copying + remote: open-craft + release: master + env: + EDX_PLATFORM_PATH: ./edx/app/edxapp/edx-platform + SECTION_TO_COURSE_PATH: ./edx/src/section-to-course + + steps: + - name: Create directory structure + run: mkdir -p ${{ env.EDX_PLATFORM_PATH }} ${{ env.SECTION_TO_COURSE_PATH }} + + - name: Checkout edx-platform repository + uses: actions/checkout@v3 + with: + repository: ${{ matrix.edx-platform.remote }}/edx-platform + ref: ${{ matrix.edx-platform.branch }} + path: ${{ env.EDX_PLATFORM_PATH }} + + - name: install edx-platform required packages + run: sudo apt-get update && sudo apt-get install libxmlsec1-dev lynx + + - name: Start MongoDB + uses: supercharge/mongodb-github-action@1.7.0 + with: + mongodb-version: 4.4 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: 3.8 + + - name: Get pip cache dir + id: pip-cache-dir + run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT + + - name: Cache pip dependencies + id: cache-dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.pip-cache-dir.outputs.dir }} + key: ${{ runner.os }}-pip-${{ hashFiles('requirements/edx/testing.txt') }} + restore-keys: ${{ runner.os }}-pip- + + - name: Install edx-platform required Python dependencies + env: + PIP_SRC: ${{ runner.temp }} + working-directory: ${{ env.EDX_PLATFORM_PATH }} + run: | + if [[ "${{ matrix.edx-platform.release }}" == "nutmeg" ]]; then + pip install -r requirements/pip.txt + pip install -r requirements/edx/development.txt --src ${{ runner.temp }} + else + make test-requirements + fi + + - name: Checkout section-to-course repo + uses: actions/checkout@v3 + with: + path: ${{ env.SECTION_TO_COURSE_PATH }} + + - name: Install section-to-course + working-directory: ${{ env.SECTION_TO_COURSE_PATH }} + run: pip install -e . + + - name: Run section-to-course integration tests + working-directory: ${{ env.SECTION_TO_COURSE_PATH }} + run: make test_integration + + - name: Run coverage + if: matrix.edx-platform.branch == 'opencraft-release/nutmeg.2' + uses: codecov/codecov-action@v3 + with: + working-directory: ${{ env.SECTION_TO_COURSE_PATH }} + token: ${{ secrets.CODECOV_TOKEN }} + flags: integration + fail_ci_if_error: true diff --git a/.github/workflows/upgrade-python-requirements.yml b/.github/workflows/upgrade-python-requirements.yml index d685da5..85722bf 100644 --- a/.github/workflows/upgrade-python-requirements.yml +++ b/.github/workflows/upgrade-python-requirements.yml @@ -12,7 +12,7 @@ on: jobs: call-upgrade-python-requirements-workflow: with: - branch: ${{ github.event.inputs.branch }} + branch: ${{ github.event.inputs.branch || 'main' }} # team_reviewers: "" # email_address: email@edx.org send_success_notification: false diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2c490d0..50538d5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,7 +3,7 @@ Change Log .. All enhancements and patches to section_to_course will be documented - in this file. It adheres to the structure of https://keepachangelog.com/ , + in this file. It adheres to the structure of https://keepachangelog.com/ , but in reStructuredText instead of Markdown (for ease of incorporation into Sphinx documentation and the PyPI description). @@ -14,7 +14,10 @@ Change Log Unreleased ********** -* +Added +===== + +* Github integration-tests action. [0.3.0] - 2023-05-12 ******************** diff --git a/Makefile b/Makefile index 1c501b5..f21d1b0 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: clean compile_translations coverage diff_cover dummy_translations \ extract_translations fake_translations help pii_check pull_translations push_translations \ - quality requirements selfcheck test test-all upgrade validate install_transifex_client + quality requirements selfcheck test_integration test_package upgrade validate install_transifex_client .DEFAULT_GOAL := help @@ -51,6 +51,9 @@ quality: ## check coding style with pycodestyle and pylint pii_check: ## check for PII annotations on all Django models tox -e pii_check +test_package: ## check if the Python package is formatted correctly + tox -e package + piptools: ## install pinned version of pip-compile and pip-sync pip install -r requirements/pip.txt pip install -r requirements/pip-tools.txt @@ -58,18 +61,14 @@ piptools: ## install pinned version of pip-compile and pip-sync requirements: piptools ## install development environment requirements pip-sync -q requirements/dev.txt requirements/private.* -test: export DJANGO_SETTINGS_MODULE=cms.envs.test -test: - cd ../../app/edxapp/edx-platform/ && pytest --pyargs section_to_course --rootdir cms +test_integration: export DJANGO_SETTINGS_MODULE=cms.envs.test +test_integration: + cd ../../app/edxapp/edx-platform/ && pytest --pyargs section_to_course --rootdir cms --cov section_to_course --cov-config=$(CURDIR)/.coveragerc --cov-report term-missing --cov-report=xml:$(CURDIR)/coverage.xml -diff_cover: test ## find diff lines that need test coverage +diff_cover: test_integration ## find diff lines that need test coverage diff-cover coverage.xml -test-all: quality pii_check ## run tests on every supported Python/Django combination - tox - tox -e docs - -validate: quality pii_check test ## run tests and quality checks +validate: quality pii_check test_package ## run tests and quality checks selfcheck: ## check that the Makefile is well-formed @echo "The Makefile is well-formed."