Skip to content

Commit

Permalink
Merge pull request #22 from saudzahirr/Fix-ci/cd-pipeline
Browse files Browse the repository at this point in the history
Fix ci/cd pipeline
  • Loading branch information
saudzahirr authored Aug 30, 2024
2 parents 1b81c9c + fe3d1d9 commit ad06770
Show file tree
Hide file tree
Showing 384 changed files with 245 additions and 149 deletions.
2 changes: 2 additions & 0 deletions .github/publish
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/bash

49 changes: 0 additions & 49 deletions .github/workflows/ci-windows.yml

This file was deleted.

54 changes: 0 additions & 54 deletions .github/workflows/ci.yml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Linux Build and Test

on:
push:
branches:
- master
- Fix-ci/cd-pipeline
pull_request:
branches:
- master
- Fix-ci/cd-pipeline

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4

- name: Create Environment
run: |
conda env create -f environment.yml
- name: Build
run: |
source $(conda info --base)/etc/profile.d/conda.sh
conda activate vm
python install.py install
vonMises -m test/test-data/MATRIX.mat -k A > vonMises.log 2>&1
- name: Unittest
run: |
source $(conda info --base)/etc/profile.d/conda.sh
conda activate vm
pytest -s test/unit-test
- name: Code Lint
run: |
source $(conda info --base)/etc/profile.d/conda.sh
conda activate vm
ruff version
ruff format --check .
ruff check --output-format=github .
- name: Archive Logs
uses: actions/upload-artifact@v3
if: always()
with:
name: test-logs
path: |
build.log
vonMises.log
test/unit-test.log
test/*.log
53 changes: 53 additions & 0 deletions .github/workflows/win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Windows Build and Test

on:
push:
branches:
- master
- Fix-ci/cd-pipeline
pull_request:
branches:
- master
- Fix-ci/cd-pipeline

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v2

- name: Create Environment
run: conda env create -f environment.yml

- name: Build
run: |
conda activate vm
python install.py install
vonMises -m test\test-data\MATRIX.mat -k A > vonMises.log 2>&1
- name: Unittest
run: |
conda activate vm
pytest -s test\unit-test
- name: Code Lint
run: |
conda activate vm
ruff version
ruff format --check .
ruff check --output-format=github .
- name: Archive Logs
uses: actions/upload-artifact@v3
if: always()
with:
name: test-logs
path: |
build.log
vonMises.log
test\unit-test.log
test\*.log
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
__pycache__
.vscode/
.ruff_cache
.pytest_cache

*.egg-info
_skbuild/
Expand Down
36 changes: 18 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,39 @@ if(OpenMP_CXX_FOUND)
endif()

set(SOURCES
src/eigenlib/eigen_API.cpp
src/eigenlib/logger.cpp
src/eigenlib/rayleigh_quotient.cpp
src/eigenlib/utils.cpp
src/eigenlib/von_mises.cpp
src/vonmiseslib/vonMises_API.cpp
src/vonmiseslib/logger.cpp
src/vonmiseslib/rayleigh_quotient.cpp
src/vonmiseslib/utils.cpp
src/vonmiseslib/von_mises.cpp
)

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/src/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/src/vonmises/lib)

include_directories(src/lib)
include_directories(src/vonmises/lib)

# Add subdirectory for third-party libraries
add_subdirectory(src/eigenlib/thirdParty)
add_subdirectory(src/vonmiseslib/thirdParty)

# Include directories for Eigen and fmt
include_directories(src/eigenlib/thirdParty/Eigen_3.4.0)
include_directories(src/eigenlib/thirdParty/fmt-10.2.1/include)
include_directories(src/vonmiseslib/thirdParty/Eigen_3.4.0)
include_directories(src/vonmiseslib/thirdParty/fmt-10.2.1/include)

configure_file(
"${PROJECT_SOURCE_DIR}/src/eigenlib/version.h.in"
"${PROJECT_SOURCE_DIR}/src/eigenlib/version.h"
"${PROJECT_SOURCE_DIR}/src/vonmiseslib/version.h.in"
"${PROJECT_SOURCE_DIR}/src/vonmiseslib/version.h"
)

# Add shared library target for your main project
add_library(eigen SHARED ${SOURCES})
add_library(vonmises SHARED ${SOURCES})

# Link the fmt static library with your eigen shared library
target_link_libraries(eigen PRIVATE fmt)
# Link the fmt static library with your vonmises shared library
target_link_libraries(vonmises PRIVATE fmt)

# Link OpenMP if found
if(OpenMP_CXX_FOUND)
target_link_libraries(eigen PRIVATE OpenMP::OpenMP_CXX)
target_link_libraries(vonmises PRIVATE OpenMP::OpenMP_CXX)
endif()

# Install the eigen library
install(TARGETS eigen LIBRARY DESTINATION lib)
# Install the vonmises library
install(TARGETS vonmises LIBRARY DESTINATION lib)
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: vm
channels:
- conda-forge
dependencies:
- python=3.11
- python
- pip
- wheel
- setuptools
Expand Down
76 changes: 67 additions & 9 deletions install.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,70 @@
import subprocess
import time
import shlex
import shutil
import subprocess
import sys
from argparse import ArgumentParser
from pathlib import Path

wheel_cmd = shlex.split("python -m build -n -x --wheel")
build_cmd = shlex.split("pip wheel . -v -w dist ")
install_cmd = shlex.split("pip install . -v")
develop_cmd = shlex.split("pip install -e . -v")


def main(args=sys.argv[1:]):
prog = ArgumentParser(prog="Build vonMises")
prog.add_argument(
"mode",
help="""Build mode:
wheel -- only builds the wheel
develop -- creates an editable install
install -- performs a normal install
clean -- removes all build data""",
type=str,
choices=["wheel", "install", "develop", "clean"],
)

args = prog.parse_args(args)

# Log to a file
log_file = "build.log"

def run_command(command, log_file=log_file):
with open(log_file, "w") as log:
subprocess.run(command, check=True, stdout=log, stderr=log)

if args.mode == "wheel":
print("Starting wheel build")
run_command(build_cmd)

elif args.mode == "install":
print("Starting install")
run_command(install_cmd)

elif args.mode == "develop":
print("Starting development build")
run_command(develop_cmd)
print("Finished development build")

elif args.mode == "clean":
print("Starting cleanup")
subprocess.run(shlex.split("python -m pip uninstall vonMises -y"), check=True)
subprocess.run(shlex.split("git clean -xdff"), cwd="src", check=True)

for entry in Path("").iterdir():
if entry.name in [
"_skbuild",
"dist",
"build",
".pytest_cache",
] or entry.name.endswith("egg-info"):
print(f"Removing '{entry}'")
shutil.rmtree(entry)
if entry.suffix == ".log":
print(f"Removing '{entry}'")
entry.unlink()
print("Finished cleanup")

wheel_cmd = shlex.split("python -m pip wheel . -v -w dist ")
install_cmd = shlex.split("python -m pip install -e . -v")

with open("build.log", "w") as log:
rv = subprocess.Popen(wheel_cmd, stdout=log, stderr=log)
while rv.poll() is None:
time.sleep(0.5)
subprocess.run(install_cmd, stdout=log, stderr=log)
if __name__ == "__main__":
main()
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ requires-python = ">=3.11"
"Homepage" = "https://github.com/saudzahirr/vonMises"

[project.scripts]
"vonMises" = "src.__main__:main"
"vonMises" = "vonmises.__main__:main"

[tool.setuptools.packages.find]
where = ["."]
where = ["src"]
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import sys
from skbuild import setup

setup()
cmake_args = []
if sys.platform == "win32":
cmake_args.append("-G")
cmake_args.append("MinGW Makefiles")

setup(cmake_args=cmake_args)
File renamed without changes.
Loading

0 comments on commit ad06770

Please sign in to comment.