Skip to content

Commit

Permalink
ci: 🎡 more CI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
darvid committed Feb 1, 2024
1 parent 68db2ad commit 90f2c5f
Showing 1 changed file with 79 additions and 36 deletions.
115 changes: 79 additions & 36 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,60 @@ concurrency:
cancel-in-progress: true

jobs:
build_environment:
name: ${{ matrix.os }} build environment
runs-on: ${{ matrix.os }}
env:
PCRE_VERSION: "8.45"

strategy:
fail-fast: true
matrix:
os: [ubuntu-22.04, macos-12-xl, macos-13-xl]

steps:
- name: Checkout python-hyperscan
uses: actions/checkout@v4

- name: Setup macOS environment
if: startsWith(matrix.os, 'macos')
run: |
gid=$(id -g)
uid=$(id -u)
sudo mkdir -p /opt/vectorscan /opt/pcre
sudo chown -R $uid:$gid /opt/vectorscan /opt/pcre
- name: Restore build dependencies cache (macOS)
id: build-deps-macos
if: startsWith(matrix.os, 'macos')
uses: actions/cache/restore@v4
with:
key: build-deps-${{ runner.os }}-${{ matrix.os }}
path: |
/opt/vectorscan
/opt/pcre
- name: Build Hyperscan (macOS)
if: startsWith(matrix.os, 'macos') && steps.build-deps-macos.outputs.cache-hit != 'true'
run: |
./build_tools/macos/build_hyperscan.sh
- name: Upload build dependencies (macOS)
if: startsWith(matrix.os, 'macos') && steps.build-deps-macos.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ steps.build-deps-macos.outputs.cache-primary-key }}
path: |
/opt/vectorscan
/opt/pcre
build_wheels:
name: ${{ matrix.python_id }}-${{ matrix.platform_id }} wheel
runs-on: ${{ matrix.os }}
if: github.repository == 'darvid/python-hyperscan'
env:
PCRE_VERSION: "8.45"
needs: [build_environment]

strategy:
fail-fast: false
Expand Down Expand Up @@ -164,44 +212,15 @@ jobs:
echo "version=$(pdm run semantic-release version --no-commit 2>/dev/null)" >> "$GITHUB_OUTPUT"
- name: Restore build artifacts cache
id: cache-dist
id: cache-wheels
uses: actions/cache/restore@v4
with:
key: ${{ runner.os }}-${{ matrix.python_id }}-${{ matrix.platform_id }}-${{ steps.semantic-version.outputs.version }}-${{ hashFiles('./src', './build_tools/**/build_*.sh') }}
path: |
wheelhouse/*.whl
- name: Setup macOS environment
if: startsWith(matrix.platform_id, 'macos')
run: |
sudo mkdir -p /opt/vectorscan /opt/pcre
- name: Restore build dependencies cache (macOS)
id: build-deps-macos
if: startsWith(matrix.platform_id, 'macos')
uses: actions/cache/restore@v4
with:
key: build-deps-${{ runner.os }}-${{ matrix.platform_id }}
path: |
/opt/vectorscan
/opt/pcre
- name: Build Hyperscan (macOS)
if: startsWith(matrix.platform_id, 'macos') && steps.build-deps-macos.outputs.cache-hit != 'true'
run: |
./build_tools/macos/build_hyperscan.sh
- name: Upload build dependencies (macOS)
if: startsWith(matrix.platform_id, 'macos') && steps.build-deps-macos.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ steps.build-deps-macos.outputs.cache-primary-key }}
path: |
/opt/vectorscan
/opt/pcre
- name: Build and test wheels
if: steps.cache-dist.outputs.cache-hit != 'true'
if: steps.cache-wheels.outputs.cache-hit != 'true'
env:
PCRE_VERSION: "${{env.PCRE_VERSION}}"
CIBW_ARCHS_MACOS: "${{ matrix.platform_id == 'macosx_arm64' && 'arm64' || 'x86_64' }}"
Expand All @@ -212,15 +231,15 @@ jobs:

- name: Save build artifacts
uses: actions/cache/save@v4
if: steps.cache-dist.outputs.cache-hit != 'true'
if: steps.cache-wheels.outputs.cache-hit != 'true'
with:
key: ${{ steps.cache-dist.outputs.cache-primary-key }}
key: ${{ steps.cache-wheels.outputs.cache-primary-key }}
path: |
wheelhouse/*.whl
- name: Upload wheels to artifacts
uses: actions/upload-artifact@v4
if: steps.cache-dist.outputs.cache-hit != 'true'
if: github.event_name == 'workflow_dispatch' || steps.cache-wheels.outputs.cache-hit != 'true'
with:
name: wheel-${{ matrix.python_id }}-${{ matrix.platform_id }}
path: |
Expand All @@ -230,29 +249,51 @@ jobs:
name: Source distribution
runs-on: ubuntu-22.04
steps:
- name: Restore source distribution cache
id: cache-sdist
uses: actions/cache/restore@v4
with:
key: sdist-${{ hashFiles('./src', './README.md', 'LICENSE', '*.py') }}
path: |
dist/*.tar.gz
- name: Checkout python-hyperscan
uses: actions/checkout@v4
with:
fetch-depth: 0
if: steps.cache-sdist.outputs.cache-hit != 'true'

- uses: pdm-project/setup-pdm@v4
with:
python-version: "3.11"
cache: true
if: steps.cache-sdist.outputs.cache-hit != 'true'

- name: Install Python deps
run: |
pdm install -G build -G release --no-self --no-lock -v
if: steps.cache-sdist.outputs.cache-hit != 'true'

- name: Increment version
run: pdm run semantic-release version --no-commit
if: steps.cache-sdist.outputs.cache-hit != 'true'

- name: Build source distribution
run: |
python setup.py sdist
if: steps.cache-sdist.outputs.cache-hit != 'true'

- name: Save source distribution cache
uses: actions/cache/save@v4
with:
key: ${{ steps.cache-sdist.outputs.cache-primary-key }}
path: |
dist/*.tar.gz
if: steps.cache-sdist.outputs.cache-hit != 'true'

- name: Upload source distribution to artifacts
uses: actions/upload-artifact@v4
if: github.event_name == 'workflow_dispatch' || steps.cache-sdist.outputs.cache-hit != 'true'
with:
name: sdist
path: |
Expand Down Expand Up @@ -297,8 +338,10 @@ jobs:
if: github.event_name == 'workflow_dispatch' || steps.release.outputs.released == 'true'
run: |
mkdir dist
mv ./wheel-*/*.whl dist/
mv ./sdist/*.tar.gz dist/
mv --backup=numbered ./wheel-*/*.whl -t dist/
mv --backup=numbered ./sdist/*.tar.gz -t dist/
ls -ahl dist/
rm -rf dist/*~
- name: Create release branch
if: steps.release.outputs.released == 'true'
Expand Down

0 comments on commit 90f2c5f

Please sign in to comment.