Skip to content

Commit ca989cf

Browse files
author
Release Manager
committed
sagemathgh-39641: CI: Migrate test-new to meson <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Migrates the `test-new` workflow to use Meson. The Meson build system rebuilds faster and leverages standard tools like `ccache` for caching Cython file compilation. The github workflow is also considerably easier to read and maintain now. To ensure reliability, pushing the Docker image in the build workflow has been disabled, as it was continuously clogging the GitHub cache (limited to 10GB, while each cached image consumes several gigabytes). This change also resolves intermittent workflow failures caused by unsuccessful image pushes. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [ ] The title is concise and informative. - [ ] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39641 Reported by: Tobias Diez Reviewer(s): Tobias Diez, user202729
2 parents 70cbadf + 87caf60 commit ca989cf

File tree

2 files changed

+34
-190
lines changed

2 files changed

+34
-190
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -76,190 +76,8 @@ env:
7676
EXTRA_CONFIGURE_ARGS: --enable-fat-binary
7777

7878
jobs:
79-
test-new:
80-
runs-on: ubuntu-latest
81-
outputs:
82-
build_targets: ${{ steps.build-targets.outputs.build_targets }}
83-
services:
84-
# https://docs.docker.com/build/ci/github-actions/local-registry/
85-
registry:
86-
image: registry:2
87-
ports:
88-
- 5000:5000
89-
steps:
90-
- name: Maximize build disk space
91-
uses: easimon/maximize-build-space@v10
92-
with:
93-
# need space in /var for Docker images
94-
root-reserve-mb: 30000
95-
remove-dotnet: true
96-
remove-android: true
97-
remove-haskell: true
98-
remove-codeql: true
99-
remove-docker-images: true
100-
101-
- name: Checkout
102-
id: checkout
103-
uses: actions/checkout@v4
104-
105-
- name: Get changed files and packages
106-
id: changed-files
107-
uses: tj-actions/changed-files@v46
108-
with:
109-
# File extensions for doctests per sage.doctest.control.skipfile
110-
# Also src/sage/doctests/tests/ are excluded because of nodoctest file
111-
# which would make sage.doctest.control.skipdir return True
112-
files_yaml: |
113-
configures:
114-
- 'build/pkgs/*/spkg-configure.m4'
115-
pkgs:
116-
- 'build/pkgs/**'
117-
- '!build/pkgs/_**'
118-
- '!build/pkgs/configure/**'
119-
- 'pkgs/**'
120-
doctests:
121-
- 'src/**/*.{py,pyx,pxd,pxi,sage,spyx,rst,tex}'
122-
- '!src/{setup,conftest*}.py'
123-
- '!src/sage/doctest/tests/*'
124-
125-
- name: Determine targets to build
126-
id: build-targets
127-
run: |
128-
uninstall_targets=$(echo $(
129-
for a in '' ${{ steps.changed-files.outputs.configures_all_changed_files }}; do
130-
# Extract package name from the file path and append '-uninstall'
131-
echo $a | sed -E 's,build/pkgs/([a-z0-9][_.a-z0-9]*)/spkg-configure[.]m4 *,\1-uninstall,'
132-
done | sort -u # Sort and ensure uniqueness
133-
))
134-
build_targets=$(echo $(
135-
for a in '' ${{ steps.changed-files.outputs.pkgs_all_changed_files }}; do
136-
# Extract package name, replace '-' with '_', and strip extra parts from the path
137-
SPKG=$(echo $a | sed -E 's,-,_,g;s,(build/)?pkgs/([a-z0-9][-_.a-z0-9]*)/[^ ]* *,\2,;')
138-
# Check if key files exist in the package directory
139-
if [ -f "build/pkgs/$SPKG/checksums.ini" ] || \
140-
[ -f "build/pkgs/$SPKG/requirements.txt" ] || \
141-
[ -f "build/pkgs/$SPKG/spkg-install" ]; then
142-
echo "$SPKG-ensure" # add the "$SPKG-ensure" target
143-
fi
144-
done | sort -u # Sort and ensure uniqueness
145-
))
146-
if [ -n "$uninstall_targets" ]; then
147-
echo "build_targets=$uninstall_targets reconfigure $build_targets ci-build-with-fallback" >> $GITHUB_OUTPUT
148-
else
149-
echo "build_targets=$build_targets ci-build-with-fallback" >> $GITHUB_OUTPUT
150-
fi
151-
cat $GITHUB_OUTPUT
152-
153-
- uses: actions/checkout@v4
154-
with:
155-
ref: ${{ github.base_ref }}
156-
path: worktree-base
157-
if: github.base_ref && steps.changed-files.outputs.pkgs_all_changed_files
158-
159-
- name: Compute metrics
160-
run: |
161-
export PATH=build/bin:$PATH
162-
if [ -d worktree-base ]; then
163-
(echo "# $GITHUB_BASE_REF"; SAGE_ROOT=worktree-base sage-package metrics :all:) > base-metrics.txt
164-
(echo "# $GITHUB_REF"; sage-package metrics :all:) > metrics.txt
165-
diff --color=always --width=100 --side-by-side --left-column base-metrics.txt metrics.txt || true
166-
else
167-
sage-package metrics :all:
168-
fi
169-
170-
- name: Install test prerequisites
171-
# From docker.yml
172-
run: |
173-
sudo DEBIAN_FRONTEND=noninteractive apt-get update
174-
sudo DEBIAN_FRONTEND=noninteractive apt-get install tox
175-
sudo apt-get clean
176-
df -h
177-
178-
- name: Merge CI fixes from sagemath/sage
179-
# From docker.yml
180-
# This step needs to happen after the commit sha is put in DOCKER_TAG
181-
# so that multi-stage builds can work correctly.
182-
run: |
183-
mkdir -p upstream
184-
.ci/merge-fixes.sh 2>&1 | tee upstream/ci_fixes.log
185-
env:
186-
GH_TOKEN: ${{ github.token }}
187-
SAGE_CI_FIXES_FROM_REPOSITORIES: ${{ vars.SAGE_CI_FIXES_FROM_REPOSITORIES }}
188-
189-
# Building
190-
191-
- name: Generate Dockerfile
192-
# From docker.yml
193-
run: |
194-
tox -e ${{ env.TOX_ENV }}
195-
cp .tox/${{ env.TOX_ENV }}/Dockerfile .
196-
env:
197-
# Only generate the Dockerfile, do not run 'docker build' here
198-
DOCKER_TARGETS: ""
199-
200-
- name: Set up Docker Buildx
201-
uses: docker/setup-buildx-action@v3
202-
with:
203-
driver-opts: network=host
204-
205-
- name: Build Docker image
206-
id: image
207-
uses: docker/build-push-action@v6
208-
with:
209-
# push and load may not be set together at the moment
210-
#
211-
# We are using "push" (to the local registry) because it was
212-
# more reliable than "load", for which we observed random failure
213-
# conditions in which the built image could not be found.
214-
#
215-
push: ${{ steps.changed-files.outputs.doctests_all_changed_files && true || false }}
216-
load: false
217-
context: .
218-
tags: ${{ env.BUILD_IMAGE }}
219-
target: with-targets
220-
cache-from: type=gha
221-
cache-to: type=gha,mode=max
222-
build-args: |
223-
NUMPROC=6
224-
USE_MAKEFLAGS=-k V=0 SAGE_NUM_THREADS=4 --output-sync=recurse
225-
TARGETS_PRE=build/make/Makefile
226-
TARGETS=${{ steps.build-targets.outputs.build_targets }}
227-
228-
- name: Start container
229-
id: container
230-
# Try to continue when "exporting to GitHub Actions Cache" failed with timeout
231-
if: (success() || failure()) && steps.changed-files.outputs.doctests_all_changed_files
232-
run: |
233-
docker run --name BUILD -dit \
234-
--mount type=bind,src=$(pwd),dst=$(pwd) \
235-
--workdir $(pwd) \
236-
${{ env.BUILD_IMAGE }} /bin/sh
237-
238-
# Testing
239-
240-
- name: Check that all modules can be imported
241-
if: (success() || failure()) && steps.container.outcome == 'success' && steps.changed-files.outputs.doctests_all_changed_files
242-
run: |
243-
# Increase the length of the lines in the "short summary"
244-
export COLUMNS=120
245-
# The following command checks that all modules can be imported.
246-
# The output also includes a long list of modules together with the number of tests in each module.
247-
# This can be ignored.
248-
./sage -python -m pip install pytest-xdist
249-
./sage -python -m pytest -c tox.ini -qq --doctest --collect-only || true
250-
shell: sh .ci/docker-exec-script.sh BUILD /sage {0}
251-
252-
- name: Test changed files
253-
if: (success() || failure()) && steps.container.outcome == 'success' && steps.changed-files.outputs.doctests_all_changed_files
254-
run: |
255-
export MAKE="make -j2 --output-sync=recurse" SAGE_NUM_THREADS=4
256-
# https://github.com/tj-actions/changed-files?tab=readme-ov-file#outputs-
257-
./sage -t --long --format github -p4 ${{ steps.changed-files.outputs.doctests_all_changed_files }}
258-
shell: sh .ci/docker-exec-script.sh BUILD /sage {0}
259-
26079
test-long:
26180
runs-on: ubuntu-latest
262-
needs: [test-new]
26381
services:
26482
# https://docs.docker.com/build/ci/github-actions/local-registry/
26583
registry:
@@ -334,8 +152,6 @@ jobs:
334152
context: .
335153
tags: ${{ env.BUILD_IMAGE }}
336154
target: with-targets
337-
cache-from: type=gha
338-
cache-to: type=gha,mode=max
339155
build-args: |
340156
NUMPROC=6
341157
USE_MAKEFLAGS=-k V=0 SAGE_NUM_THREADS=4 --output-sync=recurse
@@ -454,8 +270,6 @@ jobs:
454270
context: .
455271
tags: ${{ env.BUILD_IMAGE }}
456272
target: with-targets
457-
cache-from: type=gha
458-
cache-to: type=gha,mode=max
459273
build-args: |
460274
NUMPROC=6
461275
USE_MAKEFLAGS=-k V=0 SAGE_NUM_THREADS=4 --output-sync=recurse

.github/workflows/ci-meson.yml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,31 @@ concurrency:
1414
group: ${{ github.workflow }}-${{ github.ref }}
1515
cancel-in-progress: true
1616

17+
permissions:
18+
contents: read
19+
1720
jobs:
1821
test:
19-
name: Conda (${{ matrix.os }}, Python ${{ matrix.python }}${{ matrix.editable && ', editable' || '' }})
22+
name: Conda (${{ matrix.os }}, Python ${{ matrix.python }}, ${{ matrix.tests }}${{ matrix.editable && ', editable' || '' }})
2023
runs-on: ${{ matrix.os }}-latest
2124

2225
strategy:
2326
fail-fast: false
2427
matrix:
25-
os: [ubuntu, macos]
28+
os: ['ubuntu', 'macos']
2629
python: ['3.11', '3.12']
30+
tests: ['all']
2731
editable:
2832
${{ fromJson(github.event_name == 'pull_request' && '[false]' || '[false, true]') }}
2933
include:
34+
- os: 'ubuntu'
35+
python: '3.12'
36+
tests: 'new'
3037
# one additional editable run in pull_request, this has no effect if not pull_request
31-
- os: ubuntu
38+
- os: 'ubuntu'
3239
python: 3.12
3340
editable: true
41+
tests: 'all'
3442

3543
steps:
3644
- uses: actions/checkout@v4
@@ -41,6 +49,17 @@ jobs:
4149
env:
4250
GH_TOKEN: ${{ github.token }}
4351

52+
- name: Mark new files as uncommited
53+
if: matrix.tests == 'new'
54+
run: |
55+
# List remotes (for debugging)
56+
git remote -v
57+
# Reset the branch to develop
58+
git fetch origin develop
59+
git reset --soft origin/develop
60+
# Show uncommitted changes
61+
git status
62+
4463
- name: Cache conda packages
4564
uses: actions/cache@v4
4665
with:
@@ -83,6 +102,7 @@ jobs:
83102
# this step must be after build, because meson.build creates a number of __init__.py files
84103
# that is needed to make tools/update-meson.py run correctly
85104
shell: bash -l {0}
105+
if: matrix.tests == 'all'
86106
run: |
87107
python3 tools/update-meson.py
88108
if ! ./tools/test-git-no-uncommitted-changes; then
@@ -103,7 +123,17 @@ jobs:
103123
# If editable then deleting the directory will cause sage to detect rebuild, which will cause ninja to fail
104124
# so we don't delete the directory in this case
105125
${{ matrix.editable && 'true' || 'rm -R ./src/sage_setup/' }}
106-
./sage -t --all -p4 --format github
126+
./sage -t --${{ matrix.tests }} -p4 --format github
127+
128+
- name: Check that all modules can be imported
129+
shell: bash -l {0}
130+
run: |
131+
# Increase the length of the lines in the "short summary"
132+
export COLUMNS=120
133+
# The following command checks that all modules can be imported.
134+
# The output also includes a long list of modules together with the number of tests in each module.
135+
# This can be ignored.
136+
pytest -qq --doctest --collect-only || true
107137
108138
- name: Upload log
109139
uses: actions/[email protected]

0 commit comments

Comments
 (0)