|
| 1 | +# workflow to run static-analysis and linting checks on C/C++ files |
| 2 | + |
| 3 | +name: ClangLint |
| 4 | + |
| 5 | +# Controls when the workflow will run |
| 6 | +on: |
| 7 | + # Triggers the workflow on pushes to the "main" branch and any pull request events |
| 8 | + push: |
| 9 | + branches: [ "main"] |
| 10 | + pull_request: |
| 11 | + |
| 12 | + # Allows you to run this workflow manually from the Actions tab |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +# Workflow run - one or more jobs that can run sequentially or in parallel |
| 16 | +jobs: |
| 17 | + # This workflow contains a single job called "test-suite" |
| 18 | + C-Cpp-lint: |
| 19 | + # The type of runner that the job will run on |
| 20 | + runs-on: ubuntu-latest |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + |
| 24 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Install Python |
| 29 | + uses: actions/setup-python@v5 |
| 30 | + with: |
| 31 | + python-version: '3.x' |
| 32 | + |
| 33 | + - name: Install Dependencies |
| 34 | + run: | |
| 35 | + python -m pip install --upgrade pip |
| 36 | + python -m venv ftorch |
| 37 | + . ftorch/bin/activate |
| 38 | + pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu |
| 39 | + pip install fortitude-lint |
| 40 | +
|
| 41 | + - name: FTorch CMake |
| 42 | + run: | |
| 43 | + . ftorch/bin/activate |
| 44 | + export FT_DIR=$(pwd) |
| 45 | + VN=$(python -c "import sys; print('.'.join(sys.version.split('.')[:2]))") |
| 46 | + export Torch_DIR=${VIRTUAL_ENV}/lib/python${VN}/site-packages |
| 47 | + export BUILD_DIR=$(pwd)/src/build |
| 48 | + mkdir ${BUILD_DIR} |
| 49 | + cd ${BUILD_DIR} |
| 50 | + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${BUILD_DIR} -DCMAKE_Fortran_FLAGS="-std=f2008" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON |
| 51 | + ls ${BUILD_DIR} |
| 52 | + less ${BUILD_DIR}/compile_commands.json |
| 53 | +
|
| 54 | + - uses: cpp-linter/cpp-linter-action@v2 |
| 55 | + id: linter |
| 56 | + env: |
| 57 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + with: |
| 59 | + style: 'file' # Use .clang-format config file |
| 60 | + tidy-checks: '' # Use .clang-tidy config file |
| 61 | + database: ${BUILD_DIR} # Use the compile_commands.json from CMake to locate headers |
| 62 | + # only 'update' a single comment in a pull request thread. |
| 63 | + thread-comments: ${{ github.event_name == 'pull_request' && 'update' }} |
| 64 | + |
| 65 | + - name: Fail fast?! |
| 66 | + if: steps.linter.outputs.checks-failed > 0 |
| 67 | + run: exit 1 |
0 commit comments