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

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