@@ -175,11 +175,20 @@ jobs:
175
175
./sage -python -m pytest -c tox.ini -qq --doctest --collect-only || true
176
176
shell : sh .ci/docker-exec-script.sh BUILD /sage {0}
177
177
178
+ - name : Get changed files
179
+ id : changed-files
180
+ uses : tj-actions/changed-files@v44
181
+ with :
182
+ # File extensions per sage.doctest.control.skipfile
183
+ files : src/**/*.{py,pyx,pxd,pxi,sage,spyx,rst,tex}
184
+ files_ignore : src/{setup,conftest*}.py
185
+
178
186
- name : Test changed files (sage -t --new)
187
+ if : steps.changed-files.outputs.all_changed_files
179
188
run : |
180
189
export MAKE="make -j2 --output-sync=recurse" SAGE_NUM_THREADS=4
181
- # We run tests with "sage -t --new"; this only tests the uncommitted changes.
182
- ./sage -t --new -p4
190
+ # https://github.com/tj-actions/changed-files?tab=readme-ov-file#outputs-
191
+ ./sage -t --long --format github -p4 ${{ steps.changed-files.outputs.all_changed_files }}
183
192
shell : sh .ci/docker-exec-script.sh BUILD /sage {0}
184
193
185
194
test-mod :
@@ -283,6 +292,14 @@ jobs:
283
292
image : registry:2
284
293
ports :
285
294
- 5000:5000
295
+ strategy :
296
+ fail-fast : false
297
+ matrix :
298
+ tests :
299
+ - " src/sage/[a-f]*"
300
+ - " src/sage/[g-o]*"
301
+ - " src/sage/[p-z]*"
302
+ - " src/doc src/sage_docbuild src/sage_setup"
286
303
steps :
287
304
- name : Maximize build disk space
288
305
uses : easimon/maximize-build-space@v10
@@ -356,23 +373,138 @@ jobs:
356
373
357
374
# Testing
358
375
359
- - name : Test all files (sage -t --all -- long)
376
+ - name : Test all files (sage -t --long ${{ matrix.tests }} )
360
377
run : |
378
+ mkdir .coverage
379
+ rm -rf /sage/.coverage
380
+ ln -s $(pwd)/.coverage /sage/
381
+ cd /sage
361
382
./sage -python -m pip install coverage
362
- ./sage -python -m coverage run --rcfile=src/tox.ini src/bin/sage-runtests --all --long -p4 --format github --random-seed=286735480429121101562228604801325644303
363
- shell : sh .ci/docker-exec-script.sh BUILD /sage {0}
383
+ ./sage -python -m coverage run --rcfile=src/tox.ini src/bin/sage-runtests --force-lib --long -p4 --format github --random-seed=286735480429121101562228604801325644303 ${{ matrix.tests }}
384
+ shell : sh .ci/docker-exec-script.sh BUILD . {0}
364
385
365
- - name : Copy coverage results
386
+ - name : Combine coverage results
366
387
if : (success() || failure()) && steps.container.outcome == 'success'
367
388
run : |
368
389
./sage -python -m coverage combine --rcfile=src/tox.ini
369
- ./sage -python -m coverage xml --rcfile=src/tox.ini
370
- mkdir -p coverage-report
371
- mv coverage.xml coverage-report/
372
390
shell : sh .ci/docker-exec-script.sh BUILD /sage {0}
373
391
374
- - name : Upload coverage to codecov
392
+ - name : Prepare upload
393
+ id : copy-coverage
375
394
if : (success() || failure()) && steps.container.outcome == 'success'
395
+ run : |
396
+ echo tests_id=$(echo "${{ matrix.tests }}" | sed -E 's, +,--,g;s,/,_,g;s/[^-_A-Za-z]//g;') >> "$GITHUB_OUTPUT"
397
+
398
+ - name : Upload coverage results
399
+ if : (success() || failure()) && steps.container.outcome == 'success'
400
+ uses : actions/upload-artifact@v4
401
+ with :
402
+ name : coverage-${{ steps.copy-coverage.outputs.tests_id }}
403
+ path : .coverage
404
+
405
+ coverage-report :
406
+ runs-on : ubuntu-latest
407
+ needs : [test-long]
408
+ if : (success() || failure())
409
+ services :
410
+ # https://docs.docker.com/build/ci/github-actions/local-registry/
411
+ registry :
412
+ image : registry:2
413
+ ports :
414
+ - 5000:5000
415
+ steps :
416
+ - name : Maximize build disk space
417
+ uses : easimon/maximize-build-space@v10
418
+ with :
419
+ # need space in /var for Docker images
420
+ root-reserve-mb : 30000
421
+ remove-dotnet : true
422
+ remove-android : true
423
+ remove-haskell : true
424
+ remove-codeql : true
425
+ remove-docker-images : true
426
+ - name : Checkout
427
+ id : checkout
428
+ uses : actions/checkout@v4
429
+ - name : Install test prerequisites
430
+ # From docker.yml
431
+ run : |
432
+ sudo DEBIAN_FRONTEND=noninteractive apt-get update
433
+ sudo DEBIAN_FRONTEND=noninteractive apt-get install tox
434
+ sudo apt-get clean
435
+ df -h
436
+ - name : Merge CI fixes from sagemath/sage
437
+ # From docker.yml
438
+ # This step needs to happen after the commit sha is put in DOCKER_TAG
439
+ # so that multi-stage builds can work correctly.
440
+ run : |
441
+ .ci/merge-fixes.sh
442
+ env :
443
+ GH_TOKEN : ${{ github.token }}
444
+
445
+ # Building
446
+
447
+ - name : Generate Dockerfile
448
+ # From docker.yml
449
+ run : |
450
+ tox -e ${{ env.TOX_ENV }}
451
+ cp .tox/${{ env.TOX_ENV }}/Dockerfile .
452
+ env :
453
+ # Only generate the Dockerfile, do not run 'docker build' here
454
+ DOCKER_TARGETS : " "
455
+
456
+ - name : Set up Docker Buildx
457
+ uses : docker/setup-buildx-action@v3
458
+ with :
459
+ driver-opts : network=host
460
+
461
+ - name : Build Docker image
462
+ id : image
463
+ uses : docker/build-push-action@v5
464
+ with :
465
+ push : true
466
+ load : false
467
+ context : .
468
+ tags : ${{ env.BUILD_IMAGE }}
469
+ target : with-targets
470
+ cache-from : type=gha
471
+ cache-to : type=gha,mode=max
472
+ build-args : |
473
+ NUMPROC=6
474
+ USE_MAKEFLAGS=-k V=0 SAGE_NUM_THREADS=4 --output-sync=recurse
475
+ TARGETS_PRE=build/make/Makefile
476
+ TARGETS=ci-build-with-fallback
477
+
478
+ - name : Start container
479
+ id : container
480
+ run : |
481
+ docker run --name BUILD -dit \
482
+ --mount type=bind,src=$(pwd),dst=$(pwd) \
483
+ --workdir $(pwd) \
484
+ ${{ env.BUILD_IMAGE }} /bin/sh
485
+
486
+ # Combining
487
+
488
+ - name : Download coverage artifacts
489
+ uses : actions/download-artifact@v4
490
+ with :
491
+ path : .coverage
492
+ pattern : coverage-*
493
+
494
+ - name : Coverage report
495
+ # Using --omit to avoid "CoverageWarning: Couldn't parse '/tmp/tmp06qizzie/tmp_ldpu46ob.py': No source for code"
496
+ run : |
497
+ rm -rf /sage/.coverage
498
+ ln -s $(pwd)/.coverage /sage/
499
+ cd /sage
500
+ ./sage -python -m pip install coverage
501
+ ./sage -python -m coverage combine --rcfile=src/tox.ini .coverage/coverage-*/.coverage
502
+ ./sage -python -m coverage xml --rcfile=src/tox.ini --omit="/tmp/*"
503
+ mkdir -p .coverage/coverage-report
504
+ mv coverage.xml .coverage/coverage-report/
505
+ shell : sh .ci/docker-exec-script.sh BUILD . {0}
506
+
507
+ - name : Upload coverage to codecov
376
508
uses : codecov/codecov-action@v4
377
509
with :
378
- directory : ./coverage-report
510
+ directory : .coverage /coverage-report
0 commit comments