forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
temp: put back paver checks for testing
- Loading branch information
1 parent
c76feed
commit 1fc2c24
Showing
20 changed files
with
2,199 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Javascript tests PAVER | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
run_tests: | ||
name: JS | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
node-version: [18, 20] | ||
python-version: | ||
- "3.11" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Fetch master to compare coverage | ||
run: git fetch --depth=1 origin master | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Setup npm | ||
run: npm i -g [email protected] | ||
|
||
- name: Install Firefox 123.0 | ||
run: | | ||
sudo apt-get purge firefox | ||
wget "https://ftp.mozilla.org/pub/firefox/releases/123.0/linux-x86_64/en-US/firefox-123.0.tar.bz2" | ||
tar -xjf firefox-123.0.tar.bz2 | ||
sudo mv firefox /opt/firefox | ||
sudo ln -s /opt/firefox/firefox /usr/bin/firefox | ||
- name: Install Required System Packages | ||
run: sudo apt-get update && sudo apt-get install libxmlsec1-dev ubuntu-restricted-extras xvfb | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- 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@v4 | ||
with: | ||
path: ${{ steps.pip-cache-dir.outputs.dir }} | ||
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/edx/base.txt') }} | ||
restore-keys: ${{ runner.os }}-pip- | ||
|
||
- name: Install Required Python Dependencies | ||
run: | | ||
make base-requirements | ||
- uses: c-hive/gha-npm-cache@v1 | ||
- name: Run JS Tests | ||
env: | ||
TEST_SUITE: js-unit | ||
SCRIPT_TO_RUN: ./scripts/generic-ci-tests.sh | ||
run: | | ||
npm install -g jest | ||
xvfb-run --auto-servernum ./scripts/all-tests.sh | ||
- name: Save Job Artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: Build-Artifacts | ||
path: | | ||
reports/**/* | ||
test_root/log/*.png | ||
test_root/log/*.log | ||
**/TEST-*.xml | ||
overwrite: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Quality checks PAVER | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
- open-release/lilac.master | ||
|
||
jobs: | ||
run_tests: | ||
name: Quality Others | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-22.04] | ||
python-version: | ||
- "3.11" | ||
node-version: [20] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Fetch base branch for comparison | ||
run: git fetch --depth=1 origin ${{ github.base_ref }} | ||
|
||
- name: Install Required System Packages | ||
run: sudo apt-get update && sudo apt-get install libxmlsec1-dev | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Setup npm | ||
run: npm i -g [email protected] | ||
|
||
- 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@v4 | ||
with: | ||
path: ${{ steps.pip-cache-dir.outputs.dir }} | ||
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/edx/testing.txt') }} | ||
restore-keys: ${{ runner.os }}-pip- | ||
|
||
- name: Install Required Python Dependencies | ||
env: | ||
PIP_SRC: ${{ runner.temp }} | ||
run: | | ||
make test-requirements | ||
- name: Run Quality Tests | ||
env: | ||
TEST_SUITE: quality | ||
SCRIPT_TO_RUN: ./scripts/generic-ci-tests.sh | ||
PIP_SRC: ${{ runner.temp }} | ||
TARGET_BRANCH: ${{ github.base_ref }} | ||
run: | | ||
./scripts/all-tests.sh | ||
- name: Save Job Artifacts | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: Build-Artifacts | ||
path: | | ||
**/reports/**/* | ||
test_root/log/**/*.log | ||
*.log | ||
overwrite: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
""" | ||
|
||
|
||
from . import assets | ||
from . import assets, js_test, prereqs, quality |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
""" | ||
Javascript test tasks | ||
""" | ||
|
||
|
||
import os | ||
import re | ||
import sys | ||
|
||
from paver.easy import cmdopts, needs, sh, task | ||
|
||
from pavelib.utils.envs import Env | ||
from pavelib.utils.test.suites import JestSnapshotTestSuite, JsTestSuite | ||
from pavelib.utils.timer import timed | ||
|
||
try: | ||
from pygments.console import colorize | ||
except ImportError: | ||
colorize = lambda color, text: text | ||
|
||
__test__ = False # do not collect | ||
|
||
|
||
@task | ||
@needs( | ||
'pavelib.prereqs.install_node_prereqs', | ||
'pavelib.utils.test.utils.clean_reports_dir', | ||
) | ||
@cmdopts([ | ||
("suite=", "s", "Test suite to run"), | ||
("mode=", "m", "dev or run"), | ||
("coverage", "c", "Run test under coverage"), | ||
("port=", "p", "Port to run test server on (dev mode only)"), | ||
('skip-clean', 'C', 'skip cleaning repository before running tests'), | ||
('skip_clean', None, 'deprecated in favor of skip-clean'), | ||
], share_with=["pavelib.utils.tests.utils.clean_reports_dir"]) | ||
@timed | ||
def test_js(options): | ||
""" | ||
Run the JavaScript tests | ||
""" | ||
mode = getattr(options, 'mode', 'run') | ||
port = None | ||
skip_clean = getattr(options, 'skip_clean', False) | ||
|
||
if mode == 'run': | ||
suite = getattr(options, 'suite', 'all') | ||
coverage = getattr(options, 'coverage', False) | ||
elif mode == 'dev': | ||
suite = getattr(options, 'suite', None) | ||
coverage = False | ||
port = getattr(options, 'port', None) | ||
else: | ||
sys.stderr.write("Invalid mode. Please choose 'dev' or 'run'.") | ||
return | ||
|
||
if (suite != 'all') and (suite not in Env.JS_TEST_ID_KEYS): | ||
sys.stderr.write( | ||
"Unknown test suite. Please choose from ({suites})\n".format( | ||
suites=", ".join(Env.JS_TEST_ID_KEYS) | ||
) | ||
) | ||
return | ||
|
||
if suite != 'jest-snapshot': | ||
test_suite = JsTestSuite(suite, mode=mode, with_coverage=coverage, port=port, skip_clean=skip_clean) | ||
test_suite.run() | ||
|
||
if (suite == 'jest-snapshot') or (suite == 'all'): # lint-amnesty, pylint: disable=consider-using-in | ||
test_suite = JestSnapshotTestSuite('jest') | ||
test_suite.run() | ||
|
||
|
||
@task | ||
@cmdopts([ | ||
("suite=", "s", "Test suite to run"), | ||
("coverage", "c", "Run test under coverage"), | ||
]) | ||
@timed | ||
def test_js_run(options): | ||
""" | ||
Run the JavaScript tests and print results to the console | ||
""" | ||
options.mode = 'run' | ||
test_js(options) | ||
|
||
|
||
@task | ||
@cmdopts([ | ||
("suite=", "s", "Test suite to run"), | ||
("port=", "p", "Port to run test server on"), | ||
]) | ||
@timed | ||
def test_js_dev(options): | ||
""" | ||
Run the JavaScript tests in your default browsers | ||
""" | ||
options.mode = 'dev' | ||
test_js(options) | ||
|
||
|
||
@task | ||
@needs('pavelib.prereqs.install_coverage_prereqs') | ||
@cmdopts([ | ||
("compare-branch=", "b", "Branch to compare against, defaults to origin/master"), | ||
], share_with=['coverage']) | ||
@timed | ||
def diff_coverage(options): | ||
""" | ||
Build the diff coverage reports | ||
""" | ||
compare_branch = options.get('compare_branch', 'origin/master') | ||
|
||
# Find all coverage XML files (both Python and JavaScript) | ||
xml_reports = [] | ||
|
||
for filepath in Env.REPORT_DIR.walk(): | ||
if bool(re.match(r'^coverage.*\.xml$', filepath.basename())): | ||
xml_reports.append(filepath) | ||
|
||
if not xml_reports: | ||
err_msg = colorize( | ||
'red', | ||
"No coverage info found. Run `paver test` before running " | ||
"`paver coverage`.\n" | ||
) | ||
sys.stderr.write(err_msg) | ||
else: | ||
xml_report_str = ' '.join(xml_reports) | ||
diff_html_path = os.path.join(Env.REPORT_DIR, 'diff_coverage_combined.html') | ||
|
||
# Generate the diff coverage reports (HTML and console) | ||
# The --diff-range-notation parameter is a workaround for https://github.com/Bachmann1234/diff_cover/issues/153 | ||
sh( | ||
"diff-cover {xml_report_str} --diff-range-notation '..' --compare-branch={compare_branch} " | ||
"--html-report {diff_html_path}".format( | ||
xml_report_str=xml_report_str, | ||
compare_branch=compare_branch, | ||
diff_html_path=diff_html_path, | ||
) | ||
) | ||
|
||
print("\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
""" | ||
Pytest fixtures for the pavelib unit tests. | ||
""" | ||
|
||
|
||
import os | ||
from shutil import rmtree | ||
|
||
import pytest | ||
|
||
from pavelib.utils.envs import Env | ||
|
||
|
||
@pytest.fixture(autouse=True, scope='session') | ||
def delete_quality_junit_xml(): | ||
""" | ||
Delete the JUnit XML results files for quality check tasks run during the | ||
unit tests. | ||
""" | ||
yield | ||
if os.path.exists(Env.QUALITY_DIR): | ||
rmtree(Env.QUALITY_DIR, ignore_errors=True) |
Oops, something went wrong.