-
Notifications
You must be signed in to change notification settings - Fork 6
Add majority of CI features #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0fa891c
Add CI with build and format checks
43154d0
Updated build checker
zachhoulton 21b33fb
Support pybind11 shared lib build
zachhoulton 59c60f2
Add cpp and performance checks
zachhoulton c2e4e6f
added dynamic test support to CI framework, docker image for building…
a1rsman 6640d4f
fixed script for building wheels to work on rootless docker setups
a1rsman 61952bc
Integrated dynamic file, cleaned up build check
zachhoulton 53ab43e
setting up github actions for building wheels
a1rsman 19490f2
updated build_wheels.yml for windows and mac
a1rsman 6becc2c
Minor fixes
zachhoulton 7147d79
Merge branch 'ci' of github.com:SLAM-Lab/SANA-FE into ci
zachhoulton fb0b1ba
Merge branch 'v2.x' into ci
jamesaboyle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: Build | ||
|
|
||
| on: [push, pull_request] | ||
|
|
||
| jobs: | ||
| build_wheels: | ||
| name: Build wheels on ${{ matrix.os }} | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| # macos-13 is an intel runner, macos-14 is apple silicon | ||
| os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-13, macos-latest] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install flex and bison (platform-specific) | ||
| shell: bash | ||
| run: | | ||
| if [[ "$RUNNER_OS" == "macOS" ]]; then | ||
| brew install bison flex | ||
| echo 'PATH="/opt/homebrew/opt/bison/bin:/opt/homebrew/opt/flex/bin:$PATH"' >> $GITHUB_ENV | ||
| elif [[ "$RUNNER_OS" == "Windows" ]]; then | ||
| choco install winflexbison3 | ||
| echo 'C:\ProgramData\chocolatey\bin' >> $GITHUB_PATH | ||
| fi | ||
|
|
||
| - name: Build wheels | ||
| uses: pypa/cibuildwheel@v3.0.0 | ||
| # env: | ||
| # CIBW_SOME_OPTION: value | ||
| # ... | ||
| with: | ||
| # package-dir: . | ||
| # output-dir: wheelhouse | ||
| config-file: "{package}/pyproject.toml" | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | ||
| path: ./wheelhouse/*.whl | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,3 +33,5 @@ build/ | |
| CMakeFiles/ | ||
| Makefile | ||
| compile_commands.json | ||
| test_venv/ | ||
| *.so | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| #!/usr/bin/env ruby | ||
|
|
||
| require 'fileutils' | ||
|
|
||
| log_dir = ENV["SANAFE_CI_LOG_DIR"] || "logs/commit-latest" | ||
| log_file = "#{log_dir}/build.log" | ||
| FileUtils.mkdir_p(log_dir) | ||
|
|
||
|
|
||
| #build standalone sim | ||
| def build_cpp(label:, build_dir:, compiler: nil, log_file:) | ||
| puts "[#{label}] Building standalone simulator..." | ||
|
|
||
| cmake_cmd = "cmake -S . -B #{build_dir}" #construct cmake config command using source and build dirs | ||
| cmake_cmd += " -DCMAKE_CXX_COMPILER=#{compiler}" if compiler #add compiler option if provided | ||
| cmake_ok = system("#{cmake_cmd} > #{log_file} 2>&1") #run cmake, direct output to log file | ||
|
|
||
| if cmake_ok | ||
| make_ok = system("cmake --build #{build_dir} --parallel 8 >> #{log_file} 2>&1") #if cmake works, build and append output to log | ||
| end | ||
|
|
||
| if cmake_ok && make_ok | ||
| puts "[#{label}] Simulator build: PASS" | ||
| true | ||
| else | ||
| puts "[#{label}] Simulator build: FAIL (see #{log_file})" | ||
| false | ||
| end | ||
| end | ||
|
|
||
| #build and install python .so | ||
| def build_python(label:, build_dir:, log_file:) | ||
| puts "[#{label}] Building python extension..." | ||
|
|
||
| FileUtils.rm_f("CMakeCache.txt") | ||
| FileUtils.mkdir_p(build_dir) | ||
| FileUtils.mkdir_p(File.dirname(log_file)) | ||
|
|
||
| full_log_path = File.expand_path(log_file) | ||
|
|
||
| #create venv name | ||
| unique_id = ENV["SANAFE_CI_ID"] | ||
| venv_path = File.expand_path("#{File.dirname(log_file)}/venv") | ||
| venv_python = File.join(venv_path, "bin", "python") | ||
|
|
||
| FileUtils.mkdir_p("venvs") | ||
| unless system("python3 -m venv #{venv_path}") | ||
| puts "[#{label}] Failed to create virtualenv at #{venv_path}" | ||
| return false | ||
| end | ||
|
|
||
| install_ok = false | ||
| import_ok = false | ||
|
|
||
| File.open(full_log_path, "w") do |log| | ||
| Dir.chdir(build_dir) do | ||
| IO.popen("#{venv_python} -m pip install .. > /dev/null 2>&1") do |io| | ||
| io.each { |line| log.puts line } | ||
| end | ||
| install_ok = $?.success? | ||
| end | ||
| end | ||
|
|
||
| puts "[#{label}] Python build: #{install_ok ? 'PASS' : "FAIL (see #{log_file})"}" | ||
| install_ok | ||
| end | ||
|
|
||
| #set clang and gcc path | ||
| clang_path = ENV["CLANG_PATH"] | ||
| gcc_path = ENV["GCC_PATH"] | ||
|
|
||
| #gcc builds | ||
| gcc_sim_ok = build_cpp( | ||
| label: "GCC", | ||
| build_dir: "build_gcc", | ||
| compiler: gcc_path, | ||
| log_file: "#{log_dir}/build_gcc_sim.log" | ||
| ) | ||
| gcc_py_ok = build_python( | ||
| label: "GCC", | ||
| build_dir: "build_gcc_py", | ||
| log_file: "#{log_dir}/build_gcc_py.log" | ||
| ) | ||
|
|
||
| #clang builds | ||
| clang_sim_ok = build_cpp( | ||
| label: "Clang", | ||
| build_dir: "build_clang", | ||
| compiler: clang_path, | ||
| log_file: "#{log_dir}/build_clang_sim.log" | ||
| ) | ||
| clang_py_ok = build_python( | ||
| label: "Clang", | ||
| build_dir: "build_clang_py", | ||
| log_file: "#{log_dir}/build_clang_py.log" | ||
| ) | ||
|
|
||
| #final summary | ||
| all_ok = gcc_sim_ok && gcc_py_ok && clang_sim_ok && clang_py_ok | ||
| puts all_ok ? "All builds succeeded." : "One or more builds failed." | ||
| exit(all_ok ? 0 : 1) | ||
|
|
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #!/usr/bin/env ruby | ||
|
|
||
| require 'fileutils' | ||
|
|
||
| log_dir = ENV["SANAFE_CI_LOG_DIR"] || "logs/commit-latest" | ||
| log_file = "#{log_dir}/cppcheck.log" | ||
| FileUtils.mkdir_p(log_dir) | ||
|
|
||
| cpp_files = Dir.glob("src/*.cpp") + Dir.glob("plugins/*.cpp") | ||
| failed = false | ||
|
|
||
| File.open(log_file, "w") do |log| | ||
| log.puts "Running CPPCheck..." | ||
| cpp_files.each do |file| | ||
| log.puts "----- #{file} -----" | ||
| result = `cppcheck --enable=all --inconclusive --quiet --std=c++20 --language=c++ --suppress=missingIncludeSystem #{file} 2>&1` | ||
| log.puts result | ||
| failed ||= !result.strip.empty? | ||
| end | ||
| end | ||
|
|
||
| puts failed ? "CPPCheck: FAIL (see #{log_file})" : "CPPCheck: PASS" | ||
| exit(failed ? 1 : 0) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| #!/usr/bin/env ruby | ||
|
|
||
| require 'fileutils' | ||
|
|
||
| log_dir = ENV["SANAFE_CI_LOG_DIR"] || "logs/commit-latest" | ||
| build_log_file = "#{log_dir}/dynamic_build.log" | ||
| test_log_file = "#{log_dir}/dynamic_test.log" | ||
| FileUtils.mkdir_p(log_dir) | ||
|
|
||
| # timeout after 30 seconds | ||
| timeout = 30 | ||
|
|
||
| puts "Running dynamic tests..." | ||
|
|
||
| puts "Building the project with testing enabled..." | ||
|
|
||
| cmake = system("cmake -DENABLE_TESTING=ON -DPYTHON_BUILD_ENABLED=OFF -DSTANDALONE_BUILD_ENABLED=OFF -DCMAKE_BUILD_TYPE=Debug -S . -B build > #{build_log_file} 2>&1") | ||
|
|
||
| if !cmake | ||
| puts "CMake configuration failed. See #{build_log_file} for details." | ||
| puts "Dynamic Tests: FAIL" | ||
| exit 3 | ||
| end | ||
|
|
||
| build = system("cmake --build build -j 10 >> #{build_log_file} 2>&1") | ||
|
|
||
| if !build | ||
| puts "Build failed. See #{build_log_file} for details." | ||
| puts "Dynamic Tests: FAIL" | ||
| exit 3 | ||
| end | ||
|
|
||
| puts "Build successful. Running tests..." | ||
|
|
||
| test = system("ctest --memcheck --test-dir build --output-on-failure --timeout #{timeout} > #{test_log_file} 2>&1") | ||
| exitcode = $?.exitstatus | ||
|
|
||
| puts "Tests completed, now checking for memory leaks..." | ||
|
|
||
| build_dir = "build" | ||
| mem_log_dir = "#{build_dir}/Testing/Temporary" | ||
| pattern = "MemoryChecker.*\\.log$" | ||
| summary_log = File.join(mem_log_dir, "LastMemCheck.log") | ||
|
|
||
| unless Dir.exist?(mem_log_dir) | ||
| puts "Memory log directory #{mem_log_dir} does not exist. Something went wrong." | ||
| exit 2 | ||
| end | ||
|
|
||
| log_files = Dir.entries(mem_log_dir).select { |f| f.match?(pattern) } | ||
| puts "Found #{log_files.size} Valgrind log(s)." | ||
|
|
||
| leaks_found = false | ||
|
|
||
| log_files.each do |filename| | ||
| path = File.join(mem_log_dir, filename) | ||
| contents = File.read(path) | ||
|
|
||
| if contents.include?("definitely lost") | ||
| puts "Leak detected in #{filename}" | ||
| leaks_found = true | ||
| end | ||
| end | ||
|
|
||
| if leaks_found | ||
| puts "Memory leaks detected in one or more Valgrind logs. See #{mem_log_dir} for details." | ||
| puts "Dynamic Tests: FAIL" | ||
| exit 2 | ||
| end | ||
| if exitcode != 0 | ||
| puts "One or more tests failed. See #{test_log_file} for details." | ||
| puts "Dynamic Tests: FAIL" | ||
| exit 1 | ||
| else | ||
| puts "All tests passed successfully. Hooray! Check build/Testing/Temporary for memory leak reports." | ||
| puts "Dynamic Tests: PASS" | ||
| exit 0 | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #!/usr/bin/env ruby | ||
| #TODO: break format | ||
| require 'fileutils' | ||
|
|
||
| log_dir = ENV["SANAFE_CI_LOG_DIR"] || "logs/commit-latest" | ||
| log_file = "#{log_dir}/format.log" | ||
| FileUtils.mkdir_p(log_dir) | ||
|
|
||
| #find cpp files | ||
| cpp_files = Dir.glob("src/*.cpp") + Dir.glob("plugins/*.cpp") | ||
|
|
||
| failed_files = [] | ||
|
|
||
| File.open(log_file, "w") do |log| | ||
| cpp_files.each do |file| | ||
| result = `clang-format --dry-run --Werror #{file} 2>&1` | ||
| if $?.exitstatus != 0 | ||
| failed_files << file | ||
| log.puts "[FAIL] #{file}" | ||
| log.puts result | ||
| else | ||
| log.puts "[PASS] #{file}" | ||
| end | ||
| end | ||
|
|
||
| if failed_files.empty? | ||
| log.puts "\nAll files passed clang-format check." | ||
| else | ||
| log.puts "\n#{failed_files.size} file(s) failed formatting." | ||
| end | ||
| end | ||
|
|
||
| if failed_files.empty? | ||
| puts "Format Check: PASS" | ||
| else | ||
| puts "Format Check: FAIL (#{failed_files.size} file(s) failed, see #{log_file})" | ||
| end | ||
|
|
||
| exit(failed_files.empty? ? 0 : 1) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here we can add an if: clause, to check if the repository is jamesaboyle/SANA-FE (my local mirror)