Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Dec 21, 2023
1 parent d52858c commit 1849493
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 195 deletions.
80 changes: 2 additions & 78 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 All @@ -154,52 +121,9 @@ jobs:

# Testing

- name: Test changed files (sage -t --new)
if: (success() || failure()) && steps.build.outcome == 'success'
run: |
# We run tests with "sage -t --new"; this only tests the uncommitted changes.
./sage -t --new -p2
working-directory: ./worktree-image
env:
MAKE: make -j2 --output-sync=recurse
SAGE_NUM_THREADS: 2

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

- 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-modules || true
working-directory: ./worktree-image/src
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

- 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
mkdir -p coverage-report
mv coverage.xml coverage-report/
./sage -python -m pip install coverage
./sage -python -m coverage run ./src/bin/sage-runtests --format github --baseline-stats-path=.github/workflows/ci-conda-known-test-failures.json -p4 --random-seed=286735480429121101562228604801325644303 src/sage/combinat/words src/sage/plot/plot.py src/sage_setup/clean.py
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
104 changes: 0 additions & 104 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 @@ -148,7 +148,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

Check failure on line 151 in src/sage/combinat/words/word.py

View workflow job for this annotation

GitHub Actions / build

Failed example:

Failed example:: Exception raised: 'Traceback (most recent call last):\n File "/sage/src/sage/doctest/forker.py", line 712, in _run\n self.compile_and_execute(example, compiler, test.globs)\n File "/sage/src/sage/doctest/forker.py", line 1147, in compile_and_execute\n exec(compiled, globs)\n File "<doctest sage.combinat.words.word.Word[18]>", line 1, in <module>\n w = Word("abbabaab", daslkdlsakdlksaldkasldklsakdlsak, alphabet="abc"); w\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nNameError: name \'daslkdlsakdlksaldkasldklsakdlsak\' is not defined\n'
word: abbabaab
sage: w.parent()

Check failure on line 153 in src/sage/combinat/words/word.py

View workflow job for this annotation

GitHub Actions / build

Failed example:

Failed example:: Exception raised: 'Traceback (most recent call last):\n File "/sage/src/sage/doctest/forker.py", line 712, in _run\n self.compile_and_execute(example, compiler, test.globs)\n File "/sage/src/sage/doctest/forker.py", line 1147, in compile_and_execute\n exec(compiled, globs)\n File "<doctest sage.combinat.words.word.Word[19]>", line 1, in <module>\n w.parent()\n ^\nNameError: name \'w\' is not defined\n'
Finite words over {'a', 'b', 'c'}
Expand Down Expand Up @@ -253,7 +253,7 @@ class FiniteWord_char(WordDatatype_char, FiniteWord_class):
True
sage: w.is_square_free()

Check failure on line 255 in src/sage/combinat/words/word.py

View workflow job for this annotation

GitHub Actions / build

Failed example:

Failed example:: Got: 'False\n'
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
47 changes: 37 additions & 10 deletions src/sage/doctest/forker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1235,16 +1235,40 @@ 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
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)
match self.options.format:
case '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)
case '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:
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}'
command += f'::{message}'
out.append(command)
source = example.source
out.append(doctest._indent(source))
return '\n'.join(out)
Expand Down Expand Up @@ -1417,6 +1441,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!r}'
returnval = doctest.DocTestRunner.report_failure(self, out, test, example, got)
if self.options.debug:
self._fakeout.stop_spoofing()
Expand Down Expand Up @@ -1567,6 +1592,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: " + repr("".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
2 changes: 1 addition & 1 deletion src/sage_setup/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _find_stale_files(site_packages, python_packages, python_modules, ext_module
sage: stale_iter = _find_stale_files(SAGE_LIB, python_packages, python_modules, [], extra_files)
sage: from importlib.machinery import EXTENSION_SUFFIXES
sage: skip_extensions = tuple(EXTENSION_SUFFIXES)
sage: for f in stale_iter:
sage: for f in stale_iter:dxfcgvhbjkl;,mkjnbhgvcfgvhbjnkml,

Check notice on line 104 in src/sage_setup/clean.py

View workflow job for this annotation

GitHub Actions / build

Failed example:

Failed example: [failed in baseline]: Exception raised: 'Traceback (most recent call last):\n File "/sage/src/sage/doctest/forker.py", line 712, in _run\n self.compile_and_execute(example, compiler, test.globs)\n File "/sage/src/sage/doctest/forker.py", line 1145, in compile_and_execute\n compiled = compiler(example)\n ^^^^^^^^^^^^^^^^^\n File "/sage/src/sage/doctest/forker.py", line 679, in compiler\n code = compile(example.source, filename, "single",\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "<doctest sage_setup.clean._find_stale_files[13]>", line 1\n for f in stale_iter:dxfcgvhbjkl;,mkjnbhgvcfgvhbjnkml,\n ^\nSyntaxError: invalid syntax\n'
....: if f.endswith(skip_extensions): continue
....: if '/ext_data/' in f: continue
....: print('Found stale file: ' + f)
Expand Down

0 comments on commit 1849493

Please sign in to comment.