-
Notifications
You must be signed in to change notification settings - Fork 30
Add static analysis using fortitude, clang, and ruff #187
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
13 commits
Select commit
Hold shift + click to select a range
0aa8edd
Apply fortitude linter to ftorch.f90 and add fortitude config file.
jatkinson1000 518bace
Apply fortitude to ftorch_test_utils.
jatkinson1000 8e254d3
Apply fortitude to the Fortran in the examples.
jatkinson1000 a11d643
run clang-format on C++ and C-header files.
jatkinson1000 06bffe1
Explicitly include stdint header in ctorch.h for int64_t following cl…
jatkinson1000 842370d
Add a linting workflow using fortitude and clang.
jatkinson1000 933a282
Update examples to specify precision/kind for all floating point cons…
jatkinson1000 ccf7502
Add a ruff.toml config file for linting python and add ruff to the li…
jatkinson1000 15727fa
Remove old black workflow as superceded by ruff.
jatkinson1000 0bcb106
Apply ruff to the examples.
jatkinson1000 2e75e01
Apply ruff to utils/
jatkinson1000 a0c78ff
Add developer documentation about linting tools.
jatkinson1000 11c8e4d
Provide requirements file and update linting workflow to use (pins li…
jatkinson1000 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,97 @@ | ||
# workflow to run static-analysis and linting checks on source | ||
|
||
name: StaticAnalysis | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on pushes to the "main" branch and any pull request events | ||
push: | ||
branches: [ "main"] | ||
pull_request: | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# Workflow run - one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "static-analysis" | ||
static-analysis: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m venv ftorch_venv | ||
. ftorch_venv/bin/activate | ||
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu | ||
pip install -r requirements.txt | ||
|
||
# Run CMake build to get compile commands for clang | ||
- name: FTorch CMake | ||
run: | | ||
. ftorch_venv/bin/activate | ||
export FT_DIR=$(pwd) | ||
VN=$(python -c "import sys; print('.'.join(sys.version.split('.')[:2]))") | ||
export Torch_DIR=${VIRTUAL_ENV}/lib/python${VN}/site-packages | ||
export BUILD_DIR=$(pwd)/src/build | ||
mkdir ${BUILD_DIR} | ||
cd ${BUILD_DIR} | ||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${BUILD_DIR} -DCMAKE_Fortran_FLAGS="-std=f2008" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON | ||
|
||
# Apply Fortran linter, fortitude | ||
# Configurable using the fortitude.toml file if present | ||
- name: fortitude source | ||
if: always() | ||
run: | | ||
cd ${{ github.workspace }} | ||
. ftorch_venv/bin/activate # Uses .clang-tidy config file if present | ||
fortitude check src/ | ||
|
||
# Apply C++ and C linter and formatter, clang | ||
# Configurable using the .clang-format and .clang-tidy config files if present | ||
- name: clang source | ||
if: always() | ||
uses: cpp-linter/cpp-linter-action@v2 | ||
id: linter | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
jatkinson1000 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
with: | ||
style: 'file' | ||
tidy-checks: '' | ||
# Use the compile_commands.json from CMake to locate headers | ||
database: ${{ github.workspace }}/src/build | ||
# only 'update' a single comment in a pull request thread. | ||
thread-comments: ${{ github.event_name == 'pull_request' && 'update' }} | ||
- name: Fail fast?! | ||
if: steps.linter.outputs.checks-failed > 0 | ||
run: exit 1 | ||
|
||
# Apply Fortran linter, fortitude to examples | ||
- name: fortitude examples | ||
if: always() | ||
run: | | ||
cd ${{ github.workspace }} | ||
. ftorch_venv/bin/activate | ||
fortitude check examples | ||
|
||
- name: ruff | ||
if: always() | ||
run: | | ||
cd ${{ github.workspace }} | ||
. ftorch_venv/bin/activate | ||
ruff format --diff ./ | ||
ruff check --diff ./ |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -157,6 +157,7 @@ venv/ | |
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
ftorch_venv/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
|
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.