Enhancements to CI Workflows and Python Module Initialization with Minor Fixes #332
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 for general build | |
# This workflow handles the general build process including CMake configuration, | |
# C++ build, Python wrapper compilation, and testing across multiple platforms | |
on: | |
pull_request: | |
branches: [ master ] | |
types: [opened, synchronize, reopened] | |
workflow_dispatch: | |
# Prevent concurrent workflow runs on the same PR | |
concurrency: | |
group: cmake-${{ github.event.name }}-${{ github.event.pull_request.number || github.sha }} | |
cancel-in-progress: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PYTHONPATH: ${{ github.workspace }}/build/root/lib | |
LD_LIBRARY_PATH: ${{ github.workspace }}/build/root/lib | |
permissions: | |
contents: write | |
pull-requests: write | |
actions: write | |
checks: write | |
id-token: write | |
jobs: | |
build: | |
# Only run on pull requests from forks | |
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork || github.event_name == 'workflow_dispatch' | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-latest ] | |
arch: [ x64 ] | |
runs-on: ${{ matrix.os }} | |
# Inherit permissions from workflow level | |
# Removed redundant permissions block as it's inherited from workflow level | |
steps: | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y cmake build-essential swig python3-dev | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
with: | |
fetch-depth: 2 | |
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1 | |
with: | |
python-version: '3.x' | |
architecture: ${{matrix.arch}} | |
- name: Configure CMake | |
run: | | |
echo "Configuring CMake build..." | |
cmake -B ${{github.workspace}}/build \ | |
-DSPM_BUILD_TEST=ON \ | |
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/root | |
- name: Build | |
run: | | |
echo "Building with CMake..." | |
cmake --build ${{github.workspace}}/build --config Release --target install --parallel 8 | |
- name: Test | |
working-directory: ${{github.workspace}}/build | |
run: | | |
echo "Running tests..." | |
ctest -C Release --output-on-failure -V | |
- name: Package | |
working-directory: ${{github.workspace}}/build | |
run: | | |
echo "Creating package..." | |
cpack -V | |
- name: Build Python wrapper (Unix) | |
if: runner.os != 'Windows' | |
working-directory: ${{github.workspace}}/python | |
shell: bash | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
python -m pip install build pytest | |
python -m pip install --require-hashes --no-dependencies -r ../.github/workflows/requirements/base.txt | |
# Ensure we have the built C++ library in the Python path | |
echo "PYTHONPATH=${{github.workspace}}/build/root/lib" >> $GITHUB_ENV | |
echo "LD_LIBRARY_PATH=${{github.workspace}}/build/root/lib" >> $GITHUB_ENV | |
python setup.py build -v | |
python setup.py bdist_wheel -v | |
python -m pytest -v --log-cli-level=INFO | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: artifacts-${{ matrix.os }}-${{ matrix.arch }} | |
path: ./build/*.7z | |
- name: Upload Release Assets | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: svenstaro/upload-release-action@04733e069f2d7f7f0b4aebc4fbdbce8613b03ccd # v2.9.0 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ./build/*.7z | |
tag: ${{ github.ref }} | |
overwrite: true | |
prerelease: true | |
file_glob: true | |
body: "This is my release text" |