Debian Codegraph @

.github/workflows/ci-sage.yml

raw
1 name: Run Sage CI for Linux/Cygwin/macOS
2
3 ## This GitHub Actions workflow provides:
4 ##
5 ## - portability testing, by building and testing this project on many platforms
6 ## (Linux variants and Cygwin), each with two configurations (installed packages),
7 ##
8 ## - continuous integration, by building and testing other software
9 ## that depends on this project.
10 ##
11 ## It runs on every push to the GitHub repository.
12 ##
13 ## The testing can be monitored in the "Actions" tab of the GitHub repository.
14 ##
15 ## After all jobs have finished (or are canceled) and a short delay,
16 ## tar files of all logs are made available as "build artifacts".
17 ##
18 ## This GitHub Actions workflow uses the portability testing framework
19 ## of SageMath (https://www.sagemath.org/). For more information, see
20 ## https://doc.sagemath.org/html/en/developer/portability_testing.html
21
22 ## The workflow consists of two jobs:
23 ##
24 ## - First, it builds a source distribution of the project
25 ## and generates a script "update-pkgs.sh". It uploads them
26 ## as a build artifact named upstream.
27 ##
28 ## - Second, it checks out a copy of the SageMath source tree.
29 ## It downloads the upstream artifact and replaces the project's
30 ## package in the SageMath distribution by the newly packaged one
31 ## from the upstream artifact, by running the script "update-pkgs.sh".
32 ## Then it builds a small portion of the Sage distribution.
33 ##
34 ## Many copies of the second step are run in parallel for each of the tested
35 ## systems/configurations.
36
37 on: [push, pull_request]
38
39 ## Uncomment this (and comment the above) to run only on pushes to a tag,
40 ## not on all pushes to a branch.
41 ##
42 ## on:
43 ## pull_request:
44 ## types: [opened, synchronize]
45 ## push:
46 ## tags:
47 ## - '*'
48
49 env:
50 # Ubuntu packages to install so that the projects' "make dist" can succeed
51 DIST_PREREQ: libtool libopenblas-dev libgmp-dev
52 # Name of this project in the Sage distribution
53 SPKG: fflas_ffpack
54 # Sage distribution packages to build
55 TARGETS_PRE: build/make/Makefile
56 TARGETS: SAGE_CHECK=no SAGE_CHECK_givaro=yes SAGE_CHECK_fflas_ffpack=yes SAGE_CHECK_linbox=yes fflas_ffpack sagemath_linbox
57 TARGETS_OPTIONAL: build/make/Makefile
58 # Standard setting: Test the current beta release of Sage:
59 SAGE_REPO: sagemath/sage
60 SAGE_REF: develop
61 # Test with the branch from sage ticket 31444 merged (provides modularized package sagemath-linbox)
62 SAGE_TRAC_GIT: https://github.com/sagemath/sagetrac-mirror.git
63 SAGE_TICKET: 31444
64 REMOVE_PATCHES: "*"
65 EXTRA_CONFIGURE_ARGS: --without-system-givaro --without-system-fflas_ffpack --without-system-linbox
66
67 jobs:
68
69 dist:
70 runs-on: ubuntu-latest
71 env:
72 PREFIX: /tmp/build
73 steps:
74 - name: Check out givaro
75 uses: actions/checkout@v2
76 with:
77 path: build/pkgs/givaro/src
78 repository: linbox-team/givaro
79 - name: Check out ${{ env.SPKG }}
80 uses: actions/checkout@v2
81 with:
82 path: build/pkgs/${{ env.SPKG }}/src
83 - name: Check out linbox
84 uses: actions/checkout@v2
85 with:
86 path: build/pkgs/linbox/src
87 repository: linbox-team/linbox
88 - name: Install prerequisites
89 run: |
90 sudo DEBIAN_FRONTEND=noninteractive apt-get update
91 sudo DEBIAN_FRONTEND=noninteractive apt-get install $DIST_PREREQ
92 - name: Run make dist, prepare upstream artifact
93 run: |
94 (cd build/pkgs/givaro/src && autoreconf -fi && ./configure --prefix=${{ env.PREFIX }} && make -j3 && make install && make dist) \
95 && export PKG_CONFIG_PATH="${{ env.PREFIX }}/lib/pkgconfig:$PKG_CONFIG_PATH" \
96 && mkdir -p upstream && cp build/pkgs/givaro/src/*.tar.gz upstream/givaro-git.tar.gz \
97 && echo "sage-package create givaro --version git --tarball givaro-git.tar.gz --type=standard" > upstream/update-pkgs.sh \
98 && if [ -n "${{ env.REMOVE_PATCHES }}" ]; then echo "(cd ../build/pkgs/givaro/patches && rm -f ${{ env.REMOVE_PATCHES }}; :)" >> upstream/update-pkgs.sh; fi \
99 && (cd build/pkgs/${{ env.SPKG }}/src && autoreconf -fi && ./configure --prefix=${{ env.PREFIX }} && make -j3 && make install && make dist) \
100 && mkdir -p upstream && cp build/pkgs/${{ env.SPKG }}/src/*.tar.gz upstream/${{ env.SPKG }}-git.tar.gz \
101 && echo "sage-package create ${{ env.SPKG }} --version git --tarball ${{ env.SPKG }}-git.tar.gz --type=standard" >> upstream/update-pkgs.sh \
102 && if [ -n "${{ env.REMOVE_PATCHES }}" ]; then echo "(cd ../build/pkgs/${{ env.SPKG }}/patches && rm -f ${{ env.REMOVE_PATCHES }}; :)" >> upstream/update-pkgs.sh; fi \
103 && (cd build/pkgs/linbox/src && autoreconf -fi && ./configure --prefix=${{ env.PREFIX }} && make dist) \
104 && mkdir -p upstream && cp build/pkgs/linbox/src/*.tar.gz upstream/linbox-git.tar.gz \
105 && echo "sage-package create linbox --version git --tarball linbox-git.tar.gz --type=standard" >> upstream/update-pkgs.sh \
106 && if [ -n "${{ env.REMOVE_PATCHES }}" ]; then echo "(cd ../build/pkgs/linbox/patches && rm -f ${{ env.REMOVE_PATCHES }}; :)" >> upstream/update-pkgs.sh; fi \
107 && ls -l upstream/
108 - uses: actions/upload-artifact@v2
109 with:
110 path: upstream
111 name: upstream
112
113 cygwin:
114 env:
115 STAGE: i-a
116 LOCAL_ARTIFACT_NAME: sage-local-commit-${{ github.sha }}-cygwin-${{ matrix.pkgs }}
117 LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-cygwin-${{ matrix.pkgs }}
118 MAKE: make -j8
119 SAGE_NUM_THREADS: 3
120 SAGE_CHECK: yes
121 SAGE_CHECK_PACKAGES: "!cython,!r,!python3,!python2,!nose,!pathpy,!gap,!cysignals,!linbox,!git,!ppl"
122 CYGWIN: winsymlinks:native
123 CONFIGURE_ARGS: --enable-experimental-packages --enable-download-from-upstream-url
124 SAGE_FAT_BINARY: yes
125 SAGE_LOCAL: /opt/sage-fflas-ffpack-${{ github.sha }}
126
127 runs-on: windows-latest
128
129 needs: [dist]
130
131 strategy:
132 fail-fast: false
133 matrix:
134 pkgs: [minimal, standard]
135 steps:
136 - run: |
137 git config --global core.autocrlf false
138 git config --global core.symlinks true
139 - name: install cygwin with choco
140 shell: bash {0}
141 run: |
142 choco --version
143 choco install git python3 --source cygwin
144 - name: Check out SageMath
145 uses: actions/checkout@v2
146 with:
147 repository: ${{ env.SAGE_REPO }}
148 ref: ${{ env.SAGE_REF }}
149 fetch-depth: 2000
150 if: env.SAGE_REPO != ''
151 - name: Check out git-trac-command
152 uses: actions/checkout@v2
153 with:
154 repository: sagemath/git-trac-command
155 path: git-trac-command
156 if: env.SAGE_TRAC_GIT != ''
157 - name: Check out SageMath from trac.sagemath.org
158 shell: bash {0}
159 # Random sleep and retry to limit the load on trac.sagemath.org
160 run: |
161 git config --global user.email "[email protected]"
162 git config --global user.name "ci-sage workflow"
163 if [ ! -d .git ]; then git init; fi; git remote add trac ${{ env.SAGE_TRAC_GIT }} && x=1 && while [ $x -le 5 ]; do x=$(( $x + 1 )); sleep $(( $RANDOM % 60 + 1 )); if git-trac-command/git-trac fetch $SAGE_TICKET; then git merge FETCH_HEAD || echo "(ignored)"; exit 0; fi; sleep 40; done; exit 1
164 if: env.SAGE_TRAC_GIT != ''
165 - uses: actions/download-artifact@v2
166 with:
167 path: upstream
168 name: upstream
169 - name: install minimal prerequisites with choco
170 shell: bash {0}
171 run: |
172 choco --version
173 PACKAGES="python38 python38-pip"
174 choco install $PACKAGES --source cygwin
175 - name: Update Sage packages from upstream artifact
176 run: |
177 C:\\tools\\cygwin\\bin\\bash -l -c 'cd $(cygpath -u "$GITHUB_WORKSPACE") && ls -l upstream/ && export PATH="$(pwd)/build/bin:$PATH:/usr/local/bin:/usr/bin" && (cd upstream && bash -x update-pkgs.sh) && git diff'
178 - name: tox
179 run: |
180 C:\\tools\\cygwin\\bin\\bash -l -x -c 'python3.8 -m pip install tox'
181 C:\\tools\\cygwin\\bin\\bash -l -x -c 'cd $(cygpath -u "$GITHUB_WORKSPACE") && PREFIX="${{ env.SAGE_LOCAL }}" tox -e local-cygwin-choco-${{ matrix.pkgs }} -- $TARGETS'
182 - name: Prepare logs artifact
183 shell: bash
184 run: |
185 mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"; for a in local/var/tmp/sage/build/*; do if [ -d $a ]; then tar -c --remove-files -f "artifacts/$LOGS_ARTIFACT_NAME/$(basename $a).tar" $a || tar -c --ignore-failed-read -f "artifacts/$LOGS_ARTIFACT_NAME/$(basename $a)-save.tar" $a ; fi; done; cp -r logs/* "artifacts/$LOGS_ARTIFACT_NAME"
186 if: always()
187 - uses: actions/upload-artifact@v2
188 with:
189 path: artifacts
190 name: ${{ env.LOGS_ARTIFACT_NAME }}
191 if: always()
192 - name: Print out logs for immediate inspection
193 # The markup in the output is a GitHub Actions logging command
194 # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/development-tools-for-github-actions
195 shell: bash
196 run: |
197 find "artifacts/$LOGS_ARTIFACT_NAME" -type f -name "*.log" -exec sh -c 'if tail -20 "{}" 2>/dev/null | grep "^Error" >/dev/null; then echo :":"error file={}:":" ==== LOG FILE {} CONTAINS AN ERROR ====; cat {} ; fi' \;
198 if: always()
199 - name: Prepare sage-local artifact
200 # We specifically use the cygwin tar so that symlinks are saved/restored correctly on Windows.
201 # We remove the $SAGE_LOCAL/lib64 link, which will be recreated by the next stage.
202 run: |
203 C:\\tools\\cygwin\\bin\\bash -l -c 'cd $(cygpath -u "$GITHUB_WORKSPACE") && rm -f "${{ env.SAGE_LOCAL }}"/lib64; tar -cf /tmp/sage-local-${{ env.STAGE }}.tar --remove-files "${{ env.SAGE_LOCAL }}"'
204 if: always()
205 - uses: actions/upload-artifact@v2
206 # upload-artifact@v2 does not support whitespace in file names.
207 # so we tar up the directory ourselves
208 with:
209 path: C:\\tools\\cygwin\\tmp\\sage-local-${{ env.STAGE }}.tar
210 name: ${{ env.LOCAL_ARTIFACT_NAME }}
211 if: always()
212
213 docker:
214 runs-on: ubuntu-latest
215 needs: [dist]
216 strategy:
217 fail-fast: false
218 max-parallel: 32
219 matrix:
220 tox_system_factor: [ubuntu-trusty, ubuntu-xenial, ubuntu-bionic, ubuntu-focal, ubuntu-groovy, ubuntu-hirsute, debian-jessie, debian-stretch, debian-buster, debian-bullseye, debian-sid, linuxmint-17, linuxmint-18, linuxmint-19, linuxmint-19.3, linuxmint-20.1, fedora-26, fedora-27, fedora-28, fedora-29, fedora-30, fedora-31, fedora-32, fedora-33, fedora-34, centos-7, centos-8, gentoo, archlinux-latest, slackware-14.2, conda-forge, ubuntu-bionic-i386, debian-buster-i386, centos-7-i386, raspbian-buster-armhf]
221 tox_packages_factor: [minimal, standard]
222 env:
223 TOX_ENV: docker-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}
224 LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-docker-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}
225 DOCKER_TARGETS: configured with-targets with-targets-optional
226 steps:
227 - name: Check out SageMath
228 uses: actions/checkout@v2
229 with:
230 repository: ${{ env.SAGE_REPO }}
231 ref: ${{ env.SAGE_REF }}
232 fetch-depth: 2000
233 if: env.SAGE_REPO != ''
234 - name: Check out git-trac-command
235 uses: actions/checkout@v2
236 with:
237 repository: sagemath/git-trac-command
238 path: git-trac-command
239 if: env.SAGE_TRAC_GIT != ''
240 - name: Check out SageMath from trac.sagemath.org
241 shell: bash {0}
242 run: |
243 git config --global user.email "[email protected]"
244 git config --global user.name "ci-sage workflow"
245 if [ ! -d .git ]; then git init; fi; git remote add trac ${{ env.SAGE_TRAC_GIT }} && x=1 && while [ $x -le 5 ]; do x=$(( $x + 1 )); sleep $(( $RANDOM % 60 + 1 )); if git-trac-command/git-trac fetch $SAGE_TICKET; then git merge FETCH_HEAD || echo "(ignored)"; exit 0; fi; sleep 40; done; exit 1
246 if: env.SAGE_TRAC_GIT != ''
247 - uses: actions/download-artifact@v2
248 with:
249 path: upstream
250 name: upstream
251 - name: Install test prerequisites
252 run: |
253 sudo DEBIAN_FRONTEND=noninteractive apt-get update
254 sudo DEBIAN_FRONTEND=noninteractive apt-get install tox python3-setuptools
255 - name: Update Sage packages from upstream artifact
256 run: |
257 (export PATH=$(pwd)/build/bin:$PATH; (cd upstream && bash -x update-pkgs.sh) && sed -i.bak '/upstream/d' .dockerignore && echo "/:toolchain:/i ADD upstream upstream" | sed -i.bak -f - build/bin/write-dockerfile.sh && git diff)
258 - name: Configure and build Sage distribution within a Docker container
259 run: |
260 set -o pipefail; EXTRA_DOCKER_BUILD_ARGS="--build-arg USE_MAKEFLAGS=\"-k V=0 SAGE_NUM_THREADS=3\"" tox -e $TOX_ENV -- $TARGETS 2>&1 | sed "/^configure: notice:/s|^|::warning file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|;/^configure: warning:/s|^|::warning file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|;/^configure: error:/s|^|::error file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|;"
261 - name: Copy logs from the Docker image or build container
262 run: |
263 mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"
264 cp -r .tox/$TOX_ENV/Dockerfile .tox/$TOX_ENV/log "artifacts/$LOGS_ARTIFACT_NAME"
265 if [ -f .tox/$TOX_ENV/Dockertags ]; then CONTAINERS=$(docker create $(tail -1 .tox/$TOX_ENV/Dockertags) /bin/bash || true); fi
266 if [ -n "$CONTAINERS" ]; then for CONTAINER in $CONTAINERS; do for ARTIFACT in /sage/logs; do docker cp $CONTAINER:$ARTIFACT artifacts/$LOGS_ARTIFACT_NAME && HAVE_LOG=1; done; if [ -n "$HAVE_LOG" ]; then break; fi; done; fi
267 if: always()
268 - uses: actions/upload-artifact@v2
269 with:
270 path: artifacts
271 name: ${{ env.LOGS_ARTIFACT_NAME }}
272 if: always()
273 - name: Print out logs for immediate inspection
274 # and markup the output with GitHub Actions logging commands
275 run: |
276 .github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME"
277 if: always()
278 - name: Push Docker images
279 run: |
280 if [ -f .tox/$TOX_ENV/Dockertags ]; then
281 TOKEN="${{ secrets.DOCKER_PKG_GITHUB_TOKEN }}"
282 if [ -z "$TOKEN" ]; then
283 TOKEN="${{ secrets.GITHUB_TOKEN }}"
284 fi
285 echo "$TOKEN" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
286 for a in $(cat .tox/$TOX_ENV/Dockertags); do
287 FULL_TAG=docker.pkg.github.com/$(echo ${{ github.repository }}|tr 'A-Z' 'a-z')/$a
288 docker tag $a $FULL_TAG
289 echo Pushing $FULL_TAG
290 docker push $FULL_TAG
291 done || echo "(Ignoring errors)"
292 fi
293 if: always()
294
295 macos:
296
297 runs-on: macos-latest
298 strategy:
299 fail-fast: false
300 max-parallel: 4
301 matrix:
302 tox_system_factor: [homebrew-macos, conda-forge-macos]
303 tox_packages_factor: [minimal, standard]
304 # As of 2021-03, default xcode is 12.4
305 # https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md#xcode
306 xcode_version_factor: [default]
307 os: [ macos-10.15, macos-11.0 ]
308 include:
309 # Test xcode 11.7 only on macos-10.15
310 - tox_system_factor: homebrew-macos
311 tox_packages_factor: minimal
312 xcode_version_factor: 11.7
313 os: macos-10.15
314 - tox_system_factor: homebrew-macos
315 tox_packages_factor: standard
316 xcode_version_factor: 11.7
317 os: macos-10.15
318 # python3_xcode is only accepted if enough packages are available from the system
319 # --> to test "minimal", we will need https://trac.sagemath.org/ticket/30949
320 - tox_system_factor: homebrew-macos-python3_xcode
321 tox_packages_factor: standard
322 xcode_version_factor: 11.7
323 os: macos-10.15
324 - tox_system_factor: homebrew-macos-python3_xcode
325 tox_packages_factor: standard
326 xcode_version_factor: default
327 os: macos-10.15
328 - tox_system_factor: homebrew-macos-python3_xcode
329 tox_packages_factor: standard
330 xcode_version_factor: default
331 os: macos-11.0
332
333 needs: [dist]
334
335 env:
336 TOX_ENV: local-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}
337 LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-local-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}-${{ matrix.os }}-xcode_${{ matrix.xcode_version_factor }}
338 DOCKER_TARGETS: configured with-targets with-targets-optional
339
340 steps:
341
342 - name: Select Xcode version
343 run: |
344 if [ ${{ matrix.xcode_version_factor }} != default ]; then sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode_version_factor }}.app; fi
345 - name: Check out SageMath
346 uses: actions/checkout@v2
347 with:
348 repository: ${{ env.SAGE_REPO }}
349 ref: ${{ env.SAGE_REF }}
350 fetch-depth: 2000
351 if: env.SAGE_REPO != ''
352 - name: Check out git-trac-command
353 uses: actions/checkout@v2
354 with:
355 repository: sagemath/git-trac-command
356 path: git-trac-command
357 if: env.SAGE_TRAC_GIT != ''
358 - name: Check out SageMath from trac.sagemath.org
359 shell: bash {0}
360 run: |
361 git config --global user.email "[email protected]"
362 git config --global user.name "ci-sage workflow"
363 if [ ! -d .git ]; then git init; fi; git remote add trac ${{ env.SAGE_TRAC_GIT }} && x=1 && while [ $x -le 5 ]; do x=$(( $x + 1 )); sleep $(( $RANDOM % 60 + 1 )); if git-trac-command/git-trac fetch $SAGE_TICKET; then git merge FETCH_HEAD || echo "(ignored)"; exit 0; fi; sleep 40; done; exit 1
364 if: env.SAGE_TRAC_GIT != ''
365 - uses: actions/download-artifact@v2
366 with:
367 path: upstream
368 name: upstream
369 - name: Update Sage packages from upstream artifact
370 run: |
371 (export PATH=$(pwd)/build/bin:$PATH; (cd upstream && bash -x update-pkgs.sh) && git diff)
372
373 - name: Install test prerequisites
374 run: |
375 brew install tox
376 - name: Build and test with tox
377 # We use a high parallelization on purpose in order to catch possible parallelization bugs in the build scripts.
378 # For doctesting, we use a lower parallelization to avoid timeouts.
379 run: |
380 MAKE="make -j12" tox -e $TOX_ENV -- SAGE_NUM_THREADS=4 $TARGETS
381 - name: Prepare logs artifact
382 run: |
383 mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"; cp -r .tox/*/log "artifacts/$LOGS_ARTIFACT_NAME"
384 if: always()
385 - uses: actions/upload-artifact@v1
386 with:
387 path: artifacts
388 name: ${{ env.LOGS_ARTIFACT_NAME }}
389 if: always()
390 - name: Print out logs for immediate inspection
391 # and markup the output with GitHub Actions logging commands
392 run: |
393 .github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME"
394 if: always()