Skip to content

Commit

Permalink
.github/workflows/ci-macos.yml: Factor through new reusable workflow …
Browse files Browse the repository at this point in the history
…macos.yml
  • Loading branch information
mkoeppe committed Sep 25, 2023
1 parent 4d3e807 commit ec922ec
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 82 deletions.
83 changes: 1 addition & 82 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,88 +31,7 @@ env:

jobs:
local-macos:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
stage: ["1", "2", "2-optional-0-o", "2-optional-p-z", "2-experimental-0-o", "2-experimental-p-z"]
# python3_xcode is only accepted if enough packages are available from the system
# --> to test "minimal", we would need https://github.com/sagemath/sage/issues/30949
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]
xcode_version_factor: [default]
os: [ macos-11, macos-12 ]
env:
TOX_ENV: local-${{ matrix.tox_env }}
LOCAL_ARTIFACT_NAME: sage-local-commit-${{ github.sha }}-tox-local-${{ matrix.tox_env }}-${{ matrix.os }}-xcode_${{ matrix.xcode_version_factor }}
LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-local-${{ matrix.tox_env }}--${{ matrix.os }}-xcode_${{ matrix.xcode_version_factor }}
steps:
- uses: actions/checkout@v4
- name: Select Xcode version
run: |
if [ ${{ matrix.xcode_version_factor }} != default ]; then sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode_version_factor }}.app; fi
- name: Install test prerequisites
run: |
brew install tox
- uses: actions/download-artifact@v3
with:
path: sage-local-artifact
name: ${{ env.LOCAL_ARTIFACT_NAME }}
if: contains(matrix.stage, '2')
- name: Extract sage-local artifact
# This is macOS tar -- cannot use --listed-incremental
run: |
export SAGE_LOCAL=$(pwd)/.tox/$TOX_ENV/local
.github/workflows/extract-sage-local.sh sage-local-artifact/sage-local-*.tar
if: contains(matrix.stage, '2')
- name: Build and test with tox
# We use a high parallelization on purpose in order to catch possible parallelization bugs in the build scripts.
# For doctesting, we use a lower parallelization to avoid timeouts.
run: |
case "${{ matrix.stage }}" in
1) export TARGETS_PRE="all-sage-local" TARGETS="all-sage-local" TARGETS_OPTIONAL="build/make/Makefile"
;;
2) export TARGETS_PRE="all-sage-local" TARGETS="build doc-html" TARGETS_OPTIONAL="ptest"
;;
2-optional*) export TARGETS_PRE="build/make/Makefile" TARGETS="build/make/Makefile"
targets_pattern="${{ matrix.stage }}"
targets_pattern="${targets_pattern#2-optional-}"
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]" ) )
;;
2-experimental*) export TARGETS_PRE="build/make/Makefile" TARGETS="build/make/Makefile"
targets_pattern="${{ matrix.stage }}"
targets_pattern="${targets_pattern#2-experimental-}"
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]" ) )
;;
esac
MAKE="make -j12" tox -e $TOX_ENV -- SAGE_NUM_THREADS=4 $TARGETS
- name: Prepare logs artifact
run: |
mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"; cp -r .tox/*/log "artifacts/$LOGS_ARTIFACT_NAME"
if: always()
- uses: actions/upload-artifact@v3
with:
path: artifacts
name: ${{ env.LOGS_ARTIFACT_NAME }}
if: always()
- name: Print out logs for immediate inspection
# and markup the output with GitHub Actions logging commands
run: |
.github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME"
if: always()
- name: Prepare sage-local artifact
# This also includes the copies of homebrew or conda installed in the tox environment.
# We use absolute pathnames in the tar file.
# This is macOS tar -- cannot use --remove-files.
# We remove the $SAGE_LOCAL/lib64 link, which will be recreated by the next stage.
run: |
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
if: contains(matrix.stage, '1')
- uses: actions/upload-artifact@v3
with:
path: sage-local-artifact/sage-${{ env.TOX_ENV }}-${{ matrix.stage }}.tar
name: ${{ env.LOCAL_ARTIFACT_NAME }}
if: always()
uses: ./.github/workflows/macos.yml

dist:

Expand Down
127 changes: 127 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Reusable workflow for macOS portability CI

on:
workflow_call:
inputs:
targets_pre:
default: build/make/Makefile
type: string
targets:
default: build/make/Makefile
type: string
targets_optional:
default: build/make/Makefile
type: string
osversion_xcodeversion_toxenv_tuples:
description: 'Stringified JSON object'
default: >-
[["latest", "", "homebrew-macos-usrlocal-minimal"],
["latest", "", "homebrew-macos-usrlocal-standard"],
["11", "11.7", "homebrew-macos-usrlocal-standard"],
["12", "", "homebrew-macos-usrlocal-standard"],
["13", "15.0", "homebrew-macos-usrlocal-standard"],
["latest", "", "homebrew-macos-usrlocal-maximal"],
["latest", "", "homebrew-macos-usrlocal-python3_xcode-standard"],
["latest", "", "conda-forge-macos-minimal"],
["latest", "", "conda-forge-macos-standard"],
["latest", "", "conda-forge-macos-maximal"]]
extra_sage_packages:
description: 'Extra Sage packages to install as system packages'
type: string
default: ""
max_parallel:
type: number
default: 10
free_disk_space:
default: false
type: boolean
#
# For use in upstream CIs.
#
upstream_artifact:
required: false
type: string
sage_repo:
required: false
type: string
sage_ref:
required: false
type: string

jobs:
local-macos:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
osversion_xcodeversion_toxenv: ${{ fromJson(inputs.osversion_xcodeversion_toxenv_tuples) }}
stage: ["1", "2", "2-optional-0-o", "2-optional-p-z", "2-experimental-0-o", "2-experimental-p-z"]
env:
TOX_ENV: local-${{ matrix.osversion_xcodeversion_toxenv[2] }}-xcode_${{ matrix.osversion_xcodeversion_toxenv[1] }}
LOCAL_ARTIFACT_NAME: sage-local-commit-${{ github.sha }}-tox-local-${{ matrix.osversion_xcodeversion_toxenv[2] }}-macos-${{ matrix.osversion_xcodeversion_toxenv[0] }}-xcode_${{ matrix.osversion_xcodeversion_toxenv[1] }}
LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-local-${{ matrix.osversion_xcodeversion_toxenv[2] }}-macos-${{ matrix.osversion_xcodeversion_toxenv[0] }}-xcode_${{ matrix.osversion_xcodeversion_toxenv[1] }}
steps:
- uses: actions/checkout@v4
- name: Install test prerequisites
run: |
brew install tox
- uses: actions/download-artifact@v3
with:
path: sage-local-artifact
name: ${{ env.LOCAL_ARTIFACT_NAME }}
if: contains(matrix.stage, '2')
- name: Extract sage-local artifact
# This is macOS tar -- cannot use --listed-incremental
run: |
export SAGE_LOCAL=$(pwd)/.tox/$TOX_ENV/local
.github/workflows/extract-sage-local.sh sage-local-artifact/sage-local-*.tar
if: contains(matrix.stage, '2')
- name: Build and test with tox
# We use a high parallelization on purpose in order to catch possible parallelization bugs in the build scripts.
# For doctesting, we use a lower parallelization to avoid timeouts.
run: |
case "${{ matrix.stage }}" in
1) export TARGETS_PRE="all-sage-local" TARGETS="all-sage-local" TARGETS_OPTIONAL="build/make/Makefile"
;;
2) export TARGETS_PRE="all-sage-local" TARGETS="build doc-html" TARGETS_OPTIONAL="ptest"
;;
2-optional*) export TARGETS_PRE="build/make/Makefile" TARGETS="build/make/Makefile"
targets_pattern="${{ matrix.stage }}"
targets_pattern="${targets_pattern#2-optional-}"
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]" ) )
;;
2-experimental*) export TARGETS_PRE="build/make/Makefile" TARGETS="build/make/Makefile"
targets_pattern="${{ matrix.stage }}"
targets_pattern="${targets_pattern#2-experimental-}"
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]" ) )
;;
esac
MAKE="make -j12" tox -e $TOX_ENV -- SAGE_NUM_THREADS=4 $TARGETS
- name: Prepare logs artifact
run: |
mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"; cp -r .tox/*/log "artifacts/$LOGS_ARTIFACT_NAME"
if: always()
- uses: actions/upload-artifact@v3
with:
path: artifacts
name: ${{ env.LOGS_ARTIFACT_NAME }}
if: always()
- name: Print out logs for immediate inspection
# and markup the output with GitHub Actions logging commands
run: |
.github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME"
if: always()
- name: Prepare sage-local artifact
# This also includes the copies of homebrew or conda installed in the tox environment.
# We use absolute pathnames in the tar file.
# This is macOS tar -- cannot use --remove-files.
# We remove the $SAGE_LOCAL/lib64 link, which will be recreated by the next stage.
run: |
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
if: contains(matrix.stage, '1')
- uses: actions/upload-artifact@v3
with:
path: sage-local-artifact/sage-${{ env.TOX_ENV }}-${{ matrix.stage }}.tar
name: ${{ env.LOCAL_ARTIFACT_NAME }}
if: always()
25 changes: 25 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,27 @@ setenv =
macos-12.3: MACOSX_DEPLOYMENT_TARGET=12.3
macos-13.3: MACOS_SDK=/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk
macos-13.3: MACOSX_DEPLOYMENT_TARGET=13.3
macos-14.0: MACOS_SDK=/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk
macos-14.0: MACOSX_DEPLOYMENT_TARGET=14.0
# XCode versions, as installed on GH Actions runners
# only in https://github.com/actions/runner-images/blob/main/images/macos/macos-11-Readme.md#xcode
xcode_11.7: XCODE_VERSION=11.7
xcode_12.4: XCODE_VERSION=12.4
xcode_12.5.1: XCODE_VERSION=12.5.1
xcode_13.0: XCODE_VERSION=13.0
# in above and also in https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md#xcode
xcode_13.1: XCODE_VERSION=13.1
xcode_13.2.1: XCODE_VERSION=13.2.1
# only in https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md#xcode
xcode_13.3.1: XCODE_VERSION=13.3.1
xcode_13.4.1: XCODE_VERSION=13.4.1
xcode_14.0.1: XCODE_VERSION=14.0.1
# in avove and also in https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode
xcode_14.1: XCODE_VERSION=14.1
xcode_14.2: XCODE_VERSION=14.2
# only in https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode
xcode_14.3.1: XCODE_VERSION=14.3.1
xcode_15.0: XCODE_VERSION=15.0
#
# Resulting full configuration args, including EXTRA_CONFIGURE_ARGS from the user environment
#
Expand Down Expand Up @@ -627,6 +648,10 @@ commands =
#
local: bash -c 'if [ ! -d {env:HOME}/Library/Caches ]; then mkdir -p {env:SHARED_CACHE_DIR} && mkdir -p {env:HOME}/Library && ln -sf {toxworkdir}/Caches {env:HOME}/Library/; fi'
#
# local-macos
#
local-macos: bash -c 'if [ -n "{env:XCODE_VERSION:}" ]; then sudo xcode-select -s /Applications/Xcode_{env:XCODE_VERSION:}; fi;'
#
# local-homebrew
#
# https://docs.brew.sh/Installation
Expand Down

0 comments on commit ec922ec

Please sign in to comment.