Skip to content

Commit 053d50c

Browse files
Merge branch 'develop' into fix_issue_36833
2 parents 2877712 + e249bef commit 053d50c

File tree

1,459 files changed

+13611
-11210
lines changed

Some content is hidden

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

1,459 files changed

+13611
-11210
lines changed

.ci/create-changes-html.sh

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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+
file_path = os.path.join('$DOC_REPOSITORY', doc)
66+
try:
67+
with open(file_path, 'r') as file:
68+
content = file.readlines()
69+
except FileNotFoundError:
70+
content = []
71+
count = 0
72+
for line in block.splitlines():
73+
if line.startswith('@@ -'):
74+
search_result = re.search(r'@@ -(\d+),(\d+) \+(\d+),(\d+)', line)
75+
if search_result:
76+
line_number = int(search_result.group(3))
77+
for i in range(line_number - 1, -1, -1):
78+
if content[i].startswith('<'):
79+
count += 1
80+
content[i] = f'<span id="hunk{count}" style="visibility: hidden;"></span>' + content[i]
81+
break
82+
if content:
83+
with open(file_path, 'w') as file:
84+
file.writelines(content)
85+
path = 'html/' + doc
86+
hunks = '&nbsp;'.join(f'<a href="{path}#hunk{i+1}" class="hunk" target="_blank">#{i + 1}</a>' for i in range(count))
87+
out_blocks.append(f'<p class="diff"><a href="{path}">{doc}</a>&nbsp;' + hunks + '&emsp;</p>'
88+
+ '\n<pre><code class="language-diff">'
89+
+ html.escape(block).strip() + '</code></pre>')
90+
output_text = '\n'.join(out_blocks)
91+
with open('diff.html', 'w') as f:
92+
f.write(output_text)
93+
EOF
94+
cat diff.html >> CHANGES.html
95+
echo '</body>' >> CHANGES.html
96+
echo '</html>' >> CHANGES.html
97+
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-
git fetch --unshallow --all > /dev/null 2>&1 && echo "Unshallowed."
18-
echo "::group::Merging PR https://github.com/$REPO/pull/$a"
19-
git tag -f test_head
20-
$GH pr checkout -b pr-$a $a
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/sync_labels.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def __init__(self, url, actor):
141141
self._commits = None
142142
self._commit_date = None
143143
self._bot_login = None
144+
self._gh_version = None
144145

145146
s = url.split('/')
146147
self._owner = s[3]
@@ -235,13 +236,30 @@ def bot_login(self):
235236
"""
236237
if self._bot_login:
237238
return self._bot_login
238-
cmd = 'gh auth status'
239239
from subprocess import run
240+
cmd = 'gh version'
241+
capt = run(cmd, shell=True, capture_output=True)
242+
self._gh_version = str(capt.stdout).split('\\n')[0]
243+
info('version: %s' % self._gh_version)
244+
cmd = 'gh auth status'
240245
capt = run(cmd, shell=True, capture_output=True)
241-
l = str(capt.stderr).split()
242-
if not 'as' in l:
243-
l = str(capt.stdout).split()
244-
self._bot_login = l[l.index('as')+1]
246+
errtxt = str(capt.stderr)
247+
outtxt = str(capt.stdout)
248+
debug('auth status err: %s' % errtxt)
249+
debug('auth status out: %s' % outtxt)
250+
def read_login(txt, position_mark):
251+
for t in txt:
252+
for p in position_mark:
253+
# the output text has changed from as to account
254+
# around version 2.40.0
255+
l = t.split()
256+
if p in l:
257+
return l[l.index(p)+1]
258+
self._bot_login = read_login([errtxt, outtxt], ['account', 'as'])
259+
if not self._bot_login:
260+
self._bot_login = default_bot
261+
warning('Bot is unknown')
262+
return self._bot_login
245263
if self._bot_login.endswith('[bot]'):
246264
self._bot_login = self._bot_login.split('[bot]')[0]
247265
info('Bot is %s' % self._bot_login)

.github/workflows/build.yml

Lines changed: 1 addition & 0 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
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"sage_setup.clean": {
3+
"failed": true
4+
},
5+
"sage.combinat.cluster_algebra_quiver.quiver": {
6+
"failed": true
7+
},
8+
"sage.geometry.cone": {
9+
"failed": true
10+
},
11+
"sage.groups.matrix_gps.finitely_generated_gap": {
12+
"failed": true
13+
},
14+
"sage.interfaces.expect": {
15+
"failed": true
16+
},
17+
"sage.libs.gap.element": {
18+
"failed": true
19+
},
20+
"sage.libs.singular.singular": {
21+
"failed": true
22+
},
23+
"sage.matrix.matrix2": {
24+
"failed": true
25+
},
26+
"sage.matrix.matrix_integer_sparse": {
27+
"failed": true
28+
},
29+
"sage.misc.lazy_import": {
30+
"failed": true
31+
},
32+
"sage.misc.weak_dict": {
33+
"failed": true
34+
},
35+
"sage.modular.modform.l_series_gross_zagier": {
36+
"failed": true
37+
},
38+
"sage.rings.function_field.drinfeld_modules.morphism": {
39+
"failed": true
40+
},
41+
"sage.rings.polynomial.multi_polynomial_ideal": {
42+
"failed": true
43+
},
44+
"sage.rings.polynomial.multi_polynomial_libsingular": {
45+
"failed": true
46+
},
47+
"sage.rings.polynomial.skew_polynomial_finite_field": {
48+
"failed": true
49+
},
50+
"sage.tests.gap_packages": {
51+
"failed": true
52+
}
53+
}

0 commit comments

Comments
 (0)