Skip to content

Commit

Permalink
Merge branch 'doctester-github-annotations--prod' into ci_build_expli…
Browse files Browse the repository at this point in the history
…cit_docker_exec
  • Loading branch information
mkoeppe committed Jan 5, 2024
2 parents 3b835a4 + 4ecf7ca commit 9de2dea
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ jobs:
run: |
export MAKE="make -j2 --output-sync=recurse" SAGE_NUM_THREADS=2
# We run tests with "sage -t --new"; this only tests the uncommitted changes.
<<<<<<< HEAD
./sage -t --new -p2 --format github
shell: sh .ci/docker-exec-script.sh BUILD /sage {0}

Expand Down Expand Up @@ -166,6 +167,10 @@ jobs:
# so that multi-stage builds can work correctly.
run: |
.ci/merge-fixes.sh
=======
./sage -t --new -p2
working-directory: ./worktree-image
>>>>>>> doctester-github-annotations--prod
env:
GH_TOKEN: ${{ github.token }}

Expand Down Expand Up @@ -213,6 +218,7 @@ jobs:

- name: Test modularized distributions
run: |
<<<<<<< HEAD
export MAKE="make -j2 --output-sync=recurse" SAGE_NUM_THREADS=2
make V=0 tox-ensure && make ${{ matrix.targets }}
shell: sh .ci/docker-exec-script.sh BUILD /sage {0}
Expand Down Expand Up @@ -253,6 +259,11 @@ jobs:
# so that multi-stage builds can work correctly.
run: |
.ci/merge-fixes.sh
=======
./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
>>>>>>> doctester-github-annotations--prod
env:
GH_TOKEN: ${{ github.token }}

Expand Down Expand Up @@ -301,14 +312,17 @@ jobs:

- name: Test all files (sage -t --all --long)
run: |
./sage -tox -e coverage.py-xml -- --all --long -p2 --format github --random-seed=286735480429121101562228604801325644303
./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
shell: sh .ci/docker-exec-script.sh BUILD /sage {0}

- name: Copy coverage results
if: (success() || failure()) && steps.container.outcome == 'success'
run: |
mkdir -p ${{ github.workspace }}/coverage-report
cp src/.tox/sagedirect/coverage.xml ${{ github.workspace }}/coverage-report/
./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/
shell: sh .ci/docker-exec-script.sh BUILD /sage {0}

- name: Upload coverage to codecov
Expand Down
20 changes: 18 additions & 2 deletions src/sage/doctest/forker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,22 @@ def _failure_header(self, test, example, message='Failed example:'):
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:
Expand Down Expand Up @@ -1442,7 +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!r}'
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 @@ -1594,7 +1610,7 @@ 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)))
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
4 changes: 4 additions & 0 deletions src/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,7 @@ source = sage
concurrency = multiprocessing
data_file = .coverage/.coverage
disable_warnings = no-data-collected
[coverage:report]
ignore_errors = True
skip_empty = True

0 comments on commit 9de2dea

Please sign in to comment.