Skip to content
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

Linting for shell and GitHub Actions #206

Merged
merged 10 commits into from
Dec 18, 2024
2 changes: 2 additions & 0 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout code
with:
persist-credentials: false
uses: actions/checkout@v4

- name: Install Python
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/fypp_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-python@v4
with:
python-version: "3.11"
Expand Down
26 changes: 24 additions & 2 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ on:
# Triggers the workflow on pushes to open pull requests with code changes
pull_request:
paths:
- '.github/workflows/static_analysis.yml'
- '.github/workflows/*.yml'
- '**.c'
- '**.cpp'
- '**.fypp'
- '**.f90'
- '**.F90'
- '**.pf'
- '**.py'
- '**.sh'
- '**CMakeLists.txt'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -35,6 +37,8 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout code
with:
persist-credentials: false
uses: actions/checkout@v4

- name: Install Python
Expand Down Expand Up @@ -63,13 +67,31 @@ jobs:
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${BUILD_DIR} -DCMAKE_Fortran_FLAGS="-std=f2008" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

# Apply CMake linter, cmake-lint
- name: cmake
- name: cmake-lint
if: always()
run: |
cd ${{ github.workspace }}
. ftorch_venv/bin/activate
cmake-lint $(find . -name CMakeLists.txt)

# Apply Shell linter, shellcheck
- name: shellcheck
if: always()
run: |
cd ${{ github.workspace }}
sudo apt install shellcheck
for FILE in $(find . -name "*.sh"); do
shellcheck ${FILE}
done

# Apply GitHub Actions linter, zizmor
- name: zizmor
if: always()
run: |
cd ${{ github.workspace }}
. ftorch_venv/bin/activate
zizmor .github/workflows/*.yml

# Apply Fortran linter, fortitude
# Configurable using the fortitude.toml file if present
- name: fortitude source
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test_suite_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout code
with:
persist-credentials: false
uses: actions/checkout@v4

- name: Install Python
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/test_suite_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ on:
pull_request:
paths:
- '.github/workflows/test_suite_windows.yml'
- '**.bat'
- '**.c'
- '**.cpp'
- '**.fypp'
- '**.f90'
- '**.F90'
- '**.pf'
- '**.py'
- '**.sh'
- '**CMakeLists.txt'
- '**requirements.txt'
- '**data/*'
Expand Down Expand Up @@ -53,6 +53,8 @@ jobs:

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout code
with:
persist-credentials: false
uses: actions/checkout@v4

- name: Install Python
Expand All @@ -69,11 +71,13 @@ jobs:
shell: cmd
run: |
cd src
rem find torch location
for /f "tokens=2*" %%i in ('pip show torch ^| findstr /R "^Location"') do set torch_path=%%i
cmake ^
-Bbuild ^
-G "NMake Makefiles" ^
-DCMAKE_Fortran_FLAGS="/fpscomp:logicals" ^
-DCMAKE_PREFIX_PATH="C:\hostedtoolcache\windows\Python\3.12.7\x64\Lib\site-packages" ^
-DCMAKE_PREFIX_PATH=%torch_path% ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_Fortran_COMPILER=ifx ^
-DCMAKE_C_COMPILER=icx ^
Expand All @@ -85,7 +89,7 @@ jobs:
- name: Integration tests
shell: cmd
run: |
set PATH=C:\hostedtoolcache\windows\Python\3.12.7\x64\Lib\site-packages;%PATH%
for /f "tokens=2*" %%i in ('pip show torch ^| findstr /R "^Location"') do set torch_path=%%i
set PATH=C:\Program Files (x86)\FTorch\bin;%PATH%
set PATH=C:\hostedtoolcache\windows\Python\3.12.7\x64\Lib\site-packages\torch\lib;%PATH%
set PATH=%torch_path%\torch\lib;%PATH%
run_integration_tests.bat
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ fortitude-lint==0.6.0
clang-format==19.1.3
clang-tidy==19.1.0
cmakelang
zizmor
7 changes: 3 additions & 4 deletions run_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@

set -eu

CTEST_ARGS=$@
EXAMPLES="1_SimpleNet 2_ResNet18 4_MultiIO 6_Autograd"
BUILD_DIR=src/build

for EXAMPLE in ${EXAMPLES}; do
pip -q install -r examples/${EXAMPLE}/requirements.txt
cd ${BUILD_DIR}/test/examples/${EXAMPLE}
ctest ${CTEST_ARGS}
pip -q install -r examples/"${EXAMPLE}"/requirements.txt
cd "${BUILD_DIR}"/test/examples/"${EXAMPLE}"
ctest "$@"
cd -
done
Loading