|
| 1 | +name: Test experimental packages with tox |
| 2 | + |
| 3 | +## This GitHub Actions workflow runs SAGE_ROOT/tox.ini with select environments, |
| 4 | +## whenever a GitHub pull request is opened or synchronized in a repository |
| 5 | +## where GitHub Actions are enabled. |
| 6 | +## |
| 7 | +## It builds and checks some sage spkgs as defined in TARGETS. |
| 8 | +## |
| 9 | +## A job succeeds if there is no error. |
| 10 | +## |
| 11 | +## The build is run with "make V=0", so the build logs of individual packages are suppressed. |
| 12 | +## |
| 13 | +## At the end, all package build logs that contain an error are printed out. |
| 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 | +#on: [push, pull_request] |
| 19 | + |
| 20 | +on: |
| 21 | + pull_request: |
| 22 | + types: [opened, synchronize] |
| 23 | + push: |
| 24 | + tags: |
| 25 | + - '*' |
| 26 | + |
| 27 | +env: |
| 28 | + TARGETS_PRE: build/make/Makefile |
| 29 | + TARGETS: build/make/Makefile |
| 30 | + # TARGETS_OPTIONAL see below |
| 31 | + |
| 32 | +jobs: |
| 33 | + docker: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + strategy: |
| 36 | + fail-fast: false |
| 37 | + max-parallel: 6 |
| 38 | + matrix: |
| 39 | + 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, gentoo, archlinux-latest, slackware-14.2, conda-forge, ubuntu-bionic-i386, ubuntu-eoan-i386, debian-buster-i386, centos-7-i386] |
| 40 | + tox_packages_factor: [maximal] |
| 41 | + targets_pattern: [0-g, h-o, p, q-z] |
| 42 | + env: |
| 43 | + TOX_ENV: docker-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }} |
| 44 | + LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-docker-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }} |
| 45 | + DOCKER_TARGETS: configured with-targets with-targets-optional |
| 46 | + TARGETS_OPTIONAL: "$( echo $(PATH=build/bin:$PATH build/bin/sage-package list :experimental: | grep -v database_stein_watkins\\$ | grep -v polytopes_db_4d | grep '^[${{ matrix.targets_pattern }}]' ) )" |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v2 |
| 49 | + with: |
| 50 | + fetch-depth: 500 |
| 51 | + - name: fetch tags |
| 52 | + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* |
| 53 | + - name: free disk space |
| 54 | + run: | |
| 55 | + sudo swapoff -a |
| 56 | + sudo rm -f /swapfile |
| 57 | + sudo apt clean |
| 58 | + docker rmi $(docker image ls -aq) |
| 59 | + df -h |
| 60 | + - name: Install test prerequisites |
| 61 | + run: | |
| 62 | + sudo DEBIAN_FRONTEND=noninteractive apt-get update |
| 63 | + sudo DEBIAN_FRONTEND=noninteractive apt-get install python-tox |
| 64 | + - run: | |
| 65 | + 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::|;" |
| 66 | + - name: Copy logs from the docker image or build container |
| 67 | + run: | |
| 68 | + mkdir -p "artifacts/$LOGS_ARTIFACT_NAME" |
| 69 | + cp -r .tox/$TOX_ENV/Dockerfile .tox/$TOX_ENV/log "artifacts/$LOGS_ARTIFACT_NAME" |
| 70 | + if [ -f .tox/$TOX_ENV/Dockertags ]; then CONTAINERS=$(docker create $(tail -1 .tox/$TOX_ENV/Dockertags) /bin/bash || true); fi |
| 71 | + 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 |
| 72 | + if: always() |
| 73 | + - uses: actions/upload-artifact@v1 |
| 74 | + with: |
| 75 | + path: artifacts |
| 76 | + name: ${{ env.LOGS_ARTIFACT_NAME }} |
| 77 | + if: always() |
| 78 | + - name: Print out logs for immediate inspection |
| 79 | + # and markup the output with GitHub Actions logging commands |
| 80 | + run: | |
| 81 | + .github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME" |
| 82 | + if: always() |
| 83 | + - name: Push docker images |
| 84 | + run: | |
| 85 | + if [ -f .tox/$TOX_ENV/Dockertags ]; then |
| 86 | + TOKEN="${{ secrets.DOCKER_PKG_GITHUB_TOKEN }}" |
| 87 | + if [ -z "$TOKEN" ]; then |
| 88 | + TOKEN="${{ secrets.GITHUB_TOKEN }}" |
| 89 | + fi |
| 90 | + echo "$TOKEN" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin |
| 91 | + for a in $(cat .tox/$TOX_ENV/Dockertags); do |
| 92 | + FULL_TAG=docker.pkg.github.com/${{ github.repository }}/$a |
| 93 | + docker tag $a $FULL_TAG |
| 94 | + echo Pushing $FULL_TAG |
| 95 | + docker push $FULL_TAG |
| 96 | + done || echo "(Ignoring errors)" |
| 97 | + fi |
| 98 | + if: always() |
| 99 | + |
| 100 | + local-macos: |
| 101 | + |
| 102 | + runs-on: macos-latest |
| 103 | + strategy: |
| 104 | + fail-fast: false |
| 105 | + max-parallel: 3 |
| 106 | + matrix: |
| 107 | + tox_system_factor: [homebrew-macos, homebrew-macos-python3_xcode, homebrew-macos-python3_xcode-nokegonly, homebrew-macos-python3_pythonorg, conda-forge-macos] |
| 108 | + tox_packages_factor: [maximal] |
| 109 | + targets_pattern: [0-g, h-o, p, q-z] |
| 110 | + env: |
| 111 | + TOX_ENV: local-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }} |
| 112 | + LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-local-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }} |
| 113 | + TARGETS_OPTIONAL: "$( echo $(PATH=build/bin:$PATH build/bin/sage-package list :experimental: | grep -v database_stein_watkins\\$ | grep -v polytopes_db_4d | grep '^[${{ matrix.targets_pattern }}]' ) )" |
| 114 | + steps: |
| 115 | + - uses: actions/checkout@v2 |
| 116 | + - name: Install test prerequisites |
| 117 | + run: | |
| 118 | + brew install tox |
| 119 | + - name: Install python3 from python.org |
| 120 | + # As of 2020-03-30 (https://github.com/actions/virtual-environments/blob/master/images/macos/macos-10.15-Readme.md), |
| 121 | + # Python 3.7.7 is installed on GitHub Actions runners. But we install our own copy from the python.org binary package. |
| 122 | + run: | |
| 123 | + curl -o python3.pkg https://www.python.org/ftp/python/3.7.7/python-3.7.7-macosx10.9.pkg |
| 124 | + sudo installer -verbose -pkg python3.pkg -target / |
| 125 | + if: contains(matrix.tox_system_factor, 'python3_pythonorg') |
| 126 | + - name: Build and test with tox |
| 127 | + # We use a high parallelization on purpose in order to catch possible parallelization bugs in the build scripts. |
| 128 | + # For doctesting, we use a lower parallelization to avoid timeouts. |
| 129 | + run: | |
| 130 | + MAKE="make -j12" tox -e $TOX_ENV -- SAGE_NUM_THREADS=4 $TARGETS |
| 131 | + - name: Prepare logs artifact |
| 132 | + run: | |
| 133 | + mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"; cp -r .tox/*/log "artifacts/$LOGS_ARTIFACT_NAME" |
| 134 | + if: always() |
| 135 | + - uses: actions/upload-artifact@v1 |
| 136 | + with: |
| 137 | + path: artifacts |
| 138 | + name: ${{ env.LOGS_ARTIFACT_NAME }} |
| 139 | + if: always() |
| 140 | + - name: Print out logs for immediate inspection |
| 141 | + # and markup the output with GitHub Actions logging commands |
| 142 | + run: | |
| 143 | + .github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME" |
| 144 | + if: always() |
0 commit comments