Skip to content

Commit 5d70861

Browse files
authored
Add pre-commit config (#49)
1 parent 0821668 commit 5d70861

26 files changed

+2189
-2630
lines changed

.github/workflows/test.yml

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ env:
2626
ninja
2727
cmake
2828
gcovr
29+
2930
jobs:
3031
gcc-build:
31-
runs-on: ${{ matrix.os }}
3232
strategy:
3333
fail-fast: false
3434
matrix:
@@ -43,6 +43,11 @@ jobs:
4343
sanitizer: none
4444
buildtype: release
4545

46+
runs-on: ${{ matrix.os }}
47+
48+
permissions:
49+
contents: read
50+
4651
env:
4752
FC: gfortran
4853
CC: gcc
@@ -52,7 +57,9 @@ jobs:
5257

5358
steps:
5459
- name: Checkout code
55-
uses: actions/checkout@v3
60+
uses: actions/checkout@v4
61+
with:
62+
persist-credentials: false
5663

5764
- name: Set up Python ${{ matrix.python-version }}
5865
uses: actions/setup-python@v4
@@ -62,23 +69,29 @@ jobs:
6269
- name: Install GCC ${{ matrix.GCC_V }} (OSX)
6370
if: contains(matrix.os, 'macos')
6471
run: |
65-
ln -s /usr/local/bin/gfortran-${{ env.GCC_V }} /usr/local/bin/gfortran
66-
ln -s /usr/local/bin/gcc-${{ env.GCC_V }} /usr/local/bin/gcc
67-
ln -s /usr/local/bin/g++-${{ env.GCC_V }} /usr/local/bin/g++
72+
ln -s /usr/local/bin/gfortran-${GCC_V} /usr/local/bin/gfortran
73+
ln -s /usr/local/bin/gcc-${GCC_V} /usr/local/bin/gcc
74+
ln -s /usr/local/bin/g++-${GCC_V} /usr/local/bin/g++
75+
env:
76+
GCC_V: ${{ env.GCC_V }}
6877

6978
- name: Install GCC (Linux)
7079
run: |
7180
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
7281
sudo apt-get update
73-
sudo apt-get install gcc-${{ env.GCC_V }} g++-${{ env.GCC_V }} gfortran-${{ env.GCC_V }}
82+
sudo apt-get install gcc-${GCC_V} g++-${GCC_V} gfortran-${GCC_V}
83+
env:
84+
GCC_V: ${{ env.GCC_V }}
7485

7586
- name: Set GCC Version (Linux)
7687
if: contains(matrix.os, 'ubuntu')
7788
run: >-
7889
sudo update-alternatives
79-
--install /usr/bin/gcc gcc /usr/bin/gcc-${{ env.GCC_V }} 100
80-
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ env.GCC_V }}
81-
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{ env.GCC_V }}
90+
--install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100
91+
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V}
92+
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V}
93+
env:
94+
GCC_V: ${{ env.GCC_V }}
8295

8396
- name: Install CBLAS and LAPACKE
8497
if: contains(matrix.os, 'ubuntu')
@@ -95,7 +108,7 @@ jobs:
95108
--libdir=lib
96109
--warnlevel=0
97110
-Dsanitizer=${{ matrix.sanitizer }}
98-
-Db_coverage=${{ env.COVERAGE }}
111+
-Db_coverage=${COVERAGE}
99112
env:
100113
COVERAGE: ${{ contains(matrix.os, 'ubuntu') && 'true' || 'false' }}
101114

@@ -107,7 +120,7 @@ jobs:
107120
meson test -C ${{ env.M_BUILD_DIR }} --print-errorlogs --no-rebuild --num-processes 2 -t 2
108121
109122
- name: Create coverage report
110-
if: matrix.os == 'ubuntu-latest' && matrix.GCC_V == '11'
123+
if: matrix.os == 'ubuntu-latest' && matrix.GCC_V == '12'
111124
run: |
112125
ninja -C ${{ env.M_BUILD_DIR }} coverage
113126
@@ -117,7 +130,8 @@ jobs:
117130
echo "DFTD4_PREFIX=$PWD/_dist" >> $GITHUB_ENV
118131
119132
- name: Upload coverage to Codecov
120-
uses: codecov/codecov-action@v3
121-
if: matrix.os == 'ubuntu-latest' && matrix.GCC_V == '11'
133+
uses: codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e # 5.1.1
134+
if: matrix.os == 'ubuntu-latest' && matrix.GCC_V == '12'
122135
with:
123136
files: ./coverage.xml # optional
137+
verbose: true # optional (default = false)

.pre-commit-config.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-shebang-scripts-are-executable
8+
- id: check-toml
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
args: ["--maxkb=20000"]
12+
13+
- repo: https://github.com/pre-commit/mirrors-clang-format
14+
rev: v21.1.7
15+
hooks:
16+
- id: clang-format
17+
types_or: [c++, c, cuda]
18+
19+
- repo: https://github.com/woodruffw/zizmor-pre-commit
20+
rev: v1.18.0
21+
hooks:
22+
- id: zizmor

app/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void help() {
9696
9797
<file> is a valid xmol file (coordinates in Ångström).
9898
(Turbomole coordinate file (coordinates in Bohr) not yet supported!)
99-
99+
100100
101101
Options:
102102
@@ -146,7 +146,8 @@ int main(int argc, char **argv) {
146146
} else if (args.getflag("-f")) {
147147
func = args.getopt("-f");
148148
} else {
149-
printf("WARNING: No functional given (via '--func'). Defaulting to PBE.\n\n"
149+
printf(
150+
"WARNING: No functional given (via '--func'). Defaulting to PBE.\n\n"
150151
);
151152
func = "pbe";
152153
}

include/dftd_cblas.h

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
/*
22
* This file contains code adapted from the ORCA quantum chemistry program.
3-
* ORCA is developed by the group of Prof. Frank Neese at the Max-Planck-Institut für Kohlenforschung,
4-
* Mülheim an der Ruhr and FAccTs GmbH. ORCA is licensed by the Max-Planck-Institut für Kohlenforschung and FAccTs GmbH.
3+
* ORCA is developed by the group of Prof. Frank Neese at the
4+
* Max-Planck-Institut für Kohlenforschung, Mülheim an der Ruhr and FAccTs GmbH.
5+
* ORCA is licensed by the Max-Planck-Institut für Kohlenforschung and FAccTs
6+
* GmbH.
57
*
6-
* The inclusion of ORCA code in this file has been done with the explicit permission
7-
* of the ORCA developers.
8+
* The inclusion of ORCA code in this file has been done with the explicit
9+
* permission of the ORCA developers.
810
*
9-
* For reuse or licensing of this code, please contact the ORCA team at the Max-Planck-Institut
10-
* für Kohlenforschung (https://orcaforum.kofo.mpg.de/) or FAccTs GmbH (https://www.faccts.de/).
11+
* For reuse or licensing of this code, please contact the ORCA team at the
12+
* Max-Planck-Institut für Kohlenforschung (https://orcaforum.kofo.mpg.de/) or
13+
* FAccTs GmbH (https://www.faccts.de/).
1114
*/
1215
#pragma once
1316

@@ -35,8 +38,8 @@ inline int BLAS_Add_Mat_x_Vec(
3538
bool Transpose,
3639
double alpha
3740
) {
38-
if (Transpose) {
39-
if (A.cols == C.N && A.rows == V.N) {
41+
if (Transpose) {
42+
if (A.cols == C.N && A.rows == V.N) {
4043
cblas_dgemv(
4144
CblasRowMajor,
4245
CblasTrans,
@@ -54,7 +57,7 @@ inline int BLAS_Add_Mat_x_Vec(
5457
return EXIT_SUCCESS;
5558
};
5659
} else {
57-
if (A.rows == C.N && A.cols == V.N) {
60+
if (A.rows == C.N && A.cols == V.N) {
5861
cblas_dgemv(
5962
CblasRowMajor,
6063
CblasNoTrans,
@@ -98,7 +101,7 @@ inline int BLAS_Add_Mat_x_Mat(
98101
// check for size 0 matrices
99102
if (A.cols == 0 || A.rows == 0 || B.cols == 0 || B.rows == 0 || C.cols == 0 ||
100103
C.rows == 0) {
101-
exit(EXIT_FAILURE);
104+
exit(EXIT_FAILURE);
102105
};
103106

104107
// check for transpositions
@@ -221,9 +224,9 @@ inline int BLAS_InvertMatrix(TMatrix<double> &a) {
221224
(lapack_int)a.cols,
222225
ipiv
223226
);
224-
if (info != 0) {
227+
if (info != 0) {
225228
delete[] ipiv;
226-
return EXIT_FAILURE;
229+
return EXIT_FAILURE;
227230
}
228231

229232
// Inverse of an LU-factored general matrix
@@ -240,19 +243,19 @@ inline int BLAS_InvertMatrix(TMatrix<double> &a) {
240243
/**
241244
* @brief Solve a symmetric linear system A * X = B for X.
242245
*
243-
* This routine factorizes a symmetric matrix A using Bunch-Kaufman factorization
244-
* and solves for the right-hand side vector B. The matrix A is overwritten
245-
* by its factorization. The solution overwrites B.
246+
* This routine factorizes a symmetric matrix A using Bunch-Kaufman
247+
* factorization and solves for the right-hand side vector B. The matrix A is
248+
* overwritten by its factorization. The solution overwrites B.
246249
*
247250
* @param A Symmetric matrix of size (m x m). Overwritten by the factorization.
248251
* @param B Right-hand side vector of size m. Overwritten by the solution.
249252
* @return int Returns EXIT_SUCCESS (0) on success, EXIT_FAILURE (1) on error.
250253
*/
251254
inline int BLAS_SolveSymmetric(
252-
TMatrix<double> &A, // symmetric matrix
253-
TVector<double> &B // RHS vector (becomes solution)
255+
TMatrix<double> &A, // symmetric matrix
256+
TVector<double> &B // RHS vector (becomes solution)
254257
) {
255-
const lapack_int m = A.rows;
258+
const lapack_int m = A.rows;
256259
const lapack_int nrhs = 1;
257260

258261
if (A.cols != m || B.N != m) {
@@ -272,7 +275,8 @@ inline int BLAS_SolveSymmetric(
272275
}
273276

274277
// Solve for all RHS columns
275-
info = LAPACKE_dsytrs(LAPACK_ROW_MAJOR, 'L', m, nrhs, A.p, m, ipiv, B.p, nrhs);
278+
info =
279+
LAPACKE_dsytrs(LAPACK_ROW_MAJOR, 'L', m, nrhs, A.p, m, ipiv, B.p, nrhs);
276280
delete[] ipiv;
277281

278282
if (info != 0) {

0 commit comments

Comments
 (0)