|
| 1 | +name: Reusable workflow for macOS portability CI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + # Either specify a stage |
| 7 | + stage: |
| 8 | + required: false |
| 9 | + type: string |
| 10 | + # Or specify targets |
| 11 | + targets_pre: |
| 12 | + default: build/make/Makefile |
| 13 | + type: string |
| 14 | + targets: |
| 15 | + default: build/make/Makefile |
| 16 | + type: string |
| 17 | + targets_optional: |
| 18 | + default: build/make/Makefile |
| 19 | + type: string |
| 20 | + # System configuration |
| 21 | + osversion_xcodeversion_toxenv_tuples: |
| 22 | + description: 'Stringified JSON object' |
| 23 | + default: >- |
| 24 | + [["latest", "", "homebrew-macos-usrlocal-minimal"], |
| 25 | + ["latest", "", "homebrew-macos-usrlocal-standard"], |
| 26 | + ["11", "xcode_11.7", "homebrew-macos-usrlocal-standard"], |
| 27 | + ["12", "", "homebrew-macos-usrlocal-standard"], |
| 28 | + ["13", "xcode_15.0", "homebrew-macos-usrlocal-standard"], |
| 29 | + ["latest", "", "homebrew-macos-usrlocal-maximal"], |
| 30 | + ["latest", "", "homebrew-macos-usrlocal-python3_xcode-standard"], |
| 31 | + ["latest", "", "conda-forge-macos-minimal"], |
| 32 | + ["latest", "", "conda-forge-macos-standard"], |
| 33 | + ["latest", "", "conda-forge-macos-maximal"]] |
| 34 | + type: string |
| 35 | + extra_sage_packages: |
| 36 | + description: 'Extra Sage packages to install as system packages' |
| 37 | + type: string |
| 38 | + default: "" |
| 39 | + max_parallel: |
| 40 | + type: number |
| 41 | + default: 10 |
| 42 | + free_disk_space: |
| 43 | + default: false |
| 44 | + type: boolean |
| 45 | + # |
| 46 | + # For use in upstream CIs. |
| 47 | + # |
| 48 | + upstream_artifact: |
| 49 | + required: false |
| 50 | + type: string |
| 51 | + sage_repo: |
| 52 | + required: false |
| 53 | + type: string |
| 54 | + sage_ref: |
| 55 | + required: false |
| 56 | + type: string |
| 57 | + |
| 58 | +jobs: |
| 59 | + local-macos: |
| 60 | + |
| 61 | + runs-on: macos-${{ matrix.osversion_xcodeversion_toxenv[0] }} |
| 62 | + strategy: |
| 63 | + fail-fast: false |
| 64 | + max-parallel: ${{ inputs.max_parallel }} |
| 65 | + matrix: |
| 66 | + osversion_xcodeversion_toxenv: ${{ fromJson(inputs.osversion_xcodeversion_toxenv_tuples) }} |
| 67 | + env: |
| 68 | + TOX_ENV: local-${{ matrix.osversion_xcodeversion_toxenv[2] }}${{ matrix.osversion_xcodeversion_toxenv[1] && format('-{0}', matrix.osversion_xcodeversion_toxenv[1]) }} |
| 69 | + LOCAL_ARTIFACT_NAME: sage-local-commit-${{ github.sha }}-tox-local-${{ matrix.osversion_xcodeversion_toxenv[2] }}-macos-${{ matrix.osversion_xcodeversion_toxenv[0] }}${{ matrix.osversion_xcodeversion_toxenv[1] && format('-{0}', matrix.osversion_xcodeversion_toxenv[1]) }} |
| 70 | + LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-local-${{ matrix.osversion_xcodeversion_toxenv[2] }}-macos-${{ matrix.osversion_xcodeversion_toxenv[0] }}${{ matrix.osversion_xcodeversion_toxenv[1] && format('-{0}', matrix.osversion_xcodeversion_toxenv[1]) }} |
| 71 | + steps: |
| 72 | + - name: Check out SageMath |
| 73 | + uses: actions/checkout@v4 |
| 74 | + with: |
| 75 | + repository: ${{ inputs.sage_repo }} |
| 76 | + ref: ${{ inputs.sage_ref }} |
| 77 | + fetch-depth: 10000 |
| 78 | + |
| 79 | + - name: Install test prerequisites |
| 80 | + run: | |
| 81 | + brew install tox |
| 82 | + - name: Download upstream artifact |
| 83 | + uses: actions/download-artifact@v3 |
| 84 | + with: |
| 85 | + path: upstream |
| 86 | + name: ${{ inputs.upstream_artifact }} |
| 87 | + if: inputs.upstream_artifact |
| 88 | + - name: Update Sage packages from upstream artifact |
| 89 | + run: | |
| 90 | + (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) |
| 91 | + if: inputs.upstream_artifact |
| 92 | + |
| 93 | + - name: Merge CI fixes from sagemath/sage |
| 94 | + run: | |
| 95 | + .ci/merge-fixes.sh |
| 96 | + env: |
| 97 | + GH_TOKEN: ${{ github.token }} |
| 98 | + |
| 99 | + - uses: actions/download-artifact@v3 |
| 100 | + with: |
| 101 | + path: sage-local-artifact |
| 102 | + name: ${{ env.LOCAL_ARTIFACT_NAME }} |
| 103 | + if: contains(inputs.stage, '2') |
| 104 | + - name: Extract sage-local artifact |
| 105 | + # This is macOS tar -- cannot use --listed-incremental |
| 106 | + run: | |
| 107 | + export SAGE_LOCAL=$(pwd)/.tox/$TOX_ENV/local |
| 108 | + .github/workflows/extract-sage-local.sh sage-local-artifact/sage-local-*.tar |
| 109 | + if: contains(inputs.stage, '2') |
| 110 | + - name: Build and test with tox |
| 111 | + # We use a high parallelization on purpose in order to catch possible parallelization bugs in the build scripts. |
| 112 | + # For doctesting, we use a lower parallelization to avoid timeouts. |
| 113 | + run: | |
| 114 | + case "${{ inputs.stage }}" in |
| 115 | + 1) export TARGETS_PRE="all-sage-local" TARGETS="all-sage-local" TARGETS_OPTIONAL="build/make/Makefile" |
| 116 | + ;; |
| 117 | + 2) export TARGETS_PRE="all-sage-local" TARGETS="build doc-html" TARGETS_OPTIONAL="ptest" |
| 118 | + ;; |
| 119 | + 2-optional*) export TARGETS_PRE="build/make/Makefile" TARGETS="build/make/Makefile" |
| 120 | + targets_pattern="${{ inputs.stage }}" |
| 121 | + targets_pattern="${targets_pattern#2-optional-}" |
| 122 | + export TARGETS_OPTIONAL=$( echo $(export PATH=build/bin:$PATH && sage-package list :optional: --has-file 'spkg-install.in|spkg-install|requirements.txt' --no-file huge|has_nonfree_dependencies | grep -v sagemath_doc | grep "^[$targets_pattern]" ) ) |
| 123 | + ;; |
| 124 | + 2-experimental*) export TARGETS_PRE="build/make/Makefile" TARGETS="build/make/Makefile" |
| 125 | + targets_pattern="${{ inputs.stage }}" |
| 126 | + targets_pattern="${targets_pattern#2-experimental-}" |
| 127 | + export TARGETS_OPTIONAL=$( echo $(export PATH=build/bin:$PATH && sage-package list :experimental: --has-file 'spkg-install.in|spkg-install|requirements.txt' --no-file huge|has_nonfree_dependencies | grep -v sagemath_doc | grep "^[$targets_pattern]" ) ) |
| 128 | + ;; |
| 129 | + *) export TARGETS_PRE="${{ inputs.targets_pre }}" TARGETS="${{ inputs.targets }} TARGETS_OPTIONAL="${{ inputs.targets_optional }} |
| 130 | + ;; |
| 131 | + esac |
| 132 | + MAKE="make -j12" tox -e $TOX_ENV -- SAGE_NUM_THREADS=4 $TARGETS |
| 133 | + - name: Prepare logs artifact |
| 134 | + run: | |
| 135 | + mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"; cp -r .tox/*/log "artifacts/$LOGS_ARTIFACT_NAME" |
| 136 | + if: always() |
| 137 | + - uses: actions/upload-artifact@v3 |
| 138 | + with: |
| 139 | + path: artifacts |
| 140 | + name: ${{ env.LOGS_ARTIFACT_NAME }} |
| 141 | + if: always() |
| 142 | + - name: Print out logs for immediate inspection |
| 143 | + # and markup the output with GitHub Actions logging commands |
| 144 | + run: | |
| 145 | + .github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME" |
| 146 | + if: always() |
| 147 | + - name: Prepare sage-local artifact |
| 148 | + # This also includes the copies of homebrew or conda installed in the tox environment. |
| 149 | + # We use absolute pathnames in the tar file. |
| 150 | + # This is macOS tar -- cannot use --remove-files. |
| 151 | + # We remove the $SAGE_LOCAL/lib64 link, which will be recreated by the next stage. |
| 152 | + run: | |
| 153 | + mkdir -p sage-local-artifact && (cd .tox/$TOX_ENV && rm -f "local/lib64" && tar -cf - $(pwd)) > sage-local-artifact/sage-${{ env.TOX_ENV }}-${{ inputs.stage }}.tar |
| 154 | + if: contains(inputs.stage, '1') |
| 155 | + - uses: actions/upload-artifact@v3 |
| 156 | + with: |
| 157 | + path: sage-local-artifact/sage-${{ env.TOX_ENV }}-${{ inputs.stage }}.tar |
| 158 | + name: ${{ env.LOCAL_ARTIFACT_NAME }} |
| 159 | + if: always() |
0 commit comments