|
| 1 | +name: CI macOS |
| 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 | + workflow_dispatch: |
| 27 | + # Allow to run manually |
| 28 | + |
| 29 | +env: |
| 30 | + TARGETS_PRE: all-sage-local |
| 31 | + TARGETS: build doc-html |
| 32 | + TARGETS_OPTIONAL: ptest |
| 33 | + |
| 34 | +jobs: |
| 35 | + local-macos: |
| 36 | + |
| 37 | + runs-on: ${{ matrix.os }} |
| 38 | + strategy: |
| 39 | + fail-fast: false |
| 40 | + matrix: |
| 41 | + stage: ["1", "2", "2-optional-0-o", "2-optional-p-z", "2-experimental-0-o", "2-experimental-p-z"] |
| 42 | + # python3_xcode is only accepted if enough packages are available from the system |
| 43 | + # --> to test "minimal", we would need https://trac.sagemath.org/ticket/30949 |
| 44 | + tox_env: [homebrew-macos-usrlocal-minimal, homebrew-macos-usrlocal-standard, homebrew-macos-usrlocal-maximal, homebrew-macos-usrlocal-python3_xcode-standard, conda-forge-macos-minimal, conda-forge-macos-standard, conda-forge-macos-maximal] |
| 45 | + # As of 2021-12, default xcode |
| 46 | + # - on macos-10.15: 12.4 |
| 47 | + # - on macos-latest (= macos-11): 13.1 |
| 48 | + # https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md#xcode |
| 49 | + xcode_version_factor: [default] |
| 50 | + os: [ macos-10.15, macos-latest ] |
| 51 | + env: |
| 52 | + TOX_ENV: local-${{ matrix.tox_env }} |
| 53 | + LOCAL_ARTIFACT_NAME: sage-local-commit-${{ github.sha }}-tox-local-${{ matrix.tox_env }}-${{ matrix.os }}-xcode_${{ matrix.xcode_version_factor }} |
| 54 | + LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-local-${{ matrix.tox_env }}--${{ matrix.os }}-xcode_${{ matrix.xcode_version_factor }} |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v2 |
| 57 | + - name: Select Xcode version |
| 58 | + run: | |
| 59 | + if [ ${{ matrix.xcode_version_factor }} != default ]; then sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode_version_factor }}.app; fi |
| 60 | + - name: Install test prerequisites |
| 61 | + run: | |
| 62 | + brew install tox |
| 63 | + - uses: actions/download-artifact@v2 |
| 64 | + with: |
| 65 | + path: sage-local-artifact |
| 66 | + name: ${{ env.LOCAL_ARTIFACT_NAME }} |
| 67 | + if: contains(matrix.stage, '2') |
| 68 | + - name: Extract sage-local artifact |
| 69 | + # This is macOS tar -- cannot use --listed-incremental |
| 70 | + run: | |
| 71 | + export SAGE_LOCAL=$(pwd)/.tox/$TOX_ENV/local |
| 72 | + .github/workflows/extract-sage-local.sh sage-local-artifact/sage-local-*.tar |
| 73 | + if: contains(matrix.stage, '2') |
| 74 | + - name: Build and test with tox |
| 75 | + # We use a high parallelization on purpose in order to catch possible parallelization bugs in the build scripts. |
| 76 | + # For doctesting, we use a lower parallelization to avoid timeouts. |
| 77 | + run: | |
| 78 | + case "${{ matrix.stage }}" in |
| 79 | + 1) export TARGETS_PRE="all-sage-local" TARGETS="all-sage-local" TARGETS_OPTIONAL="" |
| 80 | + ;; |
| 81 | + 2) export TARGETS_PRE="all-sage-local" TARGETS="build doc-html" TARGETS_OPTIONAL="ptest" |
| 82 | + ;; |
| 83 | + 2-optional*) export TARGETS_PRE="build/make/Makefile" TARGETS="build/make/Makefile" |
| 84 | + targets_pattern="${{ matrix.stage }}" |
| 85 | + targets_pattern="${targets_pattern#2-optional-}" |
| 86 | + export TARGETS_OPTIONAL=$( echo $(export PATH=build/bin:$PATH && (for a in spkg-install.in spkg-install requirements.txt; do sage-package list :optional: --has-file $a --no-file huge --no-file has_nonfree_dependencies; done) | grep -v ^_ | grep -v sagemath_doc | grep "^[$targets_pattern]" ) ) |
| 87 | + ;; |
| 88 | + 2-experimental*) export TARGETS_PRE="build/make/Makefile" TARGETS="build/make/Makefile" |
| 89 | + targets_pattern="${{ matrix.stage }}" |
| 90 | + targets_pattern="${targets_pattern#2-experimental-}" |
| 91 | + export TARGETS_OPTIONAL=$( echo $(export PATH=build/bin:$PATH && (for a in spkg-install.in spkg-install requirements.txt; do sage-package list :experimental: --has-file $a --no-file huge --no-file has_nonfree_dependencies; done) | grep -v ^_ | grep -v sagemath_doc | grep "^[$targets_pattern]" ) ) |
| 92 | + ;; |
| 93 | + esac |
| 94 | + MAKE="make -j12" tox -e $TOX_ENV -- SAGE_NUM_THREADS=4 $TARGETS |
| 95 | + - name: Prepare logs artifact |
| 96 | + run: | |
| 97 | + mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"; cp -r .tox/*/log "artifacts/$LOGS_ARTIFACT_NAME" |
| 98 | + if: always() |
| 99 | + - uses: actions/upload-artifact@v1 |
| 100 | + with: |
| 101 | + path: artifacts |
| 102 | + name: ${{ env.LOGS_ARTIFACT_NAME }} |
| 103 | + if: always() |
| 104 | + - name: Print out logs for immediate inspection |
| 105 | + # and markup the output with GitHub Actions logging commands |
| 106 | + run: | |
| 107 | + .github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME" |
| 108 | + if: always() |
| 109 | + - name: Prepare sage-local artifact |
| 110 | + # This also includes the copies of homebrew or conda installed in the tox environment. |
| 111 | + # We use absolute pathnames in the tar file. |
| 112 | + # This is macOS tar -- cannot use --remove-files. |
| 113 | + # We remove the $SAGE_LOCAL/lib64 link, which will be recreated by the next stage. |
| 114 | + run: | |
| 115 | + mkdir -p sage-local-artifact && (cd .tox/$TOX_ENV && rm -f "local/lib64" && tar -cf - $(pwd)) > sage-local-artifact/sage-${{ env.TOX_ENV }}-${{ matrix.stage }}.tar |
| 116 | + if: contains(matrix.stage, '1') |
| 117 | + - uses: actions/upload-artifact@v2 |
| 118 | + with: |
| 119 | + path: sage-local-artifact/sage-${{ env.TOX_ENV }}-${{ matrix.stage }}.tar |
| 120 | + name: ${{ env.LOCAL_ARTIFACT_NAME }} |
| 121 | + if: always() |
| 122 | + |
| 123 | + dist: |
| 124 | + |
| 125 | + runs-on: ubuntu-latest |
| 126 | + steps: |
| 127 | + - uses: actions/checkout@v2 |
| 128 | + with: |
| 129 | + fetch-depth: 500 |
| 130 | + - name: fetch tags |
| 131 | + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* |
| 132 | + - name: Install bootstrap prerequisites |
| 133 | + run: | |
| 134 | + sudo DEBIAN_FRONTEND=noninteractive apt-get update |
| 135 | + sudo DEBIAN_FRONTEND=noninteractive apt-get install $(build/bin/sage-get-system-packages debian _bootstrap) |
| 136 | + - name: Bootstrap with sage-update-version |
| 137 | + # We set SAGE_ROOT and SAGE_SRC by hand |
| 138 | + # because 'sage -sh' does not work with an unconfigured tree, |
| 139 | + # giving: Error: SAGE_SCRIPTS_DIR is set to a bad value |
| 140 | + run: | |
| 141 | + git config --global user.email "[email protected]" |
| 142 | + git config --global user.name "Sage GitHub CI" |
| 143 | + SAGE_ROOT=. SAGE_SRC=./src src/bin/sage-update-version $(git describe) || echo "(ignoring error)" |
| 144 | + - name: make dist |
| 145 | + run: | |
| 146 | + ./configure --enable-download-from-upstream-url && make dist |
| 147 | + - uses: actions/upload-artifact@v2 |
| 148 | + with: |
| 149 | + path: "dist/*.tar.gz" |
| 150 | + name: dist |
| 151 | + |
| 152 | + local-macos-nohomebrew: |
| 153 | + |
| 154 | + needs: [dist] |
| 155 | + |
| 156 | + runs-on: ${{ matrix.os }} |
| 157 | + strategy: |
| 158 | + fail-fast: false |
| 159 | + max-parallel: 4 |
| 160 | + matrix: |
| 161 | + os: [ macos-10.15, macos-11.0 ] |
| 162 | + tox_system_factor: [macos-nobootstrap, macos-nobootstrap-python3_pythonorg] |
| 163 | + tox_packages_factor: [minimal] |
| 164 | + # As of 2021-03, default is 12.4 |
| 165 | + # https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md#xcode |
| 166 | + xcode_version_factor: [default] |
| 167 | + include: |
| 168 | + # Test xcode 11.7 only on macos-10.15 |
| 169 | + - tox_system_factor: macos-nobootstrap |
| 170 | + tox_packages_factor: minimal |
| 171 | + xcode_version_factor: 11.7 |
| 172 | + os: macos-10.15 |
| 173 | + - tox_system_factor: macos-nobootstrap-python3_pythonorg |
| 174 | + tox_packages_factor: minimal |
| 175 | + xcode_version_factor: 11.7 |
| 176 | + os: macos-10.15 |
| 177 | + env: |
| 178 | + TOX_ENV: local-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }} |
| 179 | + LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-local-${{ matrix.tox_system_factor }}-${{ matrix.tox_packages_factor }}-xcode_${{ matrix.xcode_version_factor }} |
| 180 | + steps: |
| 181 | + - uses: actions/checkout@v2 |
| 182 | + if: "!contains(matrix.tox_system_factor, 'nobootstrap')" |
| 183 | + - uses: actions/download-artifact@v2 |
| 184 | + with: |
| 185 | + path: . |
| 186 | + name: dist |
| 187 | + if: contains(matrix.tox_system_factor, 'nobootstrap') |
| 188 | + - name: Unpack sage dist |
| 189 | + run: | |
| 190 | + tar xf sage*.tar.gz --strip-components=1 |
| 191 | + if: contains(matrix.tox_system_factor, 'nobootstrap') |
| 192 | + - name: Move homebrew away |
| 193 | + run: | |
| 194 | + (cd /usr/local && for a in bin etc include lib opt sbin share; do sudo mv $a $a-moved; done) |
| 195 | + - name: Select Xcode version |
| 196 | + run: | |
| 197 | + if [ ${{ matrix.xcode_version_factor }} != default ]; then sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode_version_factor }}.app; fi |
| 198 | + - name: Install test prerequisites |
| 199 | + run: | |
| 200 | + sudo /usr/bin/python3 -m pip install tox |
| 201 | + - name: Install python3 from python.org |
| 202 | + # As of 2020-03-30 (https://github.com/actions/virtual-environments/blob/master/images/macos/macos-10.15-Readme.md), |
| 203 | + # Python 3.7.7 is installed on GitHub Actions runners. But we install our own copy from the python.org binary package. |
| 204 | + run: | |
| 205 | + curl -o python3.pkg https://www.python.org/ftp/python/3.7.7/python-3.7.7-macosx10.9.pkg |
| 206 | + sudo installer -verbose -pkg python3.pkg -target / |
| 207 | + if: contains(matrix.tox_system_factor, 'python3_pythonorg') |
| 208 | + - name: Build and test with tox |
| 209 | + # We use a high parallelization on purpose in order to catch possible parallelization bugs in the build scripts. |
| 210 | + # For doctesting, we use a lower parallelization to avoid timeouts. |
| 211 | + run: | |
| 212 | + MAKE="make -j12" tox -e $TOX_ENV -- SAGE_NUM_THREADS=4 $TARGETS |
| 213 | + - name: Prepare logs artifact |
| 214 | + run: | |
| 215 | + mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"; cp -r .tox/*/log "artifacts/$LOGS_ARTIFACT_NAME" |
| 216 | + if: always() |
| 217 | + - uses: actions/upload-artifact@v1 |
| 218 | + with: |
| 219 | + path: artifacts |
| 220 | + name: ${{ env.LOGS_ARTIFACT_NAME }} |
| 221 | + if: always() |
| 222 | + - name: Print out logs for immediate inspection |
| 223 | + # and markup the output with GitHub Actions logging commands |
| 224 | + run: | |
| 225 | + .github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME" |
| 226 | + if: always() |
0 commit comments