Skip to content

Commit e81a91c

Browse files
authored
Merge branch 'develop' into fix-documentation-grammar
2 parents 9a35e41 + e2e0f8d commit e81a91c

File tree

2,090 files changed

+27928
-20036
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,090 files changed

+27928
-20036
lines changed

.ci/create-changes-html.sh

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/bin/sh
2+
if [ $# != 2 ]; then
3+
echo >&2 "usage: $0 BASE_DOC_COMMIT DOC_REPO"
4+
echo >&2 "creates CHANGES.html in the current directory"
5+
echo >&2 "for the diffs of DOC_REPO against BASE_DOC_COMMIT"
6+
exit 1
7+
fi
8+
BASE_DOC_COMMIT="$1"
9+
DOC_REPOSITORY="$2"
10+
11+
# Wipe out chronic diffs between old doc and new doc
12+
(cd $DOC_REPOSITORY && find . -name "*.html" | xargs sed -i -e '\;<script type="application/vnd\.jupyter\.widget-state+json">;,\;</script>; d')
13+
# Create CHANGES.html
14+
echo '<html>' > CHANGES.html
15+
echo '<head>' >> CHANGES.html
16+
echo '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">' >> CHANGES.html
17+
echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>' >> CHANGES.html
18+
echo '<script>hljs.highlightAll();</script>' >> CHANGES.html
19+
cat >> CHANGES.html << EOF
20+
<script>
21+
document.addEventListener('DOMContentLoaded', () => {
22+
const diffSite = 'https://pianomister.github.io/diffsite'
23+
const baseDocURL = 'https://sagemath-tobias.netlify.app'
24+
const diffParagraphs = document.querySelectorAll('p.diff');
25+
diffParagraphs.forEach(paragraph => {
26+
const rootURL = window.location.origin;
27+
const docAnchor = paragraph.querySelector('a'); // first "a" element
28+
const url = new URL(docAnchor.href);
29+
const path = url.pathname;
30+
const anchor = document.createElement('a');
31+
anchor.href = diffSite + '/?url1=' + rootURL + path + '&url2=' + baseDocURL + path;
32+
anchor.textContent = 'compare with the base';
33+
anchor.setAttribute('target', '_blank');
34+
paragraph.appendChild(anchor);
35+
paragraph.innerHTML += '&nbsp;';
36+
const hunkAnchors = paragraph.querySelectorAll('a.hunk');
37+
hunkAnchors.forEach(hunkAnchor => {
38+
const url = new URL(hunkAnchor.href);
39+
const path = url.pathname;
40+
const pathHash = path + url.hash.replace('#', '%23');
41+
const anchor = document.createElement('a');
42+
anchor.href = diffSite + '/?url1=' + rootURL + pathHash + '&url2=' + baseDocURL + path;
43+
anchor.textContent = hunkAnchor.textContent;
44+
anchor.setAttribute('target', '_blank');
45+
paragraph.appendChild(anchor);
46+
paragraph.innerHTML += '&nbsp;';
47+
});
48+
});
49+
});
50+
</script>
51+
EOF
52+
echo '</head>' >> CHANGES.html
53+
echo '<body>' >> CHANGES.html
54+
(cd $DOC_REPOSITORY && git diff $BASE_DOC_COMMIT -- *.html) > diff.txt
55+
python3 - << EOF
56+
import os, re, html
57+
with open('diff.txt', 'r') as f:
58+
diff_text = f.read()
59+
diff_blocks = re.split(r'^(?=diff --git)', diff_text, flags=re.MULTILINE)
60+
out_blocks = []
61+
for block in diff_blocks:
62+
match = re.search(r'^diff --git a/(.*) b/\1', block, flags=re.MULTILINE)
63+
if match:
64+
doc = match.group(1)
65+
path = 'html/' + doc
66+
file_path = os.path.join('$DOC_REPOSITORY', doc)
67+
with open(file_path, 'r') as file:
68+
content = file.readlines()
69+
count = 0
70+
for line in block.splitlines():
71+
if line.startswith('@@ -'):
72+
line_number = int(re.search(r'@@ -(\d+)', line).group(1))
73+
for i in range(line_number, -1, -1):
74+
if content[i].startswith('<'):
75+
count += 1
76+
content[i] = f'<span id="hunk{count}" style="visibility: hidden;"></span>' + content[i]
77+
break
78+
with open(file_path, 'w') as file:
79+
file.writelines(content)
80+
hunks = '&nbsp;'.join(f'<a href="{path}#hunk{i+1}" class="hunk" target="_blank">#{i + 1}</a>' for i in range(count))
81+
out_blocks.append(f'<p class="diff"><a href="{path}">{doc}</a>&nbsp;' + hunks + '&emsp;</p>'
82+
+ '\n<pre><code class="language-diff">'
83+
+ html.escape(block).strip() + '</code></pre>')
84+
output_text = '\n'.join(out_blocks)
85+
with open('diff.html', 'w') as f:
86+
f.write(output_text)
87+
EOF
88+
cat diff.html >> CHANGES.html
89+
echo '</body>' >> CHANGES.html
90+
echo '</html>' >> CHANGES.html
91+
rm diff.txt diff.html

.ci/describe-system.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

.ci/merge-fixes.sh

Lines changed: 79 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,82 @@
11
#!/bin/sh
2-
# Merge open PRs from sagemath/sage labeled "blocker".
3-
REPO="sagemath/sage"
4-
GH="gh -R $REPO"
5-
PRs="$($GH pr list --label "p: blocker / 1" --json number --jq '.[].number')"
6-
if [ -z "$PRs" ]; then
7-
echo 'Nothing to do: Found no open PRs with "blocker" status.'
8-
else
9-
echo "Found PRs: " $PRs
10-
export GIT_AUTHOR_NAME="ci-sage workflow"
11-
export GIT_AUTHOR_EMAIL="[email protected]"
12-
export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
13-
export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
14-
git tag -f test_base
15-
git commit -q -m "Uncommitted changes" --no-allow-empty -a
16-
for a in $PRs; do
17-
echo "::group::Merging PR https://github.com/$REPO/pull/$a"
18-
git tag -f test_head
19-
$GH pr checkout -b pr-$a $a
20-
git fetch --unshallow --all
21-
git checkout -q test_head
22-
if git merge --no-edit --squash -q pr-$a; then
23-
echo "::endgroup::"
24-
if git commit -q -m "Merge https://github.com/$REPO/pull/$a" -a --no-allow-empty; then
25-
echo "Merged #$a"
2+
# Apply open PRs labeled "blocker" from sagemath/sage as patches.
3+
# This script is invoked by various workflows in .github/workflows
4+
#
5+
# The repository variable SAGE_CI_FIXES_FROM_REPOS can be set
6+
# to customize this for CI runs in forks:
7+
#
8+
# - If set to a whitespace-separated list of repositories, use them instead of sagemath/sage.
9+
# - If set to "none", do not apply any PRs.
10+
#
11+
# https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository
12+
export GIT_AUTHOR_NAME="ci-sage workflow"
13+
export GIT_AUTHOR_EMAIL="[email protected]"
14+
export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
15+
export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
16+
mkdir -p upstream
17+
for REPO in ${SAGE_CI_FIXES_FROM_REPOSITORIES:-sagemath/sage}; do
18+
case $REPO in
19+
none)
20+
echo "Nothing to do for 'none' in SAGE_CI_FIXES_FROM_REPOSITORIES"
21+
;;
22+
*/*)
23+
echo "Getting open PRs with 'blocker' status from https://github.com/$REPO/pulls?q=is%3Aopen+label%3A%22p%3A+blocker+%2F+1%22"
24+
GH="gh -R $REPO"
25+
REPO_FILE="upstream/ci-fixes-${REPO%%/*}-${REPO##*/}"
26+
PRs="$($GH pr list --label "p: blocker / 1" --json number --jq '.[].number' | tee $REPO_FILE)"
27+
date -u +"%Y-%m-%dT%H:%M:%SZ" > $REPO_FILE.date # Record the date, for future reference
28+
if [ -z "$PRs" ]; then
29+
echo "Nothing to do: Found no open PRs with 'blocker' status in $REPO."
2630
else
27-
echo "Empty, skipped"
31+
echo "Found open PRs with 'blocker' status in $REPO: $(echo $PRs)"
32+
git tag -f test_base
33+
git commit -q -m "Uncommitted changes" --no-allow-empty -a
34+
for a in $PRs; do
35+
# We used to pull the branch and merge it (after unshallowing), but when run on PRs that are
36+
# based on older releases, it has the side effect of updating to this release,
37+
# which may be confusing.
38+
#
39+
# Here, we obtain the "git am"-able patch of the PR branch.
40+
# This also makes it unnecessary to unshallow the repository.
41+
#
42+
# Considered alternative: Use https://github.com/$REPO/pull/$a.diff,
43+
# which squashes everything into one diff without commit metadata.
44+
PULL_URL="https://github.com/$REPO/pull/$a"
45+
PULL_FILE="$REPO_FILE-$a"
46+
PATH=build/bin:$PATH build/bin/sage-download-file --quiet "$PULL_URL.patch" $PULL_FILE.patch
47+
date -u +"%Y-%m-%dT%H:%M:%SZ" > $PULL_FILE.date # Record the date, for future reference
48+
LAST_SHA=$(sed -n -E '/^From [0-9a-f]{40}/s/^From ([0-9a-f]{40}).*/\1/p' $PULL_FILE.patch | tail -n 1)
49+
COMMITS_URL="https://github.com/$REPO/commits/$LAST_SHA"
50+
echo "::group::Applying PR $PULL_URL @ $COMMITS_URL as a patch"
51+
export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME applying $PULL_URL @ $COMMITS_URL"
52+
if git am --signoff --empty=keep < $PULL_FILE.patch; then
53+
echo "---- Applied patch --------------------------------------------------------------------------------"
54+
cat $PULL_FILE.patch
55+
echo "--------------------------------------------------------------------8<-----------------------------"
56+
echo "::endgroup::"
57+
elif git am --abort \
58+
&& if git fetch --unshallow --all > /dev/null 2>&1; then echo "Unshallowed"; fi \
59+
&& echo "Retrying with 3-way merge" \
60+
&& git am --empty=keep --3way < $PULL_FILE.patch; then
61+
echo "---- Applied patch --------------------------------------------------------------------------------"
62+
cat $PULL_FILE.patch
63+
echo "--------------------------------------------------------------------8<-----------------------------"
64+
echo "::endgroup::"
65+
else
66+
echo "---- Failure applying patch -----------------------------------------------------------------------"
67+
git am --signoff --show-current-patch=diff
68+
echo "--------------------------------------------------------------------8<-----------------------------"
69+
echo "::endgroup::"
70+
echo "Failure applying $PULL_URL as a patch, resetting"
71+
git am --signoff --abort
72+
fi
73+
done
2874
fi
29-
else
30-
echo "::endgroup::"
31-
echo "Failure merging #$a, resetting"
32-
git reset --hard
33-
fi
34-
done
35-
git log test_base..HEAD
36-
fi
75+
;;
76+
*)
77+
echo "Repository variable SAGE_CI_FIXES_FROM_REPOSITORIES, if set, should be a whitespace-separated list of repositories or 'none'"
78+
echo "Got: $SAGE_CI_FIXES_FROM_REPOSITORIES"
79+
exit 1
80+
;;
81+
esac
82+
done

.ci/protect-secrets.sh

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
.ci/merge-fixes.sh
3939
env:
4040
GH_TOKEN: ${{ github.token }}
41+
SAGE_CI_FIXES_FROM_REPOSITORIES: ${{ vars.SAGE_CI_FIXES_FROM_REPOSITORIES }}
4142
- name: Store CI fixes in upstream artifact
4243
run: |
4344
mkdir -p upstream
@@ -96,15 +97,15 @@ jobs:
9697
SAGE_NUM_THREADS: 2
9798

9899
- name: Build modularized distributions
99-
if: always() && steps.worktree.outcome == 'success'
100+
if: (success() || failure()) && steps.worktree.outcome == 'success'
100101
run: make V=0 tox && make SAGE_CHECK=no pypi-wheels
101102
working-directory: ./worktree-image
102103
env:
103104
MAKE: make -j2 --output-sync=recurse
104105
SAGE_NUM_THREADS: 2
105106

106107
- name: Static code check with pyright
107-
if: always() && steps.worktree.outcome == 'success'
108+
if: (success() || failure()) && steps.worktree.outcome == 'success'
108109
uses: jakebailey/pyright-action@v1
109110
with:
110111
version: 1.1.332
@@ -116,7 +117,7 @@ jobs:
116117
NODE_OPTIONS: --max-old-space-size=8192
117118

118119
- name: Static code check with pyright (annotated)
119-
if: always() && steps.worktree.outcome == 'success'
120+
if: (success() || failure()) && steps.worktree.outcome == 'success'
120121
uses: jakebailey/pyright-action@v1
121122
with:
122123
version: 1.1.332
@@ -130,7 +131,7 @@ jobs:
130131

131132
- name: Clean (fallback to non-incremental)
132133
id: clean
133-
if: always() && steps.worktree.outcome == 'success' && steps.incremental.outcome != 'success'
134+
if: (success() || failure()) && steps.worktree.outcome == 'success' && steps.incremental.outcome != 'success'
134135
run: |
135136
set -ex
136137
./bootstrap && make doc-clean doc-uninstall sagelib-clean && git clean -fx src/sage && ./config.status
@@ -143,7 +144,7 @@ jobs:
143144
# This step is needed because building the modularized distributions installs some optional packages,
144145
# so the editable install of sagelib needs to build the corresponding optional extension modules.
145146
id: build
146-
if: always() && (steps.incremental.outcome == 'success' || steps.clean.outcome == 'success')
147+
if: (success() || failure()) && (steps.incremental.outcome == 'success' || steps.clean.outcome == 'success')
147148
run: |
148149
make build
149150
working-directory: ./worktree-image
@@ -154,7 +155,7 @@ jobs:
154155
# Testing
155156

156157
- name: Test changed files (sage -t --new)
157-
if: always() && steps.build.outcome == 'success'
158+
if: (success() || failure()) && steps.build.outcome == 'success'
158159
run: |
159160
# We run tests with "sage -t --new"; this only tests the uncommitted changes.
160161
./sage -t --new -p2
@@ -164,7 +165,7 @@ jobs:
164165
SAGE_NUM_THREADS: 2
165166

166167
- name: Test modularized distributions
167-
if: always() && steps.build.outcome == 'success'
168+
if: (success() || failure()) && steps.build.outcome == 'success'
168169
run: make V=0 tox && make pypi-wheels-check
169170
working-directory: ./worktree-image
170171
env:
@@ -182,22 +183,23 @@ jobs:
182183
COLUMNS: 120
183184

184185
- name: Test all files (sage -t --all --long)
185-
if: always() && steps.build.outcome == 'success'
186+
if: (success() || failure()) && steps.build.outcome == 'success'
186187
run: |
187188
../sage -python -m pip install coverage
188189
../sage -python -m coverage run ./bin/sage-runtests --all --long -p2 --random-seed=286735480429121101562228604801325644303
189190
working-directory: ./worktree-image/src
190191

191192
- name: Prepare coverage results
192-
if: always() && steps.build.outcome == 'success'
193+
if: (success() || failure()) && steps.build.outcome == 'success'
193194
run: |
194195
./venv/bin/python3 -m coverage combine src/.coverage/
195196
./venv/bin/python3 -m coverage xml
196-
find . -name *coverage*
197+
mkdir -p coverage-report
198+
mv coverage.xml coverage-report/
197199
working-directory: ./worktree-image
198200

199201
- name: Upload coverage to codecov
200-
if: always() && steps.build.outcome == 'success'
202+
if: (success() || failure()) && steps.build.outcome == 'success'
201203
uses: codecov/codecov-action@v3
202204
with:
203-
files: ./worktree-image/coverage.xml
205+
directory: ./worktree-image/coverage-report

.github/workflows/ci-conda.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ jobs:
2121
runs-on: ${{ matrix.os }}
2222

2323
strategy:
24-
fail-fast: ${{ github.event_name == 'pull_request' }}
25-
max-parallel: ${{ github.event_name == 'pull_request' && 2 || 6 }}
2624
matrix:
2725
os: [ubuntu-latest, macos-latest]
2826
python: ['3.9', '3.10', '3.11']
@@ -38,6 +36,7 @@ jobs:
3836
.ci/merge-fixes.sh
3937
env:
4038
GH_TOKEN: ${{ github.token }}
39+
SAGE_CI_FIXES_FROM_REPOSITORIES: ${{ vars.SAGE_CI_FIXES_FROM_REPOSITORIES }}
4140

4241
- name: Create conda environment files
4342
run: ./bootstrap-conda

0 commit comments

Comments
 (0)