free mason #10
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: CI | |
| # on: | |
| # push: | |
| # branches: | |
| # - master | |
| # tags: | |
| # - '*' | |
| # pull_request: | |
| # branches: | |
| # - master | |
| jobs: | |
| cpp_edlib: | |
| name: "Check that CPP edlib correctly builds and passes tests." | |
| strategy: | |
| matrix: | |
| include: | |
| # I use different combos of OSes and compiler versions to cover as much version space as it reasonably makes sense. | |
| # ubuntu-22.04 comes with gcc 10, 11 and 12, and clang 13, 14 and 15. | |
| - { os: ubuntu-22.04, compiler: gcc-11 } | |
| - { os: ubuntu-22.04, compiler: clang-13 } | |
| # ubuntu-24.04 comes with gcc 12, 13 and 14, and clang 16, 17 and 18. | |
| - { os: ubuntu-24.04, compiler: gcc-14 } | |
| - { os: ubuntu-24.04, compiler: clang-18 } | |
| # macos-13 comes with gcc 12, 13 and 14, and clang 14. | |
| - { os: macos-13, compiler: gcc-12 } | |
| - { os: macos-13, compiler: clang-14 } | |
| # macos-14 comes with gcc 12, 13 and 14, and clang 15. | |
| - { os: macos-14, compiler: gcc-13 } | |
| - { os: macos-14, compiler: clang-15 } | |
| runs-on: ${{ matrix.os }} | |
| continue-on-error: true | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install system dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y valgrind | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Install Python packages | |
| run: | | |
| python -m pip install --upgrade pip setuptools meson ninja | |
| - name: Set C/CPP compiler to use | |
| run: | | |
| compiler="${{ matrix.compiler }}" | |
| if [[ "$compiler" =~ ^(gcc|clang)-[0-9]+$ ]]; then | |
| export CC="$compiler" | |
| export CXX="$(echo "$compiler" | sed -e 's/gcc/g++/' -e 's/clang/clang++/')" | |
| printenv CC CXX | |
| else | |
| echo "Error: Don't know how to set CC and CXX env vars for compiler '$compiler'" >&2 | |
| exit 1 | |
| fi | |
| - name: Build binaries and libraries and test them (with Meson) | |
| run: | | |
| make CXXFLAGS="-Werror" LIBRARY_TYPE=static BUILD_DIR=meson-build-static | |
| make CXXFLAGS="-Werror" LIBRARY_TYPE=shared BUILD_DIR=meson-build-shared | |
| # Check for memory leaks. | |
| # I run this only on linux because osx returns errors from | |
| # system libraries, which I would have to supress. | |
| if [ ${{ runner.os }} == "Linux" ]; then | |
| make check-memory-leaks BUILD_DIR=meson-build-static | |
| fi | |
| - name: Build binaries and libraries and test them (with CMake) | |
| run: | | |
| mkdir -p build && cd build | |
| CXXFLAGS="-Werror" cmake -GNinja .. | |
| ninja -v | |
| bin/runTests | |
| # TODO: I should have this step produce artifacts (wheels and sdist), but not deploy them. | |
| # Then, I should have another step that deploys them, therefore not deploying unless all jobs pass, | |
| # making sure we don't deploy only half of the wheels. | |
| python_edlib: | |
| name: "Build, test and possibly deploy python bindings for edlib" | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| deploy-sdist: true | |
| - os: macos-13 # intel runner | |
| # TODO: Get macos-14 building, currently I have an error with arch mismatch. | |
| # - os: macos-14 # apple silicon | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| working-directory: bindings/python | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Install Python deps | |
| run: | | |
| python -m pip install setuptools | |
| - name: Build edlib python module | |
| run: | | |
| make build | |
| - name: Test edlib python module | |
| run: | | |
| python test.py | |
| - name: Build sdist | |
| run: | | |
| make sdist | |
| # To ensure it doesn't get cleaned up by the `make wheels` or some other step. | |
| mv dist sdist | |
| - name: Build wheels | |
| run: | | |
| if [ ${{ matrix.os }} == "macos-13" ]; then | |
| # Default is x86-64 only, but this way we also build universal2 wheels, | |
| # which work on both intel (x86_64) and apple silicon (arm64). | |
| export CIBW_ARCHS_MACOS="x86_64 universal2" | |
| fi | |
| make wheels | |
| - name: Deploy sdist and Linux and Mac wheels to PyPI | |
| if: github.ref_type == 'tag' | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: | | |
| python -m pip install twine | |
| python -m twine upload --skip-existing wheelhouse/*.whl | |
| # While I do want to upload wheels for both Mac and Linux, | |
| # it makes no sense to upload sdist twice. | |
| if [ ${{ matrix.deploy-sdist }} == "true" ]; then | |
| python -m twine upload --skip-existing sdist/edlib-*.tar.gz | |
| fi | |