|
| 1 | +name: Run Sage CI for Linux |
| 2 | + |
| 3 | +## This GitHub Actions workflow provides: |
| 4 | +## |
| 5 | +## - portability testing, by building and testing this project on many platforms |
| 6 | +## |
| 7 | +## - continuous integration, by building and testing other software |
| 8 | +## that depends on this project. |
| 9 | +## |
| 10 | +## It runs on every pull request and push of a tag to the GitHub repository. |
| 11 | +## |
| 12 | +## The testing can be monitored in the "Actions" tab of the GitHub repository. |
| 13 | +## |
| 14 | +## After all jobs have finished (or are canceled) and a short delay, |
| 15 | +## tar files of all logs are made available as "build artifacts". |
| 16 | +## |
| 17 | +## This GitHub Actions workflow uses the portability testing framework |
| 18 | +## of SageMath (https://www.sagemath.org/). For more information, see |
| 19 | +## https://doc.sagemath.org/html/en/developer/portability_testing.html |
| 20 | + |
| 21 | +## The workflow consists of two jobs: |
| 22 | +## |
| 23 | +## - First, it builds a source distribution of the project |
| 24 | +## and generates a script "update-pkgs.sh". It uploads them |
| 25 | +## as a build artifact named upstream. |
| 26 | +## |
| 27 | +## - Second, it checks out a copy of the SageMath source tree. |
| 28 | +## It downloads the upstream artifact and replaces the project's |
| 29 | +## package in the SageMath distribution by the newly packaged one |
| 30 | +## from the upstream artifact, by running the script "update-pkgs.sh". |
| 31 | +## Then it builds a small portion of the Sage distribution. |
| 32 | +## |
| 33 | +## Many copies of the second step are run in parallel for each of the tested |
| 34 | +## systems/configurations. |
| 35 | + |
| 36 | +#on: [push, pull_request] |
| 37 | + |
| 38 | +on: |
| 39 | + pull_request: |
| 40 | + types: [opened, synchronize] |
| 41 | + push: |
| 42 | + tags: |
| 43 | + - '*' |
| 44 | + workflow_dispatch: |
| 45 | + # Allow to run manually |
| 46 | + |
| 47 | +env: |
| 48 | + # Ubuntu packages to install so that the project's "setup.py sdist" can succeed |
| 49 | + DIST_PREREQ: python3 |
| 50 | + # Name of this project in the Sage distribution |
| 51 | + SPKG: setuptools |
| 52 | + # Sage distribution packages to build |
| 53 | + TARGETS_PRE: build/make/Makefile |
| 54 | + TARGETS: setuptools pyzmq |
| 55 | + TARGETS_OPTIONAL: build/make/Makefile |
| 56 | + # Standard setting: Test the current beta release of Sage: |
| 57 | + SAGE_REPO: sagemath/sage |
| 58 | + SAGE_REF: develop |
| 59 | + # Temporarily test with the branch from sage ticket |
| 60 | + # (this is a no-op after that ticket is merged) |
| 61 | + #SAGE_TRAC_GIT: https://github.com/sagemath/sagetrac-mirror.git |
| 62 | + #SAGE_TICKET: 32579 |
| 63 | + REMOVE_PATCHES: "*" |
| 64 | + |
| 65 | +jobs: |
| 66 | + |
| 67 | + dist: |
| 68 | + runs-on: ubuntu-latest |
| 69 | + steps: |
| 70 | + - name: Check out ${{ env.SPKG }} |
| 71 | + uses: actions/checkout@v2 |
| 72 | + with: |
| 73 | + path: build/pkgs/${{ env.SPKG }}/src |
| 74 | + - name: Install prerequisites |
| 75 | + run: | |
| 76 | + sudo DEBIAN_FRONTEND=noninteractive apt-get update |
| 77 | + sudo DEBIAN_FRONTEND=noninteractive apt-get install $DIST_PREREQ |
| 78 | + python3 -m pip install build |
| 79 | + - name: Run make dist, prepare upstream artifact |
| 80 | + run: | |
| 81 | + (cd build/pkgs/${{ env.SPKG }}/src && python3 -m bootstrap && python3 -m build --sdist) \ |
| 82 | + && mkdir -p upstream && cp build/pkgs/${{ env.SPKG }}/src/dist/*.tar.gz upstream/${{ env.SPKG }}-git.tar.gz \ |
| 83 | + && echo "sage-package create ${{ env.SPKG }} --version git --tarball ${{ env.SPKG }}-git.tar.gz --type=standard" > 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 | + docker: |
| 92 | + runs-on: ubuntu-latest |
| 93 | + needs: [dist] |
| 94 | + strategy: |
| 95 | + fail-fast: false |
| 96 | + max-parallel: 32 |
| 97 | + matrix: |
| 98 | + tox_system_factor: [ubuntu-trusty, ubuntu-xenial, ubuntu-bionic, ubuntu-focal, ubuntu-groovy, ubuntu-hirsute, ubuntu-impish, debian-jessie, debian-stretch, debian-buster, debian-bullseye, debian-sid, linuxmint-17, linuxmint-18, linuxmint-19, linuxmint-19.3, linuxmint-20.1, linuxmint-20.2, fedora-26, fedora-27, fedora-28, fedora-29, fedora-30, fedora-31, fedora-32, fedora-33, fedora-34, fedora-35, centos-7, centos-8, gentoo, gentoo-python3.7, archlinux-latest, opensuse-15, opensuse-15.3, opensuse-tumbleweed, slackware-14.2, conda-forge, ubuntu-bionic-i386, manylinux-2_24-i686, debian-buster-i386, centos-7-i386, raspbian-buster-armhf] |
| 99 | + tox_packages_factor: [minimal, standard] |
| 100 | + env: |
| 101 | + TOX_ENV: docker-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }} |
| 102 | + LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-docker-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }} |
| 103 | + DOCKER_TARGETS: configured with-targets with-targets-optional |
| 104 | + steps: |
| 105 | + - name: Check out SageMath |
| 106 | + uses: actions/checkout@v2 |
| 107 | + with: |
| 108 | + repository: ${{ env.SAGE_REPO }} |
| 109 | + ref: ${{ env.SAGE_REF }} |
| 110 | + fetch-depth: 2000 |
| 111 | + if: env.SAGE_REPO != '' |
| 112 | + - name: Check out git-trac-command |
| 113 | + uses: actions/checkout@v2 |
| 114 | + with: |
| 115 | + repository: sagemath/git-trac-command |
| 116 | + path: git-trac-command |
| 117 | + if: env.SAGE_TRAC_GIT != '' |
| 118 | + - name: Check out SageMath from trac.sagemath.org |
| 119 | + shell: bash {0} |
| 120 | + run: | |
| 121 | + git config --global user.email "ci-sage@example.com" |
| 122 | + git config --global user.name "ci-sage workflow" |
| 123 | + 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 |
| 124 | + if: env.SAGE_TRAC_GIT != '' |
| 125 | + - uses: actions/download-artifact@v2 |
| 126 | + with: |
| 127 | + path: upstream |
| 128 | + name: upstream |
| 129 | + - name: Install test prerequisites |
| 130 | + run: | |
| 131 | + sudo DEBIAN_FRONTEND=noninteractive apt-get update |
| 132 | + sudo DEBIAN_FRONTEND=noninteractive apt-get install tox python3-setuptools |
| 133 | + - name: Update Sage packages from upstream artifact |
| 134 | + run: | |
| 135 | + (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) |
| 136 | + - name: Configure and build Sage distribution within a Docker container |
| 137 | + run: | |
| 138 | + 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::|;" |
| 139 | + - name: Copy logs from the Docker image or build container |
| 140 | + run: | |
| 141 | + mkdir -p "artifacts/$LOGS_ARTIFACT_NAME" |
| 142 | + cp -r .tox/$TOX_ENV/Dockerfile .tox/$TOX_ENV/log "artifacts/$LOGS_ARTIFACT_NAME" |
| 143 | + if [ -f .tox/$TOX_ENV/Dockertags ]; then CONTAINERS=$(docker create $(tail -1 .tox/$TOX_ENV/Dockertags) /bin/bash || true); fi |
| 144 | + 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 |
| 145 | + if: always() |
| 146 | + - uses: actions/upload-artifact@v2 |
| 147 | + with: |
| 148 | + path: artifacts |
| 149 | + name: ${{ env.LOGS_ARTIFACT_NAME }} |
| 150 | + if: always() |
| 151 | + - name: Print out logs for immediate inspection |
| 152 | + # and markup the output with GitHub Actions logging commands |
| 153 | + run: | |
| 154 | + .github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME" |
| 155 | + if: always() |
0 commit comments