Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sage -t --format github (illustration) #36558

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
7f982bb
.github/workflows/ci-conda-known-test-failures.json: Add random failu…
mkoeppe Dec 20, 2023
48cde67
src/sage/doctest/forker.py: Show '# [failed in baseline]' earlier
mkoeppe Dec 20, 2023
d52858c
Refactor through new function DocTestController.source_baseline
mkoeppe Dec 20, 2023
1849493
WIP
mkoeppe Dec 20, 2023
8aca1ad
sage -t: Add option '--format github'
mkoeppe Dec 21, 2023
72ac0ec
.github/workflows/build.yml: Use sage -t --format github
mkoeppe Dec 21, 2023
7a121e6
src/sage/doctest/control.py: Fix doctest
mkoeppe Dec 21, 2023
0bd0077
src/sage/doctest/control.py: Log 'Using --baseline-stats-path=...'
mkoeppe Dec 21, 2023
8c8f2dc
Merge branch 'doctester-baselinestats-improvement' into doctester-git…
mkoeppe Dec 21, 2023
24779a9
src/sage/doctest/forker.py: Rewrite without 'match'
mkoeppe Dec 21, 2023
ee0cb6b
.github/workflows/ci-conda-known-test-failures.json: Add https://gith…
mkoeppe Dec 21, 2023
fed6570
.github/workflows/ci-conda-known-test-failures.json: Add https://gith…
mkoeppe Dec 21, 2023
22ef486
.github/workflows/ci-conda-known-test-failures.json: Add some failure…
mkoeppe Dec 21, 2023
5fc07c7
src/bin/sage-runtests: Generalize argparse hack
mkoeppe Dec 21, 2023
93c4e7d
DocTestReporter.report_head: Move all printing of 'failed in baseline…
mkoeppe Dec 21, 2023
55eba9f
Merge branch 'doctester-baselinestats-improvement' into doctester-git…
mkoeppe Dec 21, 2023
0f35de8
Merge branch 'doctester-github-annotations--prod' into doctester-gith…
mkoeppe Dec 21, 2023
c05bdba
DocTestReporter.report_head: Move all printing of 'failed in baseline…
mkoeppe Dec 21, 2023
5d5f6c1
Merge branch 'doctester-baselinestats-improvement' into doctester-git…
mkoeppe Dec 21, 2023
c165172
Merge branch 'doctester-github-annotations--prod' into doctester-gith…
mkoeppe Dec 21, 2023
5e5d720
Merge branch 'doctester-baselinestats-improvement' into ci_conda_more…
mkoeppe Dec 21, 2023
179ebb4
.github/workflows/ci-conda-known-test-failures.json: Add references f…
mkoeppe Dec 21, 2023
b41999b
.github/workflows/ci-conda-known-test-failures.json: Add details from…
mkoeppe Dec 21, 2023
63b8b10
src/sage/doctest/reporting.py: Include message in '[failed in baselin…
mkoeppe Dec 21, 2023
4a22bbc
Merge branch 'ci_conda_more_known_failures' into doctester-github-ann…
mkoeppe Dec 21, 2023
4b0f525
.github/workflows/build.yml: Fix up path to coverage files
mkoeppe Dec 23, 2023
0bfd2c9
src/sage/doctest/reporting.py: Make 'AlarmInterrupt in doctesting fra…
mkoeppe Dec 23, 2023
f2d8abf
Merge branch 'doctester-baselinestats-improvement' into doctester-git…
mkoeppe Dec 23, 2023
ce3b849
.github/workflows/build.yml: Do not create GitHub Annotations for the…
mkoeppe Dec 28, 2023
2a540d8
Merge remote-tracking branch 'upstream/develop' into doctester-github…
mkoeppe Dec 28, 2023
b14e0f2
Merge branch 'doctester-github-annotations--prod' into doctester-gith…
mkoeppe Dec 28, 2023
b83dcf3
src/sage/doctest/forker.py: Use urllib.parse.quote for github annotat…
mkoeppe Dec 29, 2023
81768a3
Merge branch 'doctester-github-annotations--prod' into doctester-gith…
mkoeppe Dec 29, 2023
96e0431
src/sage/doctest/forker.py: Don't use urllib.parse.quote, only quote …
mkoeppe Dec 29, 2023
dda4dc3
Merge branch 'doctester-github-annotations--prod' into doctester-gith…
mkoeppe Dec 29, 2023
1d69f07
.github/workflows/build.yml: Fix "Couldn't combine from non-existent …
mkoeppe Dec 29, 2023
2cfcbe3
Merge remote-tracking branch 'upstream/develop' into doctester-github…
mkoeppe Jan 4, 2024
173bc41
.github/workflows/build.yml: Pass --rcfile to coverage
mkoeppe Jan 5, 2024
d27f1ca
Merge branch 'doctester-github-annotations--prod' into doctester-gith…
mkoeppe Jan 5, 2024
4ecf7ca
src/tox.ini (coverage:report): Ignore errors, ignore empty
mkoeppe Jan 5, 2024
aa344d2
Merge branch 'doctester-github-annotations--prod' into doctester-gith…
mkoeppe Jan 5, 2024
6aa76c0
Merge remote-tracking branch 'upstream/develop' into doctester-github…
mkoeppe Jan 14, 2024
e8ef307
Merge branch 'doctester-github-annotations--prod' into doctester-gith…
mkoeppe Jan 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 8 additions & 47 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,39 +96,6 @@ jobs:
MAKE: make -j2 --output-sync=recurse
SAGE_NUM_THREADS: 2

- name: Build modularized distributions
if: (success() || failure()) && steps.worktree.outcome == 'success'
run: make V=0 tox && make SAGE_CHECK=no pypi-wheels
working-directory: ./worktree-image
env:
MAKE: make -j2 --output-sync=recurse
SAGE_NUM_THREADS: 2

- name: Static code check with pyright
if: (success() || failure()) && steps.worktree.outcome == 'success'
uses: jakebailey/pyright-action@v1
with:
version: 1.1.332
# Many warnings issued by pyright are not yet helpful because there is not yet enough type information.
no-comments: true
working-directory: ./worktree-image
env:
# To avoid out of memory errors
NODE_OPTIONS: --max-old-space-size=8192

- name: Static code check with pyright (annotated)
if: (success() || failure()) && steps.worktree.outcome == 'success'
uses: jakebailey/pyright-action@v1
with:
version: 1.1.332
# Issue errors
no-comments: false
level: error
working-directory: ./worktree-image
env:
# To avoid out of memory errors
NODE_OPTIONS: --max-old-space-size=8192

- name: Clean (fallback to non-incremental)
id: clean
if: (success() || failure()) && steps.worktree.outcome == 'success' && steps.incremental.outcome != 'success'
Expand Down Expand Up @@ -187,31 +154,25 @@ jobs:
- name: Pytest
if: contains(github.ref, 'pytest')
run: |
../sage -python -m pip install coverage pytest-xdist
../sage -python -m coverage run -m pytest -c tox.ini --doctest || true
working-directory: ./worktree-image/src
./sage -python -m pip install coverage pytest-xdist
./sage -python -m coverage run --rcfile=src/tox.ini -m pytest -c src/tox.ini --doctest-modules || true
working-directory: ./worktree-image
env:
# Increase the length of the lines in the "short summary"
COLUMNS: 120

- name: Test all files (sage -t --all --long)
if: (success() || failure()) && steps.build.outcome == 'success'
run: |
../sage -python -m pip install coverage
../sage -python -m coverage run ./bin/sage-runtests --all --long -p2 --random-seed=286735480429121101562228604801325644303
working-directory: ./worktree-image/src
./sage -python -m pip install coverage
./sage -python -m coverage run --rcfile=src/tox.ini src/bin/sage-runtests --all --long -p2 --format github --random-seed=286735480429121101562228604801325644303
working-directory: ./worktree-image

- name: Prepare coverage results
if: (success() || failure()) && steps.build.outcome == 'success'
run: |
./venv/bin/python3 -m coverage combine src/.coverage/
./venv/bin/python3 -m coverage xml
./sage -python -m coverage combine --rcfile=src/tox.ini
./sage -python -m coverage xml --rcfile=src/tox.ini
mkdir -p coverage-report
mv coverage.xml coverage-report/
working-directory: ./worktree-image

- name: Upload coverage to codecov
if: (success() || failure()) && steps.build.outcome == 'success'
uses: codecov/codecov-action@v3
with:
directory: ./worktree-image/coverage-report
42 changes: 33 additions & 9 deletions .github/workflows/ci-conda-known-test-failures.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
{
"doc.en.constructions.calculus": {
"failed": "unreported random failures in plotting"
},
"sage_setup.clean": {
"failed": true
"failed": "_find_stale_files finds some stale files under sage/tests when executed under conda"
},
"sage.algebras.fusion_rings.fusion_ring": {
"failed": "unreported random timeouts"
},
"sage.combinat.cluster_algebra_quiver.quiver": {
"failed": true
"failed": "failure seen in https://github.com/sagemath/sage/actions/runs/6836592771/job/18591690058#step:11:10059"
},
"sage.geometry.cone": {
"failed": true
"failed": "unreported random timeouts seen in https://github.com/sagemath/sage/actions/runs/6827937663/job/18571052628#step:11:12362"
},
"sage.groups.matrix_gps.finitely_generated_gap": {
"failed": true
Expand All @@ -15,38 +21,56 @@
"failed": true
},
"sage.libs.gap.element": {
"failed": true
"failed": "failure seen in https://github.com/sagemath/sage/actions/runs/6840579851/job/18600012965#step:11:13016"
},
"sage.libs.singular.singular": {
"failed": true
},
"sage.matrix.matrix2": {
"failed": true
"failed": "failure seen in https://github.com/sagemath/sage/actions/runs/6835143781/job/18588599649#step:11:16939"
},
"sage.matrix.matrix_integer_sparse": {
"failed": true
"failed": "failure seen in https://github.com/sagemath/sage/actions/runs/6827937663/job/18571052628#step:11:12362"
},
"sage.misc.lazy_import": {
"failed": true
},
"sage.misc.weak_dict": {
"failed": true
"failed": "failure seen in https://github.com/sagemath/sage/actions/runs/6870325919/job/18684964234#step:11:10059"
},
"sage.modular.modform.l_series_gross_zagier": {
"failed": true
"failed": "unreported failure seen in https://github.com/sagemath/sage/actions/runs/6859244281/job/18651257775#step:11:10102"
},
"sage.parallel.map_reduce": {
"failed": "random failure https://github.com/sagemath/sage/issues/36939"
},
"sage.plot.plot": {
"failed": "unreported random failure (macOS)"
},
"sage.rings.function_field.drinfeld_modules.morphism": {
"failed": true
"failed": "unreported random failure seen in https://github.com/sagemath/sage/actions/runs/6840502530/job/18599835766#step:11:10107"
},
"sage.rings.polynomial.multi_polynomial_ideal": {
"failed": true
},
"sage.rings.polynomial.multi_polynomial_libsingular": {
"failed": true
},
"sage.rings.polynomial.polynomial_element": {
"failed": "unreported random failure in symbolic 'roots' (macOS)"
},
"sage.rings.polynomial.skew_polynomial_finite_field": {
"failed": true
},
"sage.schemes.elliptic_curves.ell_field": {
"failed": "random failure https://github.com/sagemath/sage/issues/36832"
},
"sage.sets.recursively_enumerated_set": {
"failed": "random failures related to AlarmInterrupt (macOS)"
},
"sage.structure.coerce_actions": {
"failed": "random failure https://github.com/sagemath/sage/issues/35973"
},
"sage.tests.gap_packages": {
"failed": true
}
Expand Down
101 changes: 0 additions & 101 deletions .github/workflows/ci-conda.yml

This file was deleted.

2 changes: 2 additions & 0 deletions src/bin/sage-runtests
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ if __name__ == "__main__":
what.add_argument("--installed", action="store_true", default=False, help="test all installed modules of the Sage library")
parser.add_argument("--logfile", type=argparse.FileType('a'), metavar="FILE", help="log all output to FILE")

parser.add_argument("--format", choices=["sage", "github"], default="sage",
help="set format of error messages and warnings")
parser.add_argument("-l", "--long", action="store_true", default=False, help="include lines with the phrase 'long time'")
parser.add_argument("-s", "--short", dest="target_walltime", nargs='?',
type=int, default=-1, const=300, metavar="SECONDS",
Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/words/word.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def Word(data=None, alphabet=None, length=None, datatype=None, caching=True, RSK

Word over a string with a parent::

sage: w = Word("abbabaab", alphabet="abc"); w
sage: w = Word("abbabaab", daslkdlsakdlksaldkasldklsakdlsak, alphabet="abc"); w
word: abbabaab
sage: w.parent()
Finite words over {'a', 'b', 'c'}
Expand Down Expand Up @@ -252,7 +252,7 @@ class FiniteWord_char(WordDatatype_char, FiniteWord_class):
True

sage: w.is_square_free()
False
Falsish
sage: w[:-1].is_square_free()
True

Expand Down
1 change: 1 addition & 0 deletions src/sage/doctest/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def __init__(self, **kwds):
self.show_skipped = False
self.target_walltime = -1
self.baseline_stats_path = None
self.format = "sage"

# sage-runtests contains more optional tags. Technically, adding
# auto_optional_tags here is redundant, since that is added
Expand Down
60 changes: 52 additions & 8 deletions src/sage/doctest/forker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1235,16 +1235,57 @@ def _failure_header(self, test, example, message='Failed example:'):
"""
out = [self.DIVIDER]
with OriginalSource(example):
if test.filename:
if test.lineno is not None and example.lineno is not None:
lineno = test.lineno + example.lineno + 1
if self.options.format == 'sage':
if test.filename:
if test.lineno is not None and example.lineno is not None:
lineno = test.lineno + example.lineno + 1
else:
lineno = '?'
out.append('File "%s", line %s, in %s' %
(test.filename, lineno, test.name))
else:
out.append('Line %s, in %s' % (example.lineno + 1, test.name))
out.append(message)
elif self.options.format == 'github':
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#using-workflow-commands-to-access-toolkit-functions
if message.startswith('Warning: '):
command = f'::warning title={message}'
message = message[len('Warning: '):]
elif self.baseline.get('failed', False):
command = f'::notice title={message}'
message += ' [failed in baseline]'
else:
lineno = '?'
out.append('File "%s", line %s, in %s' %
(test.filename, lineno, test.name))
command = f'::error title={message}'
if extra := getattr(example, 'extra', None):
message += f': {extra}'
if test.filename:
command += f',file={test.filename}'
if test.lineno is not None and example.lineno is not None:
lineno = test.lineno + example.lineno + 1
command += f',line={lineno}'
lineno = None
else:
command += f',line={example.lineno + 1}'
#
# Urlencoding trick for multi-line annotations
# https://github.com/actions/starter-workflows/issues/68#issuecomment-581479448
#
# This only affects the display in the workflow Summary, after clicking "Show more";
# the message needs to be long enough so that "Show more" becomes available.
# https://github.com/actions/toolkit/issues/193#issuecomment-1867084340
#
# Unfortunately, this trick does not make the annotations in the diff view multi-line.
#
if '\n' in message:
message = message.replace('\n', '%0A')
# The actual threshold for "Show more" to appear depends on the window size.
show_more_threshold = 500
if (pad := show_more_threshold - len(message)) > 0:
message += ' ' * pad
command += f'::{message}'
out.append(command)
else:
out.append('Line %s, in %s' % (example.lineno + 1, test.name))
out.append(message)
raise ValueError(f'unknown format option: {self.options.format}')
source = example.source
out.append(doctest._indent(source))
return '\n'.join(out)
Expand Down Expand Up @@ -1417,6 +1458,7 @@ def report_failure(self, out, test, example, got, globs):
"""
if not self.options.initial or self.no_failure_yet:
self.no_failure_yet = False
example.extra = f'Got: {got}'
returnval = doctest.DocTestRunner.report_failure(self, out, test, example, got)
if self.options.debug:
self._fakeout.stop_spoofing()
Expand Down Expand Up @@ -1567,6 +1609,8 @@ def report_unexpected_exception(self, out, test, example, exc_info):
"""
if not self.options.initial or self.no_failure_yet:
self.no_failure_yet = False

example.extra = "Exception raised:\n" + "".join(traceback.format_exception(*exc_info))
returnval = doctest.DocTestRunner.report_unexpected_exception(self, out, test, example, exc_info)
if self.options.debug:
self._fakeout.stop_spoofing()
Expand Down
Loading
Loading