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

spielwiese
Last change on this file since efb3fc was efb3fc, checked in by Matthias Koeppe <mkoeppe@…>, 4 years ago
Update from fplll
  • Property mode set to 100644
File size: 15.6 KB
RevLine 
[d2074d]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
46env:
47  # Ubuntu packages to install so that the project's "make dist" can succeed
[ab6949]48  DIST_PREREQ: libcdd-dev
[d2074d]49  # Name of this project in the Sage distribution
[a72a30]50  SPKG:        singular
[d2074d]51  # Sage distribution packages to build
52  TARGETS_PRE: build/make/Makefile
[a72a30]53  TARGETS:     SAGE_CHECK=yes singular
54  TARGETS_OPTIONAL: SAGE_CHECK=warn pynac pysingular
[d2074d]55  # Standard setting: Test the current beta release of Sage:
56  SAGE_REPO:   sagemath/sage
57  SAGE_REF:    develop
[a72a30]58  # Temporarily test on the branch from sage ticket for singular 4.1.3 upgrade
[d2074d]59  SAGE_TRAC_GIT: git://trac.sagemath.org/sage.git
[efb3fc]60  SAGE_TRAC_COMMAND: try
[a72a30]61  SAGE_TICKET: 25993
[d2074d]62  REMOVE_PATCHES: "*"
63
64jobs:
65
66  dist:
67    runs-on: ubuntu-latest
68    steps:
69      - name: Check out ${{ env.SPKG }}
70        uses: actions/checkout@v2
71        with:
72          path: build/pkgs/${{ env.SPKG }}/src
73      - name: Install prerequisites
74        run: |
75          sudo DEBIAN_FRONTEND=noninteractive apt-get update
76          sudo DEBIAN_FRONTEND=noninteractive apt-get install $DIST_PREREQ
77      - name: Run make dist, prepare upstream artifact
[662704]78        # make dist broken, make_tar.sh broken - https://github.com/Singular/Singular/issues/1016
[d2074d]79        run: |
[ab6949]80          (cd build/pkgs/${{ env.SPKG }}/src && (./autogen.sh && ./configure && make dist) ) \
[d2074d]81          && mkdir -p upstream && cp build/pkgs/${{ env.SPKG }}/src/*.tar.gz upstream/${{ env.SPKG }}-git.tar.gz \
82          && echo "sage-package create ${{ env.SPKG }} --version git --tarball ${{ env.SPKG }}-git.tar.gz --type=optional" > upstream/update-pkgs.sh \
83          && if [ -n "${{ env.REMOVE_PATCHES }}" ]; then echo "(cd ../build/pkgs/${{ env.SPKG }}/patches && rm -f ${{ env.REMOVE_PATCHES }}; :)" >> upstream/update-pkgs.sh; fi \
84          && ls -l upstream/
85      - uses: actions/upload-artifact@v2
86        with:
87          path: upstream
88          name: upstream
89
90  cygwin:
91    env:
92      STAGE: i-a
93      LOCAL_ARTIFACT_NAME: sage-local-commit-${{ github.sha }}-cygwin-${{ matrix.pkgs }}
94      LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-cygwin-${{ matrix.pkgs }}
95      MAKE: make -j8
96      SAGE_NUM_THREADS: 3
97      SAGE_CHECK: yes
98      SAGE_CHECK_PACKAGES: "!cython,!r,!python3,!python2,!nose,!pathpy,!gap,!cysignals,!linbox,!git,!ppl"
99      CYGWIN: winsymlinks:native
100      CONFIGURE_ARGS: --enable-experimental-packages --enable-download-from-upstream-url
101      SAGE_FAT_BINARY: yes
102
103    runs-on: windows-latest
104
105    needs: [dist]
106
107    strategy:
108      fail-fast: false
109      matrix:
110        pkgs: [minimal, standard]
111    steps:
112    - run: |
113        git config --global core.autocrlf false
114        git config --global core.symlinks true
115    - name: install cygwin with choco
116      shell: bash {0}
117      run: |
118        choco --version
119        choco install git python3 --source cygwin
120    - name: Check out SageMath
121      uses: actions/checkout@v2
122      with:
123        repository: ${{ env.SAGE_REPO }}
124        ref: ${{ env.SAGE_REF }}
125      if: env.SAGE_REPO != ''
126    - name: Check out git-trac-command
127      uses: actions/checkout@v2
128      with:
129        repository: sagemath/git-trac-command
130        path: git-trac-command
131      if: env.SAGE_TRAC_GIT != ''
132    - name: Check out SageMath from trac.sagemath.org
133      shell: bash {0}
134      # Random sleep and retry to limit the load on trac.sagemath.org
135      run: |
[efb3fc]136        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
[d2074d]137      if: env.SAGE_TRAC_GIT != ''
138    - uses: actions/download-artifact@v2
139      with:
140        path: upstream
141        name: upstream
142    - name: install minimal prerequisites with choco
143      shell: bash {0}
144      run: |
145        choco --version
146        PACKAGES=$(sed 's/#.*//;' ./build/pkgs/cygwin.txt ./build/pkgs/cygwin-bootstrap.txt)
147        choco install $PACKAGES --source cygwin
148    - name: Update Sage packages from upstream artifact
149      run: |
150        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'
151    - name: bootstrap
152      run: |
153        C:\\tools\\cygwin\\bin\\bash -l -c 'export PATH=/usr/local/bin:/usr/bin && cd $(cygpath -u "$GITHUB_WORKSPACE") && env && ./bootstrap'
154    - name: install additional cygwin packages with choco
155      if: contains(matrix.pkgs, 'standard')
156      shell: bash {0}
157      run: |
158        PACKAGES=$(sed 's/#.*//;' ./build/pkgs/*/distros/cygwin.txt)
159        choco install $PACKAGES --source cygwin
160    - name: configure
161      run: |
162        C:\\tools\\cygwin\\bin\\bash -l -c 'export PATH=/usr/local/bin:/usr/bin && cd $(cygpath -u "$GITHUB_WORKSPACE") && ./configure $CONFIGURE_ARGS'
163    - name: make
164      run: |
165        C:\\tools\\cygwin\\bin\\bash -l -x -c 'export PATH=/usr/local/bin:/usr/bin && cd $(cygpath -u "$GITHUB_WORKSPACE") && make -k -w V=0 base-toolchain && make -k -w V=1 $TARGETS'
[9abf8f]166    - name: make
167      run: |
168        C:\\tools\\cygwin\\bin\\bash -l -x -c 'export PATH=/usr/local/bin:/usr/bin && cd $(cygpath -u "$GITHUB_WORKSPACE") && make -k -w V=1 $TARGETS_OPTIONAL'
[d2074d]169    - name: Prepare logs artifact
170      shell: bash
171      run: |
[f3d331]172        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"
[d2074d]173      if: always()
174    - uses: actions/upload-artifact@v2
175      with:
176        path: artifacts
177        name: ${{ env.LOGS_ARTIFACT_NAME }}
178      if: always()
179    - name: Print out logs for immediate inspection
180      # The markup in the output is a GitHub Actions logging command
181      # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/development-tools-for-github-actions
182      shell: bash
183      run: |
184        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' \;
185      if: always()
186    - name: Prepare sage-local artifact
187      # We specifically use the cygwin tar so that symlinks are saved/restored correctly on Windows.
188      # We remove the local/lib64 link, which will be recreated by the next stage.
189      run: |
190        C:\\tools\\cygwin\\bin\\bash -l -c 'cd $(cygpath -u "$GITHUB_WORKSPACE") && rm -f local/lib64; tar -cf /tmp/sage-local-${{ env.STAGE }}.tar --remove-files local'
191      if: always()
192    - uses: actions/upload-artifact@v2
193      # upload-artifact@v2 does not support whitespace in file names.
194      # so we tar up the directory ourselves
195      with:
196        path: C:\\tools\\cygwin\\tmp\\sage-local-${{ env.STAGE }}.tar
197        name: ${{ env.LOCAL_ARTIFACT_NAME }}
198      if: always()
199
200  docker:
201    runs-on: ubuntu-latest
202    needs: [dist]
203    strategy:
204      fail-fast: false
205      max-parallel: 32
206      matrix:
[efb3fc]207        tox_system_factor: [ubuntu-trusty, ubuntu-xenial, ubuntu-bionic, ubuntu-eoan, ubuntu-focal, debian-jessie, debian-stretch, debian-buster, debian-bullseye, debian-sid, linuxmint-17, linuxmint-18, linuxmint-19, linuxmint-19.3, fedora-26, fedora-27, fedora-28, fedora-29, fedora-30, fedora-31, centos-7, centos-8, archlinux-latest, slackware-14.2, conda-forge, ubuntu-bionic-i386, ubuntu-eoan-i386, debian-buster-i386, centos-7-i386, raspbian-buster-armhf]
[d2074d]208        tox_packages_factor: [minimal, standard]
209    env:
210      TOX_ENV: docker-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}
211      LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-docker-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}
212      DOCKER_TARGETS: configured with-targets
213    steps:
214      - name: Check out SageMath
215        uses: actions/checkout@v2
216        with:
217          repository: ${{ env.SAGE_REPO }}
218          ref: ${{ env.SAGE_REF }}
219        if: env.SAGE_REPO != ''
220      - name: Check out git-trac-command
221        uses: actions/checkout@v2
222        with:
223          repository: sagemath/git-trac-command
224          path: git-trac-command
225        if: env.SAGE_TRAC_GIT != ''
226      - name: Check out SageMath from trac.sagemath.org
227        shell: bash {0}
228        run: |
[efb3fc]229          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
[d2074d]230        if: env.SAGE_TRAC_GIT != ''
231      - uses: actions/download-artifact@v2
232        with:
233          path: upstream
234          name: upstream
235      - name: Install test prerequisites
236        run: |
237          sudo DEBIAN_FRONTEND=noninteractive apt-get update
238          sudo DEBIAN_FRONTEND=noninteractive apt-get install python-tox python3-setuptools
239      - name: Update Sage packages from upstream artifact
240        run: |
241          (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)
[1a0966]242      - name: Configure and build Sage distribution within a Docker container
243        run: |
[d2074d]244          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::|;"
[1a0966]245      - name: Copy logs from the Docker image or build container
[d2074d]246        run: |
247          mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"
248          cp -r .tox/$TOX_ENV/Dockerfile .tox/$TOX_ENV/log "artifacts/$LOGS_ARTIFACT_NAME"
249          if [ -f .tox/$TOX_ENV/Dockertags ]; then CONTAINERS=$(docker create $(tail -1 .tox/$TOX_ENV/Dockertags) /bin/bash || true); fi
250          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
251        if: always()
252      - uses: actions/upload-artifact@v2
253        with:
254          path: artifacts
255          name: ${{ env.LOGS_ARTIFACT_NAME }}
256        if: always()
257      - name: Print out logs for immediate inspection
258        # and markup the output with GitHub Actions logging commands
259        run: |
260          .github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME"
261        if: always()
[1a0966]262      - name: Push Docker images
[d2074d]263        run: |
264          if [ -f .tox/$TOX_ENV/Dockertags ]; then
265            TOKEN="${{ secrets.DOCKER_PKG_GITHUB_TOKEN }}"
266            if [ -z "$TOKEN" ]; then
267              TOKEN="${{ secrets.GITHUB_TOKEN }}"
268            fi
269            echo "$TOKEN" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
270            for a in $(cat .tox/$TOX_ENV/Dockertags); do
271              FULL_TAG=docker.pkg.github.com/$(echo ${{ github.repository }}|tr 'A-Z' 'a-z')/$a
272              docker tag $a $FULL_TAG
273              echo Pushing $FULL_TAG
274              docker push $FULL_TAG
275            done || echo "(Ignoring errors)"
276          fi
277        if: always()
278
279  macos:
280
281    runs-on: macos-latest
282    strategy:
283      fail-fast: false
284      max-parallel: 4
285      matrix:
286        tox_system_factor: [homebrew-macos, homebrew-macos-python3_xcode, homebrew-macos-python3_xcode-nokegonly, conda-forge-macos]
287        tox_packages_factor: [minimal, standard]
288
289    needs: [dist]
290
291    env:
292      TOX_ENV: local-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}
293      LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-local-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}
294    steps:
295
296      - name: Check out SageMath
297        uses: actions/checkout@v2
298        with:
299          repository: ${{ env.SAGE_REPO }}
300          ref: ${{ env.SAGE_REF }}
301        if: env.SAGE_REPO != ''
302      - name: Check out git-trac-command
303        uses: actions/checkout@v2
304        with:
305          repository: sagemath/git-trac-command
306          path: git-trac-command
307        if: env.SAGE_TRAC_GIT != ''
308      - name: Check out SageMath from trac.sagemath.org
309        shell: bash {0}
310        run: |
[efb3fc]311          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
[d2074d]312        if: env.SAGE_TRAC_GIT != ''
313      - uses: actions/download-artifact@v2
314        with:
315          path: upstream
316          name: upstream
317      - name: Update Sage packages from upstream artifact
318        run: |
319          (export PATH=$(pwd)/build/bin:$PATH; (cd upstream && bash -x update-pkgs.sh) && git diff)
320
321      - name: Install test prerequisites
322        run: |
323          brew install tox
324      - name: Build and test with tox
325        # We use a high parallelization on purpose in order to catch possible parallelization bugs in the build scripts.
326        # For doctesting, we use a lower parallelization to avoid timeouts.
327        run: |
328          MAKE="make -j12" tox -e $TOX_ENV -- SAGE_NUM_THREADS=4 $TARGETS
329      - name: Prepare logs artifact
330        run: |
331          mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"; cp -r .tox/*/log "artifacts/$LOGS_ARTIFACT_NAME"
332        if: always()
333      - uses: actions/upload-artifact@v1
334        with:
335          path: artifacts
336          name: ${{ env.LOGS_ARTIFACT_NAME }}
337        if: always()
338      - name: Print out logs for immediate inspection
339        # and markup the output with GitHub Actions logging commands
340        run: |
341          .github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME"
342        if: always()
Note: See TracBrowser for help on using the repository browser.