source: git/.github/workflows/ci-sage.yml @ 0c72bd

spielwiese
Last change on this file since 0c72bd was 0c72bd, checked in by Matthias Koeppe <mkoeppe@…>, 3 years ago
.github/workflows/ci-sage.yml: Run a quick test job before testing lots of platforms in parallel
  • Property mode set to 100644
File size: 19.8 KB
Line 
1name: 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 pull request and push of a tag 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
39on:
40  pull_request:
41    types: [opened, synchronize]
42  push:
43    tags:
44      - '*'
45  workflow_dispatch:
46    # Allow to run manually
47
48env:
49  # Ubuntu packages to install so that the project's "make dist" can succeed
50  DIST_PREREQ: libcdd-dev
51  # Name of this project in the Sage distribution
52  SPKG:        singular
53  # Sage distribution packages to build
54  TARGETS_PRE: build/make/Makefile
55  TARGETS:     SAGE_CHECK=no SAGE_CHECK_PACKAGES=singular,pynac singular pynac
56  TARGETS_OPTIONAL: SAGE_CHECK=no SAGE_CHECK_pysingular=warn pysingular
57  # Standard setting: Test the current beta release of Sage:
58  SAGE_REPO:   sagemath/sage
59  SAGE_REF:    develop
60  # Temporarily test on the branch from sage ticket for singular 4.2 upgrade
61  SAGE_TRAC_GIT: git://trac.sagemath.org/sage.git
62  SAGE_TRAC_COMMAND: try
63  SAGE_TICKET: 25993
64  REMOVE_PATCHES: "*"
65
66jobs:
67
68  dist:
69    runs-on: ubuntu-latest
70    steps:
71      - name: Check out ${{ env.SPKG }}
72        uses: actions/checkout@v2
73        with:
74          path: build/pkgs/${{ env.SPKG }}/src
75      - name: Install prerequisites
76        run: |
77          sudo DEBIAN_FRONTEND=noninteractive apt-get update
78          sudo DEBIAN_FRONTEND=noninteractive apt-get install $DIST_PREREQ
79      - name: Run make dist, prepare upstream artifact
80        run: |
81          (cd build/pkgs/${{ env.SPKG }}/src && (./autogen.sh && ./configure && make dist) ) \
82          && mkdir -p upstream && cp build/pkgs/${{ env.SPKG }}/src/*.tar.gz upstream/${{ env.SPKG }}-git.tar.gz \
83          && echo "sage-package create ${{ env.SPKG }} --version git --tarball ${{ env.SPKG }}-git.tar.gz --type=optional" > upstream/update-pkgs.sh \
84          && if [ -n "${{ env.REMOVE_PATCHES }}" ]; then echo "(cd ../build/pkgs/${{ env.SPKG }}/patches && rm -f ${{ env.REMOVE_PATCHES }}; :)" >> upstream/update-pkgs.sh; fi \
85          && ls -l upstream/
86      - uses: actions/upload-artifact@v2
87        with:
88          path: upstream
89          name: upstream
90
91  kanarienvogel:
92    # Quick run for 1 platform first; do not run the other platforms when this already fails
93    runs-on: ubuntu-latest
94    needs: [dist]
95    strategy:
96      fail-fast: true
97      max-parallel: 4
98      matrix:
99        tox_system_factor: [ubuntu-focal]
100        tox_packages_factor: [standard]
101    env:
102      # Override so that this runs faster
103      TARGETS: SAGE_CHECK=no singular
104      TARGETS_OPTIONAL: build/make/Makefile
105    # The rest of this is identical to job "docker":
106      TOX_ENV: docker-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}
107      LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-docker-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}
108      DOCKER_TARGETS: configured with-targets with-targets-optional
109    steps:
110      - name: Check out SageMath
111        uses: actions/checkout@v2
112        with:
113          repository: ${{ env.SAGE_REPO }}
114          ref: ${{ env.SAGE_REF }}
115        if: env.SAGE_REPO != ''
116      - name: Check out git-trac-command
117        uses: actions/checkout@v2
118        with:
119          repository: sagemath/git-trac-command
120          path: git-trac-command
121        if: env.SAGE_TRAC_GIT != ''
122      - name: Check out SageMath from trac.sagemath.org
123        shell: bash {0}
124        run: |
125          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 ${{ env.SAGE_TRAC_COMMAND }} $SAGE_TICKET; then exit 0; fi; sleep 40; done; exit 1
126        if: env.SAGE_TRAC_GIT != ''
127      - uses: actions/download-artifact@v2
128        with:
129          path: upstream
130          name: upstream
131      - name: Install test prerequisites
132        run: |
133          sudo DEBIAN_FRONTEND=noninteractive apt-get update
134          sudo DEBIAN_FRONTEND=noninteractive apt-get install tox python3-setuptools
135      - name: Update Sage packages from upstream artifact
136        run: |
137          (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)
138      - name: Configure and build Sage distribution within a Docker container
139        run: |
140          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::|;"
141      - name: Copy logs from the Docker image or build container
142        run: |
143          mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"
144          cp -r .tox/$TOX_ENV/Dockerfile .tox/$TOX_ENV/log "artifacts/$LOGS_ARTIFACT_NAME"
145          if [ -f .tox/$TOX_ENV/Dockertags ]; then CONTAINERS=$(docker create $(tail -1 .tox/$TOX_ENV/Dockertags) /bin/bash || true); fi
146          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
147        if: always()
148      - uses: actions/upload-artifact@v2
149        with:
150          path: artifacts
151          name: ${{ env.LOGS_ARTIFACT_NAME }}
152        if: always()
153      - name: Print out logs for immediate inspection
154        # and markup the output with GitHub Actions logging commands
155        run: |
156          .github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME"
157        if: always()
158      - name: Push Docker images
159        run: |
160          if [ -f .tox/$TOX_ENV/Dockertags ]; then
161            TOKEN="${{ secrets.DOCKER_PKG_GITHUB_TOKEN }}"
162            if [ -z "$TOKEN" ]; then
163              TOKEN="${{ secrets.GITHUB_TOKEN }}"
164            fi
165            echo "$TOKEN" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
166            for a in $(cat .tox/$TOX_ENV/Dockertags); do
167              FULL_TAG=docker.pkg.github.com/$(echo ${{ github.repository }}|tr 'A-Z' 'a-z')/$a
168              docker tag $a $FULL_TAG
169              echo Pushing $FULL_TAG
170              docker push $FULL_TAG
171            done || echo "(Ignoring errors)"
172          fi
173        if: always()
174
175  cygwin:
176    env:
177      STAGE: i-a
178      LOCAL_ARTIFACT_NAME: sage-local-commit-${{ github.sha }}-cygwin-${{ matrix.pkgs }}
179      LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-cygwin-${{ matrix.pkgs }}
180      MAKE: make -j8
181      SAGE_NUM_THREADS: 3
182      SAGE_CHECK: yes
183      SAGE_CHECK_PACKAGES: "!cython,!r,!python3,!python2,!nose,!pathpy,!gap,!cysignals,!linbox,!git,!ppl"
184      CYGWIN: winsymlinks:native
185      CONFIGURE_ARGS: --enable-experimental-packages --enable-download-from-upstream-url
186      SAGE_FAT_BINARY: yes
187      SAGE_LOCAL: /opt/sage-singular-${{ github.sha }}
188
189    runs-on: windows-latest
190
191    needs: [dist, kanarienvogel]
192
193    strategy:
194      fail-fast: false
195      matrix:
196        pkgs: [minimal, standard]
197    steps:
198    - run: |
199        git config --global core.autocrlf false
200        git config --global core.symlinks true
201    - name: install cygwin with choco
202      shell: bash {0}
203      run: |
204        choco --version
205        choco install git python3 --source cygwin
206    - name: Check out SageMath
207      uses: actions/checkout@v2
208      with:
209        repository: ${{ env.SAGE_REPO }}
210        ref: ${{ env.SAGE_REF }}
211      if: env.SAGE_REPO != ''
212    - name: Check out git-trac-command
213      uses: actions/checkout@v2
214      with:
215        repository: sagemath/git-trac-command
216        path: git-trac-command
217      if: env.SAGE_TRAC_GIT != ''
218    - name: Check out SageMath from trac.sagemath.org
219      shell: bash {0}
220      # Random sleep and retry to limit the load on trac.sagemath.org
221      run: |
222        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 ${{ env.SAGE_TRAC_COMMAND }} $SAGE_TICKET; then exit 0; fi; sleep 40; done; exit 1
223      if: env.SAGE_TRAC_GIT != ''
224    - uses: actions/download-artifact@v2
225      with:
226        path: upstream
227        name: upstream
228    - name: install minimal prerequisites with choco
229      shell: bash {0}
230      run: |
231        choco --version
232        PACKAGES="python38 python38-pip"
233        choco install $PACKAGES --source cygwin
234    - name: Update Sage packages from upstream artifact
235      run: |
236        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'
237    - name: tox
238      run: |
239        C:\\tools\\cygwin\\bin\\bash -l -x -c 'python3.8 -m pip install tox'
240        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'
241    - name: Prepare logs artifact
242      shell: bash
243      run: |
244        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"
245      if: always()
246    - uses: actions/upload-artifact@v2
247      with:
248        path: artifacts
249        name: ${{ env.LOGS_ARTIFACT_NAME }}
250      if: always()
251    - name: Print out logs for immediate inspection
252      # The markup in the output is a GitHub Actions logging command
253      # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/development-tools-for-github-actions
254      shell: bash
255      run: |
256        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' \;
257      if: always()
258    - name: Prepare sage-local artifact
259      # We specifically use the cygwin tar so that symlinks are saved/restored correctly on Windows.
260      # We remove the $SAGE_LOCAL/lib64 link, which will be recreated by the next stage.
261      run: |
262        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 }}"'
263      if: always()
264    - uses: actions/upload-artifact@v2
265      # upload-artifact@v2 does not support whitespace in file names.
266      # so we tar up the directory ourselves
267      with:
268        path: C:\\tools\\cygwin\\tmp\\sage-local-${{ env.STAGE }}.tar
269        name: ${{ env.LOCAL_ARTIFACT_NAME }}
270      if: always()
271
272  docker:
273    runs-on: ubuntu-latest
274    needs: [dist, kanarienvogel]
275    strategy:
276      fail-fast: false
277      max-parallel: 32
278      matrix:
279        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, ubuntu-focal-i386, debian-buster-i386, centos-7-i386, raspbian-buster-armhf]
280        tox_packages_factor: [minimal, standard]
281    env:
282      TOX_ENV: docker-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}
283      LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-docker-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}
284      DOCKER_TARGETS: configured with-targets with-targets-optional
285    steps:
286      - name: Check out SageMath
287        uses: actions/checkout@v2
288        with:
289          repository: ${{ env.SAGE_REPO }}
290          ref: ${{ env.SAGE_REF }}
291        if: env.SAGE_REPO != ''
292      - name: Check out git-trac-command
293        uses: actions/checkout@v2
294        with:
295          repository: sagemath/git-trac-command
296          path: git-trac-command
297        if: env.SAGE_TRAC_GIT != ''
298      - name: Check out SageMath from trac.sagemath.org
299        shell: bash {0}
300        run: |
301          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 ${{ env.SAGE_TRAC_COMMAND }} $SAGE_TICKET; then exit 0; fi; sleep 40; done; exit 1
302        if: env.SAGE_TRAC_GIT != ''
303      - uses: actions/download-artifact@v2
304        with:
305          path: upstream
306          name: upstream
307      - name: Install test prerequisites
308        run: |
309          sudo DEBIAN_FRONTEND=noninteractive apt-get update
310          sudo DEBIAN_FRONTEND=noninteractive apt-get install tox python3-setuptools
311      - name: Update Sage packages from upstream artifact
312        run: |
313          (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)
314      - name: Configure and build Sage distribution within a Docker container
315        run: |
316          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::|;"
317      - name: Copy logs from the Docker image or build container
318        run: |
319          mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"
320          cp -r .tox/$TOX_ENV/Dockerfile .tox/$TOX_ENV/log "artifacts/$LOGS_ARTIFACT_NAME"
321          if [ -f .tox/$TOX_ENV/Dockertags ]; then CONTAINERS=$(docker create $(tail -1 .tox/$TOX_ENV/Dockertags) /bin/bash || true); fi
322          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
323        if: always()
324      - uses: actions/upload-artifact@v2
325        with:
326          path: artifacts
327          name: ${{ env.LOGS_ARTIFACT_NAME }}
328        if: always()
329      - name: Print out logs for immediate inspection
330        # and markup the output with GitHub Actions logging commands
331        run: |
332          .github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME"
333        if: always()
334      - name: Push Docker images
335        run: |
336          if [ -f .tox/$TOX_ENV/Dockertags ]; then
337            TOKEN="${{ secrets.DOCKER_PKG_GITHUB_TOKEN }}"
338            if [ -z "$TOKEN" ]; then
339              TOKEN="${{ secrets.GITHUB_TOKEN }}"
340            fi
341            echo "$TOKEN" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
342            for a in $(cat .tox/$TOX_ENV/Dockertags); do
343              FULL_TAG=docker.pkg.github.com/$(echo ${{ github.repository }}|tr 'A-Z' 'a-z')/$a
344              docker tag $a $FULL_TAG
345              echo Pushing $FULL_TAG
346              docker push $FULL_TAG
347            done || echo "(Ignoring errors)"
348          fi
349        if: always()
350
351  macos:
352
353    runs-on: macos-latest
354    strategy:
355      fail-fast: false
356      max-parallel: 4
357      matrix:
358        os: [ macos-10.15, macos-11.0 ]
359        tox_system_factor: [homebrew-macos, homebrew-macos-python3_xcode, homebrew-macos-python3_xcode-nokegonly, conda-forge-macos]
360        tox_packages_factor: [minimal, standard]
361        xcode_version_factor: [11.7, default, 12.3]
362
363    needs: [dist, kanarienvogel]
364
365    env:
366      TOX_ENV: local-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}
367      LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-local-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}-${{ matrix.os }}-xcode_${{ matrix.xcode_version_factor }}
368      DOCKER_TARGETS: configured with-targets with-targets-optional
369
370    steps:
371
372      - name: Select Xcode version
373        run: |
374          if [ ${{ matrix.xcode_version_factor }} != default ]; then sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode_version_factor }}.app; fi
375      - name: Check out SageMath
376        uses: actions/checkout@v2
377        with:
378          repository: ${{ env.SAGE_REPO }}
379          ref: ${{ env.SAGE_REF }}
380        if: env.SAGE_REPO != ''
381      - name: Check out git-trac-command
382        uses: actions/checkout@v2
383        with:
384          repository: sagemath/git-trac-command
385          path: git-trac-command
386        if: env.SAGE_TRAC_GIT != ''
387      - name: Check out SageMath from trac.sagemath.org
388        shell: bash {0}
389        run: |
390          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 ${{ env.SAGE_TRAC_COMMAND }} $SAGE_TICKET; then exit 0; fi; sleep 40; done; exit 1
391        if: env.SAGE_TRAC_GIT != ''
392      - uses: actions/download-artifact@v2
393        with:
394          path: upstream
395          name: upstream
396      - name: Update Sage packages from upstream artifact
397        run: |
398          (export PATH=$(pwd)/build/bin:$PATH; (cd upstream && bash -x update-pkgs.sh) && git diff)
399
400      - name: Install test prerequisites
401        run: |
402          brew install tox
403      - name: Build and test with tox
404        # We use a high parallelization on purpose in order to catch possible parallelization bugs in the build scripts.
405        # For doctesting, we use a lower parallelization to avoid timeouts.
406        run: |
407          MAKE="make -j12" tox -e $TOX_ENV -- SAGE_NUM_THREADS=4 $TARGETS
408      - name: Prepare logs artifact
409        run: |
410          mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"; cp -r .tox/*/log "artifacts/$LOGS_ARTIFACT_NAME"
411        if: always()
412      - uses: actions/upload-artifact@v1
413        with:
414          path: artifacts
415          name: ${{ env.LOGS_ARTIFACT_NAME }}
416        if: always()
417      - name: Print out logs for immediate inspection
418        # and markup the output with GitHub Actions logging commands
419        run: |
420          .github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME"
421        if: always()
Note: See TracBrowser for help on using the repository browser.