Repository navigation
Use uv for development, CI and docs builds #993
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: macOS | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.ref_name != 'master' }} | |
| jobs: | |
| cache_libs: | |
| uses: ./.github/workflows/cache_libs.yml | |
| secrets: inherit | |
| macosx: | |
| needs: cache_libs | |
| runs-on: macos-latest | |
| env: | |
| # Runners preinstall several Pythons. Use uv's own so every job in the matrix gets the same kind of build. | |
| UV_PYTHON_PREFERENCE: only-managed | |
| LIBICONV_VERSION: ${{ needs.cache_libs.outputs.LIBICONV_VERSION }} | |
| LIBXML2_VERSION: ${{ needs.cache_libs.outputs.LIBXML2_VERSION }} | |
| LIBXSLT_VERSION: ${{ needs.cache_libs.outputs.LIBXSLT_VERSION }} | |
| OPENSSL_VERSION: ${{ needs.cache_libs.outputs.OPENSSL_VERSION }} | |
| XMLSEC1_VERSION: ${{ needs.cache_libs.outputs.XMLSEC1_VERSION }} | |
| ZLIB_VERSION: ${{ needs.cache_libs.outputs.ZLIB_VERSION }} | |
| strategy: | |
| matrix: | |
| python: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"] | |
| static_deps: ["static", ""] | |
| steps: | |
| - uses: actions/checkout@v5.0.0 | |
| - name: Cache [libs] | |
| id: cache-libs | |
| uses: actions/cache/restore@v4.3.0 | |
| with: | |
| path: | | |
| libs/*.xz | |
| libs/*.gz | |
| libs/*.zip | |
| key: >- | |
| libs-${{ runner.os }}-${{ runner.arch }}-${{ env.LIBICONV_VERSION }}-${{ env.LIBXML2_VERSION }}-${{ env.LIBXSLT_VERSION }}-${{ env.OPENSSL_VERSION }}-${{ env.XMLSEC1_VERSION }}-${{ env.ZLIB_VERSION }} | |
| - uses: astral-sh/setup-uv@v10.3.3 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Install build dependencies | |
| run: brew install libxml2 libxmlsec1 pkg-config | |
| - name: Build macosx_x86_64 wheel | |
| env: | |
| CC: clang | |
| CFLAGS: "-fprofile-instr-generate -fcoverage-mapping" | |
| LDFLAGS: "-fprofile-instr-generate -fcoverage-mapping" | |
| PYXMLSEC_STATIC_DEPS: ${{ matrix.static_deps }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| export PKG_CONFIG_PATH="$(brew --prefix)/opt/libxml2/lib/pkgconfig" | |
| export PYXMLSEC_LIBS_DIR="$PWD/libs" | |
| uv build | |
| rm -rf build/ | |
| - name: Set environment variables | |
| shell: bash | |
| run: echo "LLVM_PROFILE_FILE=pyxmlsec.profraw" >> $GITHUB_ENV | |
| # Static and non-static jobs share a uv cache and build wheels with the same filename, so uv can | |
| # install the other job's cached wheel from dist/. --refresh-package makes it use the one just built. | |
| - name: Install test dependencies (static only) | |
| if: matrix.static_deps == 'static' | |
| run: | | |
| uv sync --locked --no-default-groups --group test --group coverage --no-install-project | |
| uv pip install xmlsec --only-binary xmlsec --no-index --find-links dist/ --refresh-package xmlsec | |
| - name: Install test dependencies (non-static only) | |
| if: matrix.static_deps != 'static' | |
| run: | | |
| export PKG_CONFIG_PATH="$(brew --prefix)/opt/libxml2/lib/pkgconfig" | |
| uv sync --locked --no-default-groups --group test --group coverage --no-install-project --no-binary-package lxml | |
| uv pip install xmlsec --only-binary xmlsec --no-index --find-links dist/ --refresh-package xmlsec | |
| # Assign separately so that a failed import stops this step. | |
| PYXMLSEC_LIBFILE="$(uv run --no-sync python -c 'import xmlsec; print(xmlsec.__file__)')" | |
| echo "PYXMLSEC_LIBFILE=$PYXMLSEC_LIBFILE" >> $GITHUB_ENV | |
| - name: Run tests | |
| run: | | |
| uv run --no-sync coverage run -m pytest -v --color=yes | |
| - name: Report coverage to codecov | |
| if: matrix.static_deps != 'static' | |
| run: | | |
| /Library/Developer/CommandLineTools/usr/bin/llvm-profdata merge -sparse ${{ env.LLVM_PROFILE_FILE }} -output pyxmlsec.profdata | |
| /Library/Developer/CommandLineTools/usr/bin/llvm-cov show ${{ env.PYXMLSEC_LIBFILE }} --arch=$(uname -m) --instr-profile=pyxmlsec.profdata src > coverage.txt | |
| bash <(curl -s https://codecov.io/bash) -f coverage.txt |