Skip to content

Commit 4ba2b6a

Browse files
author
Matthias Koeppe
committed
.github/workflows/ci-macos.yml: Refactor through new reusable workflow macos.yml, update macOS, Xcode versions
1 parent 0a27b65 commit 4ba2b6a

File tree

3 files changed

+217
-82
lines changed

3 files changed

+217
-82
lines changed

.github/workflows/ci-macos.yml

Lines changed: 33 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -30,89 +30,40 @@ env:
3030
TARGETS_OPTIONAL: ptest
3131

3232
jobs:
33-
local-macos:
33+
stage-1:
34+
uses: ./.github/workflows/macos.yml
35+
with:
36+
stage: "1"
3437

35-
runs-on: ${{ matrix.os }}
36-
strategy:
37-
fail-fast: false
38-
matrix:
39-
stage: ["1", "2", "2-optional-0-o", "2-optional-p-z", "2-experimental-0-o", "2-experimental-p-z"]
40-
# python3_xcode is only accepted if enough packages are available from the system
41-
# --> to test "minimal", we would need https://github.com/sagemath/sage/issues/30949
42-
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]
43-
xcode_version_factor: [default]
44-
os: [ macos-11, macos-12 ]
45-
env:
46-
TOX_ENV: local-${{ matrix.tox_env }}
47-
LOCAL_ARTIFACT_NAME: sage-local-commit-${{ github.sha }}-tox-local-${{ matrix.tox_env }}-${{ matrix.os }}-xcode_${{ matrix.xcode_version_factor }}
48-
LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-tox-local-${{ matrix.tox_env }}--${{ matrix.os }}-xcode_${{ matrix.xcode_version_factor }}
49-
steps:
50-
- uses: actions/checkout@v4
51-
- name: Select Xcode version
52-
run: |
53-
if [ ${{ matrix.xcode_version_factor }} != default ]; then sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode_version_factor }}.app; fi
54-
- name: Install test prerequisites
55-
run: |
56-
brew install tox
57-
- uses: actions/download-artifact@v3
58-
with:
59-
path: sage-local-artifact
60-
name: ${{ env.LOCAL_ARTIFACT_NAME }}
61-
if: contains(matrix.stage, '2')
62-
- name: Extract sage-local artifact
63-
# This is macOS tar -- cannot use --listed-incremental
64-
run: |
65-
export SAGE_LOCAL=$(pwd)/.tox/$TOX_ENV/local
66-
.github/workflows/extract-sage-local.sh sage-local-artifact/sage-local-*.tar
67-
if: contains(matrix.stage, '2')
68-
- name: Build and test with tox
69-
# We use a high parallelization on purpose in order to catch possible parallelization bugs in the build scripts.
70-
# For doctesting, we use a lower parallelization to avoid timeouts.
71-
run: |
72-
case "${{ matrix.stage }}" in
73-
1) export TARGETS_PRE="all-sage-local" TARGETS="all-sage-local" TARGETS_OPTIONAL="build/make/Makefile"
74-
;;
75-
2) export TARGETS_PRE="all-sage-local" TARGETS="build doc-html" TARGETS_OPTIONAL="ptest"
76-
;;
77-
2-optional*) export TARGETS_PRE="build/make/Makefile" TARGETS="build/make/Makefile"
78-
targets_pattern="${{ matrix.stage }}"
79-
targets_pattern="${targets_pattern#2-optional-}"
80-
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]" ) )
81-
;;
82-
2-experimental*) export TARGETS_PRE="build/make/Makefile" TARGETS="build/make/Makefile"
83-
targets_pattern="${{ matrix.stage }}"
84-
targets_pattern="${targets_pattern#2-experimental-}"
85-
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]" ) )
86-
;;
87-
esac
88-
MAKE="make -j12" tox -e $TOX_ENV -- SAGE_NUM_THREADS=4 $TARGETS
89-
- name: Prepare logs artifact
90-
run: |
91-
mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"; cp -r .tox/*/log "artifacts/$LOGS_ARTIFACT_NAME"
92-
if: always()
93-
- uses: actions/upload-artifact@v3
94-
with:
95-
path: artifacts
96-
name: ${{ env.LOGS_ARTIFACT_NAME }}
97-
if: always()
98-
- name: Print out logs for immediate inspection
99-
# and markup the output with GitHub Actions logging commands
100-
run: |
101-
.github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME"
102-
if: always()
103-
- name: Prepare sage-local artifact
104-
# This also includes the copies of homebrew or conda installed in the tox environment.
105-
# We use absolute pathnames in the tar file.
106-
# This is macOS tar -- cannot use --remove-files.
107-
# We remove the $SAGE_LOCAL/lib64 link, which will be recreated by the next stage.
108-
run: |
109-
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
110-
if: contains(matrix.stage, '1')
111-
- uses: actions/upload-artifact@v3
112-
with:
113-
path: sage-local-artifact/sage-${{ env.TOX_ENV }}-${{ matrix.stage }}.tar
114-
name: ${{ env.LOCAL_ARTIFACT_NAME }}
115-
if: always()
38+
stage-2:
39+
uses: ./.github/workflows/macos.yml
40+
with:
41+
stage: "2"
42+
needs: [stage-1]
43+
44+
stage-2-optional-0-o:
45+
uses: ./.github/workflows/macos.yml
46+
with:
47+
stage: "2-optional-0-o"
48+
needs: [stage-2]
49+
50+
stage-2-optional-p-z:
51+
uses: ./.github/workflows/macos.yml
52+
with:
53+
stage: "2-optional-p-z"
54+
needs: [stage-2-optional-0-o]
55+
56+
stage-2-experimental-0-o:
57+
uses: ./.github/workflows/macos.yml
58+
with:
59+
stage: "2-optional-0-o"
60+
needs: [stage-2-optional-p-z]
61+
62+
stage-2-experimental-p-z:
63+
uses: ./.github/workflows/macos.yml
64+
with:
65+
stage: "2-experimental-p-z"
66+
needs: [stage-2-experimental-0-o]
11667

11768
dist:
11869

.github/workflows/macos.yml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
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()

tox.ini

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,27 @@ setenv =
601601
macos-12.3: MACOSX_DEPLOYMENT_TARGET=12.3
602602
macos-13.3: MACOS_SDK=/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk
603603
macos-13.3: MACOSX_DEPLOYMENT_TARGET=13.3
604+
macos-14.0: MACOS_SDK=/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk
605+
macos-14.0: MACOSX_DEPLOYMENT_TARGET=14.0
606+
# XCode versions, as installed on GH Actions runners
607+
# only in https://github.com/actions/runner-images/blob/main/images/macos/macos-11-Readme.md#xcode
608+
xcode_11.7: XCODE_VERSION=11.7
609+
xcode_12.4: XCODE_VERSION=12.4
610+
xcode_12.5.1: XCODE_VERSION=12.5.1
611+
xcode_13.0: XCODE_VERSION=13.0
612+
# in above and also in https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md#xcode
613+
xcode_13.1: XCODE_VERSION=13.1
614+
xcode_13.2.1: XCODE_VERSION=13.2.1
615+
# only in https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md#xcode
616+
xcode_13.3.1: XCODE_VERSION=13.3.1
617+
xcode_13.4.1: XCODE_VERSION=13.4.1
618+
xcode_14.0.1: XCODE_VERSION=14.0.1
619+
# in avove and also in https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode
620+
xcode_14.1: XCODE_VERSION=14.1
621+
xcode_14.2: XCODE_VERSION=14.2
622+
# only in https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode
623+
xcode_14.3.1: XCODE_VERSION=14.3.1
624+
xcode_15.0: XCODE_VERSION=15.0
604625
#
605626
# Resulting full configuration args, including EXTRA_CONFIGURE_ARGS from the user environment
606627
#
@@ -629,6 +650,10 @@ commands =
629650
#
630651
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'
631652
#
653+
# local-macos
654+
#
655+
local-macos: bash -c 'if [ -n "{env:XCODE_VERSION:}" ]; then sudo xcode-select -s /Applications/Xcode_{env:XCODE_VERSION:}.app; fi;'
656+
#
632657
# local-homebrew
633658
#
634659
# https://docs.brew.sh/Installation

0 commit comments

Comments
 (0)