From f726ac2becb2e5f5e18ab86ebdcfdae88d9aa1cd Mon Sep 17 00:00:00 2001 From: Sathis Kumar Date: Sat, 13 May 2023 00:40:23 +0530 Subject: [PATCH 1/5] build: Added integration test workflow action Integration test workflow action is added to run automatically on PR. --- .github/workflows/integration-tests.yml | 96 +++++++++++++++++++++++++ CHANGELOG.rst | 7 +- Makefile | 4 +- 3 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/integration-tests.yml diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml new file mode 100644 index 0000000..b612988 --- /dev/null +++ b/.github/workflows/integration-tests.yml @@ -0,0 +1,96 @@ +name: integration-tests + +on: + pull_request: + push: + branches: + - main + +jobs: + run-tests: + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + edx-platform-version: [ 'open-release/nutmeg.master' ] + env: + EDX_PLATFORM_PATH: './edx/app/edxapp/edx-platform' + SECTION_TO_COURSE_PATH: './edx/src/section-to-course' + + name: section-to-course-gh-hosted-python-edx-plaform-${{ matrix.edx-platform-version }} + steps: + # Create the docker container directory structure + # Note: We do not have permission to create directory in root folder. + # So create folder structure relative to current directory. + - name: Create edx-platform directory + run: mkdir -p ${{ env.EDX_PLATFORM_PATH }} + + - name: Checkout edx-platform repository + uses: actions/checkout@v3 + with: + repository: openedx/edx-platform + ref: ${{ matrix.edx-platform-version }} + path: ${{ env.EDX_PLATFORM_PATH }} + + - name: Checkout OpenCraft edx-platform code drift changes + uses: actions/checkout@v3 + if: ${{ matrix.edx-platform-version }} == 'open-release/nutmeg.master' + with: + repository: open-craft/edx-platform + ref: 'opencraft-release/nutmeg.2' + 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-version }}" == "master" ]]; then + make test-requirements + elif [[ "${{ matrix.edx-platform-version }}" == "open-release/nutmeg.master" ]]; then + pip install -r requirements/pip.txt + pip install -r requirements/edx/development.txt --src ${{ runner.temp }} + pip install "django~=3.2.0" + fi + + - name: Create section-to-course directory + run: mkdir -p ${{ env.SECTION_TO_COURSE_PATH }} + + - 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 test + working-directory: ${{ env.SECTION_TO_COURSE_PATH }} + run: make test_integration 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..2f07459 100644 --- a/Makefile +++ b/Makefile @@ -58,8 +58,8 @@ 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: +test_integration: export DJANGO_SETTINGS_MODULE=cms.envs.test +test_integration: cd ../../app/edxapp/edx-platform/ && pytest --pyargs section_to_course --rootdir cms diff_cover: test ## find diff lines that need test coverage From 0fd45984ba468bc659fec538ed029ed93616874a Mon Sep 17 00:00:00 2001 From: Agrendalath Date: Mon, 15 May 2023 15:28:06 +0200 Subject: [PATCH 2/5] build: add default branch to the Upgrade Requirements workflow --- .github/workflows/upgrade-python-requirements.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 9816eed888fa7551f6b777e005e4a88eadf8fe6b Mon Sep 17 00:00:00 2001 From: Agrendalath Date: Mon, 15 May 2023 16:18:28 +0200 Subject: [PATCH 3/5] build: improve integration-tests workflow --- .github/workflows/integration-tests.yml | 64 +++++++++++-------------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index b612988..08c9551 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -1,43 +1,38 @@ -name: integration-tests +name: Integration Tests on: pull_request: push: - branches: - - main - + branches: [main] + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: - run-tests: + tests: + name: ${{ matrix.edx-platform.branch }} (${{ matrix.edx-platform.release }}) runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: - edx-platform-version: [ 'open-release/nutmeg.master' ] + edx-platform: + - branch: opencraft-release/nutmeg.2 + remote: open-craft + release: nutmeg env: - EDX_PLATFORM_PATH: './edx/app/edxapp/edx-platform' - SECTION_TO_COURSE_PATH: './edx/src/section-to-course' + EDX_PLATFORM_PATH: ./edx/app/edxapp/edx-platform + SECTION_TO_COURSE_PATH: ./edx/src/section-to-course - name: section-to-course-gh-hosted-python-edx-plaform-${{ matrix.edx-platform-version }} steps: - # Create the docker container directory structure - # Note: We do not have permission to create directory in root folder. - # So create folder structure relative to current directory. - - name: Create edx-platform directory - run: mkdir -p ${{ env.EDX_PLATFORM_PATH }} + - 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: openedx/edx-platform - ref: ${{ matrix.edx-platform-version }} - path: ${{ env.EDX_PLATFORM_PATH }} - - - name: Checkout OpenCraft edx-platform code drift changes - uses: actions/checkout@v3 - if: ${{ matrix.edx-platform-version }} == 'open-release/nutmeg.master' - with: - repository: open-craft/edx-platform - ref: 'opencraft-release/nutmeg.2' + repository: ${{ matrix.edx-platform.remote }}/edx-platform + ref: ${{ matrix.edx-platform.branch }} path: ${{ env.EDX_PLATFORM_PATH }} - name: install edx-platform required packages @@ -47,7 +42,7 @@ jobs: uses: supercharge/mongodb-github-action@1.7.0 with: mongodb-version: 4.4 - + - name: Setup Python uses: actions/setup-python@v4 with: @@ -55,8 +50,7 @@ jobs: - name: Get pip cache dir id: pip-cache-dir - run: | - echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT + run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - name: Cache pip dependencies id: cache-dependencies @@ -65,23 +59,19 @@ jobs: 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 + + - name: Install edx-platform required Python dependencies env: PIP_SRC: ${{ runner.temp }} working-directory: ${{ env.EDX_PLATFORM_PATH }} run: | - if [[ "${{ matrix.edx-platform-version }}" == "master" ]]; then - make test-requirements - elif [[ "${{ matrix.edx-platform-version }}" == "open-release/nutmeg.master" ]]; then + if [[ "${{ matrix.edx-platform.release }}" == "nutmeg" ]]; then pip install -r requirements/pip.txt pip install -r requirements/edx/development.txt --src ${{ runner.temp }} - pip install "django~=3.2.0" + else + make test-requirements fi - - name: Create section-to-course directory - run: mkdir -p ${{ env.SECTION_TO_COURSE_PATH }} - - name: Checkout section-to-course repo uses: actions/checkout@v3 with: @@ -91,6 +81,6 @@ jobs: working-directory: ${{ env.SECTION_TO_COURSE_PATH }} run: pip install -e . - - name: Run section-to-course integration test + - name: Run section-to-course integration tests working-directory: ${{ env.SECTION_TO_COURSE_PATH }} run: make test_integration From 6f18ceb653fbe7f1c80b499dd996fd20ea58e2f1 Mon Sep 17 00:00:00 2001 From: Agrendalath Date: Mon, 15 May 2023 16:20:37 +0200 Subject: [PATCH 4/5] build: add coverage --- .coveragerc | 1 + .github/workflows/integration-tests.yml | 9 +++++++++ Makefile | 15 +++++++-------- 3 files changed, 17 insertions(+), 8 deletions(-) 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 index 08c9551..c7ae64d 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -84,3 +84,12 @@ jobs: - 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/Makefile b/Makefile index 2f07459..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 @@ -60,16 +63,12 @@ requirements: piptools ## install development environment requirements test_integration: export DJANGO_SETTINGS_MODULE=cms.envs.test test_integration: - cd ../../app/edxapp/edx-platform/ && pytest --pyargs section_to_course --rootdir cms + 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." From 799548abdbb36d832daf1adfaf5486ee84a1821d Mon Sep 17 00:00:00 2001 From: Agrendalath Date: Mon, 15 May 2023 16:20:43 +0200 Subject: [PATCH 5/5] build: add master branch --- .github/workflows/integration-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index c7ae64d..92e7b00 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -20,6 +20,9 @@ jobs: - 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