Skip to content

Commit cdb870c

Browse files
danielyan86129facebook-github-bot
authored andcommitted
Update GitHub CI workflows (#356)
Summary: Update build-and-test and deploy GitHub Actions workflows for pyvrs2. Reviewed By: YLouWashU Differential Revision: D95732614
1 parent 38902b6 commit cdb870c

2 files changed

Lines changed: 60 additions & 10 deletions

File tree

.github/workflows/build-and-test.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ jobs:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
# UPDATED: Replaced macos-13 with macos-latest
16-
os: [ubuntu-latest, macos-latest]
15+
os: [ubuntu-latest, macos-14, macos-15]
1716
fail-fast: false
1817

1918
steps:
@@ -54,6 +53,31 @@ jobs:
5453
fi
5554
python -m pip install -U pip
5655
python -m pip install numpy typing dataclasses pytest parameterized Pillow
56+
57+
- name: Pre-download virtualenv to avoid GitHub rate limits
58+
env:
59+
GH_TOKEN: ${{ github.token }}
60+
run: |
61+
VIRTUALENV_VERSION=20.21.1
62+
if [ "$RUNNER_OS" == "macOS" ]; then
63+
CACHE_DIR="$HOME/Library/Caches/cibuildwheel"
64+
else
65+
CACHE_DIR="$HOME/.cache/cibuildwheel"
66+
fi
67+
mkdir -p "$CACHE_DIR"
68+
DEST="$CACHE_DIR/virtualenv-${VIRTUALENV_VERSION}.pyz"
69+
if [ ! -f "$DEST" ]; then
70+
# Use GitHub API (authenticated, 5000 req/hr) instead of raw blob URL (unauthenticated, 60 req/hr)
71+
curl -sL --retry 5 --retry-delay 10 --retry-all-errors \
72+
-H "Authorization: token ${GH_TOKEN}" \
73+
-H "Accept: application/vnd.github.v3.raw" \
74+
-o "$DEST" \
75+
"https://api.github.com/repos/pypa/get-virtualenv/contents/public/virtualenv.pyz?ref=${VIRTUALENV_VERSION}"
76+
fi
77+
ls -la "$DEST"
78+
79+
- name: Install cibuildwheel
80+
run: |
5781
python -m pip install cibuildwheel==2.17.0
5882
5983
- name: Build wheels for CPython
@@ -68,6 +92,8 @@ jobs:
6892
CIBW_BEFORE_BUILD_LINUX: bash scripts/install-manylinux-deps.sh
6993
CIBW_BEFORE_BUILD_MACOS: bash scripts/install-macos-deps.sh
7094
CIBW_SKIP: "*-manylinux_i686 *musllinux*"
95+
# Target macOS 14 (Sonoma) so wheels work on 14+.
96+
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=14.0
7197

7298
- name: Build and Test Python
7399
shell: bash

.github/workflows/deploy.yml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ jobs:
3535
python3 -m pip install setuptools wheel twine
3636
python3 setup.py sdist
3737
38-
- uses: actions/upload-artifact@v2
38+
- uses: actions/upload-artifact@v4
3939
with:
40-
name: python-package-distributions
40+
name: python-package-distributions-sdist
4141
path: dist/*.tar.gz
4242

4343
build-wheels:
@@ -54,11 +54,33 @@ jobs:
5454
- name: Set up Python
5555
uses: actions/setup-python@v5
5656
with:
57-
python-version: '3.9'
57+
python-version: '3.11'
5858
- name: Upgrade pip
5959
run: |
6060
python3 -m pip install --upgrade pip
6161
62+
- name: Pre-download virtualenv to avoid GitHub rate limits
63+
env:
64+
GH_TOKEN: ${{ github.token }}
65+
run: |
66+
VIRTUALENV_VERSION=20.21.1
67+
if [ "$RUNNER_OS" == "macOS" ]; then
68+
CACHE_DIR="$HOME/Library/Caches/cibuildwheel"
69+
else
70+
CACHE_DIR="$HOME/.cache/cibuildwheel"
71+
fi
72+
mkdir -p "$CACHE_DIR"
73+
DEST="$CACHE_DIR/virtualenv-${VIRTUALENV_VERSION}.pyz"
74+
if [ ! -f "$DEST" ]; then
75+
# Use GitHub API (authenticated, 5000 req/hr) instead of raw blob URL (unauthenticated, 60 req/hr)
76+
curl -sL --retry 5 --retry-delay 10 --retry-all-errors \
77+
-H "Authorization: token ${GH_TOKEN}" \
78+
-H "Accept: application/vnd.github.v3.raw" \
79+
-o "$DEST" \
80+
"https://api.github.com/repos/pypa/get-virtualenv/contents/public/virtualenv.pyz?ref=${VIRTUALENV_VERSION}"
81+
fi
82+
ls -la "$DEST"
83+
6284
- name: Install cibuildwheel
6385
run: |
6486
python3 -m pip install cibuildwheel==2.17.0
@@ -73,9 +95,11 @@ jobs:
7395
CIBW_BEFORE_BUILD_LINUX: bash scripts/install-manylinux-deps.sh
7496
CIBW_BEFORE_BUILD_MACOS: bash scripts/install-macos-deps.sh
7597
CIBW_SKIP: "*-manylinux_i686 *musllinux*"
76-
- uses: actions/upload-artifact@v2
98+
# Target macOS 14 (Sonoma) so wheels work on 14+.
99+
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=14.0
100+
- uses: actions/upload-artifact@v4
77101
with:
78-
name: python-package-distributions
102+
name: python-package-distributions-${{ matrix.os }}
79103
path: dist
80104

81105
publish-to-pypi:
@@ -84,13 +108,13 @@ jobs:
84108
- build-wheels
85109
- create-sdist
86110
steps:
87-
- name: Download wheels from previous jobs
111+
- name: Download all artifacts
88112
# by default this will download all artifacts
89-
uses: actions/download-artifact@v3
113+
uses: actions/download-artifact@v4
90114
with:
91-
name: python-package-distributions
92115
# PyPI publish action uploads everything under dist/* by default
93116
path: dist
117+
merge-multiple: true
94118

95119
- name: Display the list of artifacts
96120
run: ls -R dist

0 commit comments

Comments
 (0)