Skip to content

Commit 4a95a89

Browse files
authored
Add GitHub workflows back and update testing (#192)
1 parent 85ccad5 commit 4a95a89

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1185
-711
lines changed

.github/codecov.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# configuration for code coverage testing with codecov
2+
coverage:
3+
status:
4+
project:
5+
default:
6+
informational: true
7+
patch:
8+
default:
9+
informational: true
10+
codecov:
11+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/codechecks.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This workflow checks for compliance with the Google C++ style guide.
2+
name: Codechecks
3+
on: [push, pull_request]
4+
jobs:
5+
clang-format:
6+
runs-on: macos-latest
7+
steps:
8+
- uses: actions/checkout@v3
9+
- name: Install dependencies
10+
run: |
11+
brew install clang-format
12+
- name: Run clang-format
13+
run: |
14+
mkdir Release
15+
cd Release
16+
cmake ..
17+
make codecheck
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This workflow builds and deploys the html documentation for svZeroDSolver.
2+
name: Documentation
3+
on: [push, pull_request]
4+
permissions:
5+
contents: write
6+
jobs:
7+
documentation:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- name: Make build directory
12+
run: mkdir docs/build
13+
- name: Build doxygen documentation
14+
continue-on-error: false
15+
uses: mattnotmitt/doxygen-action@edge
16+
with:
17+
working-directory: '.'
18+
doxyfile-path: 'docs/Doxyfile'
19+
enable-latex: true
20+
- name: Save documentation
21+
uses: actions/upload-artifact@v4
22+
with:
23+
name: documentation
24+
path: ./docs/build/html
25+
- name: Deploy documentation
26+
if: github.ref == 'refs/heads/master'
27+
uses: peaceiris/actions-gh-pages@v3
28+
with:
29+
github_token: ${{ secrets.GITHUB_TOKEN }}
30+
publish_dir: ./docs/build/html

.github/workflows/gui.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This workflow uses Cypress for end-to-end testing of the 0D model GUI.
2+
3+
name: GUI-tests
4+
5+
on: [push, pull_request]
6+
7+
jobs:
8+
cypress-run:
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest, macos-latest]
12+
fail-fast: false
13+
runs-on: ${{ matrix.os }}
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v3
18+
19+
- name: Set up Node.js
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: '20'
23+
24+
- name: Install dependencies
25+
working-directory: tests/cypress
26+
run: npm install
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: '3.10' # Use the Python version compatible with your Flask app
32+
33+
- name: Install Flask dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
python -m pip install flask
37+
38+
- name: Start Flask Application
39+
run: |
40+
cd applications/svZeroDGUI
41+
FLASK_APP=app.py flask run --host=0.0.0.0 --port=8902 &
42+
env:
43+
FLASK_ENV: development
44+
45+
- name: Run Cypress tests
46+
uses: cypress-io/github-action@v5
47+
with:
48+
start: npm start
49+
working-directory: tests/cypress

.github/workflows/test.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# This workflow builds and tests svZeroDSolver. It is built and tested on
2+
# different versions of ubuntu and macOS.
3+
name: Build and test
4+
on: [push, pull_request]
5+
jobs:
6+
test:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
os: [ubuntu-22.04, ubuntu-latest, macos-13, macos-latest, windows-latest]
11+
version: [13] # GCC version
12+
fail-fast: false
13+
env:
14+
GCC_V: ${{ matrix.version }}
15+
CONDA_ENV: zerod
16+
PYTHONPATH: ${{ github.workspace }}
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: conda-incubator/setup-miniconda@v3
20+
with:
21+
auto-update-conda: true
22+
activate-environment: ${{env.CONDA_ENV}}
23+
python-version: "3.11.4"
24+
- name: Install ubuntu dependencies
25+
if: startsWith(matrix.os, 'ubuntu')
26+
run: sudo apt update && sudo apt install build-essential cmake lcov
27+
28+
- name: Install dependencies to get correct version numbers (Ubuntu)
29+
if: startsWith(matrix.os, 'ubuntu')
30+
run: conda install -c conda-forge libstdcxx-ng=${GCC_V} gcc=${GCC_V}
31+
32+
- name: Install dependencies to get correct version numbers (MacOS)
33+
if: startsWith(matrix.os, 'macos')
34+
run: |
35+
brew install gcc@${GCC_V}
36+
ln -s /usr/local/bin/gcc-${GCC_V} /usr/local/bin/gcc
37+
38+
- name: Install dependencies for windows
39+
if: startsWith(matrix.os, 'windows')
40+
shell: pwsh
41+
run: |
42+
choco install mingw --no-progress
43+
conda install -y -c conda-forge cmake graphviz python-graphviz pydot
44+
pip install --upgrade cmake-setuptools
45+
46+
- name: Install POISX-like svZeroDSolver
47+
if: ${{!startsWith(matrix.os, 'windows')}}
48+
run: conda run pip install -e ".[dev]"
49+
50+
- name: Install Windows svZeroDSolver
51+
if: startsWith(matrix.os, 'windows')
52+
shell: pwsh
53+
run: |
54+
$Env:CMAKE_GENERATOR = 'MinGW Makefiles'
55+
Write-Host "→ Using CMAKE_GENERATOR = $Env:CMAKE_GENERATOR"
56+
pip install --no-build-isolation -v .[dev]
57+
pip show pysvzerod
58+
59+
- name: Install Networkx
60+
run: |
61+
conda run pip install networkx
62+
63+
- name: Test the build
64+
run: |
65+
cd tests
66+
conda run pytest -v --durations=0 --ignore=test_dirgraph.py
67+
68+
- name: Build using CMake for POISX-like Systems
69+
if: ${{!startsWith(matrix.os, 'windows')}}
70+
run: |
71+
mkdir Release
72+
cd Release
73+
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_DISTRIBUTION=ON ..
74+
make -j2
75+
76+
- name: Build using CMake for Windows Systems
77+
if: startsWith(matrix.os, 'windows')
78+
shell: pwsh
79+
run: |
80+
mkdir Release
81+
cd Release
82+
cmake -G "MinGW Makefiles" `
83+
-DCMAKE_BUILD_TYPE=Release `
84+
-DENABLE_DISTRIBUTION=ON `
85+
..
86+
cmake --build . --parallel 2
87+
88+
- name: Test interface POISX-like Systems
89+
if: ${{!startsWith(matrix.os, 'windows')}}
90+
run: |
91+
cd tests/test_interface
92+
mkdir build_tests
93+
cd build_tests
94+
cmake ../
95+
make -j2
96+
cd test_01
97+
./svZeroD_interface_test01 ../../../../Release ../../test_01/svzerod_3Dcoupling.json
98+
cd ../test_02
99+
./svZeroD_interface_test02 ../../../../Release ../../test_02/svzerod_tuned.json
100+
101+
- name: Test interface Windows Systems
102+
if: startsWith(matrix.os, 'windows')
103+
shell: pwsh
104+
run: |
105+
cd tests/test_interface
106+
mkdir build_tests
107+
cd build_tests
108+
cmake -G "MinGW Makefiles" ..
109+
cmake --build . --parallel 2
110+
cd test_01
111+
./svZeroD_interface_test01.exe `
112+
../../../../Release `
113+
../../test_01/svzerod_3Dcoupling.json
114+
115+
cd ../test_02
116+
./svZeroD_interface_test02 `
117+
../../../../Release `
118+
../../test_02/svzerod_tuned.json
119+
120+
- name: Generate code coverage
121+
if: startsWith(matrix.os, 'ubuntu-22.04')
122+
run: |
123+
cd Release
124+
cmake -DENABLE_COVERAGE=ON ..
125+
make -j2
126+
cd ../tests
127+
conda run pytest -v --durations=0 --coverage --ignore=test_dirgraph.py
128+
cd ../Release
129+
make coverage
130+
131+
- name: Save coverage report
132+
if: startsWith(matrix.os, 'ubuntu-22.04')
133+
uses: actions/upload-artifact@v4
134+
with:
135+
name: coverage_report
136+
path: Release/coverage
137+
138+
- name: Upload coverage reports to Codecov
139+
if: startsWith(matrix.os, 'ubuntu-22.04')
140+
uses: codecov/codecov-action@v4
141+
env:
142+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
143+
144+
- name: Build installer POISX-like Systems
145+
if: ${{!startsWith(matrix.os, 'windows')}}
146+
run: |
147+
cd Release
148+
cpack
149+
cp distribution/svZeroDSolver_* ..
150+
151+
- name: Install NSIS
152+
if: startsWith(matrix.os, 'windows')
153+
run: choco install nsis -y
154+
155+
- name: Build installer Windows Systems
156+
if: startsWith(matrix.os, 'windows')
157+
shell: pwsh
158+
run: |
159+
# NSIS will be at C:\Program Files (x86)\NSIS\Bin
160+
echo "C:\Program Files (x86)\NSIS\Bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
161+
cd Release
162+
cpack -C Release
163+
Copy-Item distribution\svZeroDSolver_* -Destination ..\
164+
165+
- name: Upload installer
166+
uses: actions/upload-artifact@v4
167+
with:
168+
name: ${{ matrix.os }} installer
169+
path: svZeroDSolver_*
170+
if-no-files-found: error
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Test Visualization Application
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
strategy:
8+
matrix:
9+
os: [ubuntu-latest, macos-latest]
10+
fail-fast: false
11+
runs-on: ${{ matrix.os }}
12+
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.11'
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -r tests/requirements.txt
26+
27+
- name: Install Graphviz
28+
if: runner.os == 'Linux'
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -y graphviz
32+
33+
- name: Install Graphviz (macOS)
34+
if: runner.os == 'macOS'
35+
run: |
36+
brew install graphviz
37+
38+
- name: Run tests
39+
run: |
40+
pytest tests/test_dirgraph.py

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,13 @@ endif()
6565
# -----------------------------------------------------------------------------
6666
# Eigen is a header-only C++ template library for linear algebra.
6767
#
68+
# Tell FetchContent not to re-check for updates once Eigen is downloaded
69+
set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
70+
6871
FetchContent_Declare(
6972
Eigen
7073
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
71-
GIT_TAG master
74+
GIT_TAG 3.4.0
7275
GIT_SHALLOW TRUE
7376
GIT_PROGRESS TRUE)
7477

applications/pysvzerod.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the University of California, and others.
2-
// SPDX-License-Identifier: BSD-3-Clause
1+
// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the
2+
// University of California, and others. SPDX-License-Identifier: BSD-3-Clause
33
/**
44
* @file pysvzerod.cpp
55
* @brief Python interface for svZeroDSolver
@@ -65,9 +65,8 @@ PYBIND11_MODULE(pysvzerod, m) {
6565
py::module_ sys = py::module_::import("sys");
6666
auto argv = sys.attr("argv").cast<std::vector<std::string>>();
6767
if (argv.size() != 3) {
68-
std::cout
69-
<< "Usage: svzerodsolver path/to/config.json path/to/output.csv"
70-
<< std::endl;
68+
std::cout << "Usage: svzerodsolver path/to/config.json path/to/output.csv"
69+
<< std::endl;
7170
exit(1);
7271
}
7372
std::ifstream ifs(argv[1]);

applications/svzerodcalibrator.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the University of California, and others.
2-
// SPDX-License-Identifier: BSD-3-Clause
1+
// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the
2+
// University of California, and others. SPDX-License-Identifier: BSD-3-Clause
33
/**
44
* @file svzerodcalibrator.cpp
55
* @brief Main routine for svZeroDCalibrator
@@ -26,7 +26,8 @@ int main(int argc, char* argv[]) {
2626
std::ifstream input_file(input_file_name);
2727

2828
if (!input_file.is_open()) {
29-
std::cerr << "[svzerodcalibrator] Error: The input file '" << input_file_name << "' cannot be opened." << std::endl;
29+
std::cerr << "[svzerodcalibrator] Error: The input file '"
30+
<< input_file_name << "' cannot be opened." << std::endl;
3031
return 1;
3132
}
3233

@@ -36,16 +37,19 @@ int main(int argc, char* argv[]) {
3637
try {
3738
output_config = calibrate(config);
3839
} catch (const nlohmann::json::parse_error& e) {
39-
std::cerr << "[svzerodcalibrator] Error: The input file '" << input_file_name
40-
<< "' does not have the parameters needed by the calibrate program." << std::endl;
40+
std::cerr
41+
<< "[svzerodcalibrator] Error: The input file '" << input_file_name
42+
<< "' does not have the parameters needed by the calibrate program."
43+
<< std::endl;
4144
return 1;
4245
}
4346

4447
// Write optimized simulation config
4548
std::ofstream out_file(output_file_name);
4649

4750
if (!out_file.is_open()) {
48-
std::cerr << "[svzerodcalibrator] Error: The output file '" << output_file_name << "' cannot be opened." << std::endl;
51+
std::cerr << "[svzerodcalibrator] Error: The output file '"
52+
<< output_file_name << "' cannot be opened." << std::endl;
4953
return 1;
5054
}
5155

0 commit comments

Comments
 (0)