testing workflow #7
This file contains 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: Build and Test | |
on: | |
push: | |
branches: [main, workflow] | |
pull_request: | |
branches: [main, workflow] | |
jobs: | |
build-and-test: | |
name: Build and Test on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install system dependencies (Ubuntu) | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y \ | |
python3-dev \ | |
pybind11-dev \ | |
ninja-build \ | |
cmake \ | |
build-essential | |
- name: Install system dependencies (macOS) | |
if: runner.os == 'macOS' | |
run: | | |
brew install ninja pybind11 cmake | |
pip install --upgrade pip wheel setuptools | |
pip install "pybind11[global]" | |
# Verify the environment setup | |
- name: Verify environment | |
run: | | |
echo "Python: $(python --version)" | |
echo "Pip: $(pip --version)" | |
echo "Ninja: $(which ninja)" | |
ninja --version | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pytest meson>=1.3.2 meson-python numpy ninja | |
- name: Configure Meson | |
run: | | |
# On macOS, ensure ninja is in the system PATH | |
if [ "$RUNNER_OS" = "macOS" ]; then | |
export PATH="/usr/local/bin:$PATH" | |
fi | |
meson setup build | |
- name: Build | |
run: | | |
if [ "$RUNNER_OS" = "macOS" ]; then | |
export PATH="/usr/local/bin:$PATH" | |
fi | |
meson compile -C build | |
- name: Run C++ Tests | |
run: | | |
if [ "$RUNNER_OS" = "macOS" ]; then | |
export PATH="/usr/local/bin:$PATH" | |
fi | |
meson test -C build -v | |
- name: Install Python Package | |
run: | | |
if [ "$RUNNER_OS" = "macOS" ]; then | |
export PATH="/usr/local/bin:$PATH" | |
fi | |
pip install -e . | |
- name: Run Python Tests | |
run: | | |
if [ "$RUNNER_OS" = "macOS" ]; then | |
export PATH="/usr/local/bin:$PATH" | |
fi | |
# Verify module can be imported | |
python -c "import enigma; print('Enigma import successful')" | |
# Run tests | |
pytest python/tests -v | |
- name: Upload Test Results | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-results-${{ matrix.os }}-py${{ matrix.python-version }} | |
path: | | |
build/meson-logs/testlog.txt | |
build/meson-logs/meson-log.txt |