Skip to content

Commit c52e36d

Browse files
committed
add additional pre-commit hooks
1 parent 84d39d2 commit c52e36d

File tree

4 files changed

+78
-60
lines changed

4 files changed

+78
-60
lines changed

.github/workflows/build-with-clang.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
16-
numpy_version: ["numpy'>=2'"]
16+
numpy_version: ["numpy>=2"]
1717
env:
1818
ONEAPI_ROOT: /opt/intel/oneapi
1919

@@ -55,22 +55,22 @@ jobs:
5555
- name: Install mkl_random dependencies
5656
run: |
5757
pip install cython setuptools">=77"
58-
pip install ${{ matrix.numpy_version }}
58+
pip install "${{ matrix.numpy_version }}"
5959
6060
- name: List oneAPI folder content
61-
run: ls ${{ env.ONEAPI_ROOT }}/compiler
61+
run: ls "${{ env.ONEAPI_ROOT }}/compiler"
6262

6363
- name: Build mkl_random
6464
run: |
65-
source ${{ env.ONEAPI_ROOT }}/setvars.sh
66-
echo $CMPLR_ROOT
67-
export CC=$CMPLR_ROOT/bin/icx
68-
export CXX=$CMPLR_ROOT/bin/icpx
65+
source "${{ env.ONEAPI_ROOT }}/setvars.sh"
66+
echo "$CMPLR_ROOT"
67+
export CC="$CMPLR_ROOT/bin/icx"
68+
export CXX="$CMPLR_ROOT/bin/icpx"
6969
export CFLAGS="${CFLAGS} -fno-fast-math -O2"
7070
pip install -e . --no-build-isolation --no-deps --verbose
7171
7272
- name: Run mkl_random tests
7373
run: |
74-
source ${{ env.ONEAPI_ROOT }}/setvars.sh
74+
source "${{ env.ONEAPI_ROOT }}/setvars.sh"
7575
pip install pytest
7676
pytest -s -v --pyargs mkl_random

.github/workflows/conda-package-cf.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,21 @@ jobs:
5353
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
5454
5555
- name: Add conda to system path
56-
run: echo $CONDA/bin >> $GITHUB_PATH
56+
run: echo "$CONDA/bin" >> "$GITHUB_PATH"
5757

5858
- name: Install conda-build
5959
run: conda install conda-build
6060

6161
- name: Build conda package
6262
run: |
63-
CHANNELS="-c conda-forge --override-channels"
64-
VERSIONS="--python ${{ matrix.python }} --numpy ${{ matrix.numpy }}"
65-
TEST="--no-test"
63+
CHANNELS=(-c conda-forge --override-channels)
64+
VERSIONS=(--python "${{ matrix.python }}" --numpy "${{ matrix.numpy }}")
65+
TEST=(--no-test)
6666
6767
conda build \
68-
$TEST \
69-
$VERSIONS \
70-
$CHANNELS \
68+
"${TEST[@]}" \
69+
"${VERSIONS[@]}" \
70+
"${CHANNELS[@]}" \
7171
conda-recipe-cf
7272
7373
- name: Upload artifact
@@ -162,27 +162,27 @@ jobs:
162162
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
163163

164164
- name: Add conda to system path
165-
run: echo $CONDA/bin >> $GITHUB_PATH
165+
run: echo "$CONDA/bin" >> "$GITHUB_PATH"
166166

167167
- name: Install conda-build
168168
run: conda install conda-build
169169

170170
- name: Create conda channel
171171
run: |
172-
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
173-
conda index $GITHUB_WORKSPACE/channel || exit 1
174-
mv ${PACKAGE_NAME}-*.conda $GITHUB_WORKSPACE/channel/linux-64 || exit 1
175-
conda index $GITHUB_WORKSPACE/channel || exit 1
172+
mkdir -p "$GITHUB_WORKSPACE/channel/linux-64"
173+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
174+
mv "${PACKAGE_NAME}"-*.conda "$GITHUB_WORKSPACE/channel/linux-64" || exit 1
175+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
176176
# Test channel
177-
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels --info --json > $GITHUB_WORKSPACE/ver.json
177+
conda search "$PACKAGE_NAME" -c "$GITHUB_WORKSPACE/channel" --override-channels --info --json > "$GITHUB_WORKSPACE/ver.json"
178178
cat ver.json
179179
180180
- name: Collect dependencies
181181
run: |
182-
. $CONDA/etc/profile.d/conda.sh
183-
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
184-
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
185-
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS --only-deps --dry-run > lockfile
182+
. "$CONDA/etc/profile.d/conda.sh"
183+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
184+
export PACKAGE_VERSION
185+
conda create -n "${{ env.TEST_ENV_NAME }}" "${PACKAGE_NAME}=${PACKAGE_VERSION}" "python=${{ matrix.python }}" "numpy=${{ matrix.numpy }}" -c "$GITHUB_WORKSPACE/channel" -c conda-forge --override-channels --only-deps --dry-run > lockfile
186186
cat lockfile
187187
188188
- name: Set pkgs_dirs
@@ -203,17 +203,17 @@ jobs:
203203
204204
- name: Install mkl_random
205205
run: |
206-
. $CONDA/etc/profile.d/conda.sh
207-
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
208-
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
209-
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} pytest python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS
206+
. "$CONDA/etc/profile.d/conda.sh"
207+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
208+
export PACKAGE_VERSION
209+
conda create -n "${{ env.TEST_ENV_NAME }}" "${PACKAGE_NAME}=${PACKAGE_VERSION}" pytest "python=${{ matrix.python }}" "numpy=${{ matrix.numpy }}" -c "$GITHUB_WORKSPACE/channel" -c conda-forge --override-channels
210210
# Test installed packages
211211
conda list
212212
213213
- name: Run tests
214214
run: |
215-
. $CONDA/etc/profile.d/conda.sh
216-
conda activate ${{ env.TEST_ENV_NAME }}
215+
. "$CONDA/etc/profile.d/conda.sh"
216+
conda activate "${{ env.TEST_ENV_NAME }}"
217217
pytest -vv --pyargs ${{ env.MODULE_NAME }}
218218
219219
test_windows:

.github/workflows/conda-package.yml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,26 @@ jobs:
4949
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
5050
5151
- name: Add conda to system path
52-
run: echo $CONDA/bin >> $GITHUB_PATH
52+
run: echo "$CONDA/bin" >> "$GITHUB_PATH"
5353

5454
- name: Install conda-build
5555
run: conda install conda-build
5656

5757
- name: Store conda paths as envs
5858
shell: bash -el {0}
5959
run: |
60-
echo "CONDA_BLD=/usr/share/miniconda/conda-bld/linux-64/" >> $GITHUB_ENV
60+
echo "CONDA_BLD=/usr/share/miniconda/conda-bld/linux-64/" >> "$GITHUB_ENV"
6161
6262
- name: Build conda package
6363
run: |
64-
CHANNELS="-c https://software.repos.intel.com/python/conda -c conda-forge --override-channels"
65-
VERSIONS="--python ${{ matrix.python }}"
66-
TEST="--no-test"
64+
CHANNELS=(-c https://software.repos.intel.com/python/conda -c conda-forge --override-channels)
65+
VERSIONS=(--python "${{ matrix.python }}")
66+
TEST=(--no-test)
6767
6868
conda build \
69-
$TEST \
70-
$VERSIONS \
71-
$CHANNELS \
69+
"${TEST[@]}" \
70+
"${VERSIONS[@]}" \
71+
"${CHANNELS[@]}" \
7272
conda-recipe
7373
7474
- name: Upload artifact
@@ -120,10 +120,10 @@ jobs:
120120
- name: Store conda paths as envs
121121
shell: bash -el {0}
122122
run: |
123-
echo "CONDA_BLD=$CONDA_PREFIX\\conda-bld\\win-64\\" >> $GITHUB_ENV
123+
echo "CONDA_BLD=${CONDA_PREFIX}\\conda-bld\\win-64\\" >> "$GITHUB_ENV"
124124
125125
- name: Build conda package
126-
run: conda build --no-test --python ${{ matrix.python }} -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels conda-recipe
126+
run: conda build --no-test --python "${{ matrix.python }}" -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels conda-recipe
127127

128128
- name: Upload artifact
129129
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
@@ -160,27 +160,27 @@ jobs:
160160
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
161161

162162
- name: Add conda to system path
163-
run: echo $CONDA/bin >> $GITHUB_PATH
163+
run: echo "$CONDA/bin" >> "$GITHUB_PATH"
164164

165165
- name: Install conda-build
166166
run: conda install conda-build
167167

168168
- name: Create conda channel
169169
run: |
170-
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
171-
conda index $GITHUB_WORKSPACE/channel || exit 1
172-
mv ${PACKAGE_NAME}-*.conda $GITHUB_WORKSPACE/channel/linux-64 || exit 1
173-
conda index $GITHUB_WORKSPACE/channel || exit 1
170+
mkdir -p "$GITHUB_WORKSPACE/channel/linux-64"
171+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
172+
mv "${PACKAGE_NAME}"-*.conda "$GITHUB_WORKSPACE/channel/linux-64" || exit 1
173+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
174174
# Test channel
175-
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels --info --json > $GITHUB_WORKSPACE/ver.json
175+
conda search "$PACKAGE_NAME" -c "$GITHUB_WORKSPACE/channel" --override-channels --info --json > "$GITHUB_WORKSPACE/ver.json"
176176
cat ver.json
177177
178178
- name: Collect dependencies
179179
run: |
180-
. $CONDA/etc/profile.d/conda.sh
181-
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
182-
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
183-
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS --only-deps --dry-run > lockfile
180+
. "$CONDA/etc/profile.d/conda.sh"
181+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
182+
export PACKAGE_VERSION
183+
conda create -n "${{ env.TEST_ENV_NAME }}" "${PACKAGE_NAME}=${PACKAGE_VERSION}" "python=${{ matrix.python }}" "numpy=${{ matrix.numpy }}" -c "$GITHUB_WORKSPACE/channel" -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels --only-deps --dry-run > lockfile
184184
cat lockfile
185185
186186
- name: Set pkgs_dirs
@@ -201,19 +201,19 @@ jobs:
201201
202202
- name: Install mkl_random
203203
run: |
204-
. $CONDA/etc/profile.d/conda.sh
205-
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
206-
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
207-
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} pytest python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS
208-
conda activate ${{ env.TEST_ENV_NAME }}
204+
. "$CONDA/etc/profile.d/conda.sh"
205+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
206+
export PACKAGE_VERSION
207+
conda create -n "${{ env.TEST_ENV_NAME }}" "${PACKAGE_NAME}=${PACKAGE_VERSION}" pytest "python=${{ matrix.python }}" "numpy=${{ matrix.numpy }}" -c "$GITHUB_WORKSPACE/channel" -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels
208+
conda activate "${{ env.TEST_ENV_NAME }}"
209209
210210
# Test installed packages
211211
conda list
212212
213213
- name: Run tests
214214
run: |
215-
. $CONDA/etc/profile.d/conda.sh
216-
conda activate ${{ env.TEST_ENV_NAME }}
215+
. "$CONDA/etc/profile.d/conda.sh"
216+
conda activate "${{ env.TEST_ENV_NAME }}"
217217
pytest -vv --pyargs ${{ env.MODULE_NAME }}
218218
219219
test_windows:
@@ -259,7 +259,7 @@ jobs:
259259
run: |
260260
mkdir ${{ env.GITHUB_WORKSPACE }}\channel\win-64
261261
move ${{ env.PACKAGE_NAME }}-*.conda ${{ env.GITHUB_WORKSPACE }}\channel\win-64
262-
python -m conda_index ${{ env.GITHUB_WORKSPACE }}/channel
262+
python -m conda_index "${{ env.GITHUB_WORKSPACE }}/channel"
263263
264264
# Test channel
265265
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.GITHUB_WORKSPACE }}/channel --override-channels --info --json > ${{ env.GITHUB_WORKSPACE }}\ver.json
@@ -309,5 +309,5 @@ jobs:
309309
310310
- name: Run tests
311311
run: |
312-
conda activate -n ${{ env.TEST_ENV_NAME }}
312+
conda activate -n "${{ env.TEST_ENV_NAME }}"
313313
pytest -v --pyargs ${{ env.MODULE_NAME }}

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
33
rev: v6.0.0
44
hooks:
5+
# Git
6+
- id: check-added-large-files
7+
- id: no-commit-to-branch
8+
name: "ensure no direct commit to master/maintenance branches"
9+
args: [--branch, "master", --pattern, "maintenance/.*"]
10+
- id: check-case-conflict
11+
- id: check-illegal-windows-names
512
- id: check-ast
613
- id: check-builtin-literals
714
- id: check-case-conflict
@@ -101,3 +108,14 @@ repos:
101108
rev: 3.0.0
102109
hooks:
103110
- id: shellcheck
111+
112+
- repo: https://github.com/gitleaks/gitleaks
113+
rev: v8.30.0
114+
hooks:
115+
- id: gitleaks
116+
117+
- repo: https://github.com/rhysd/actionlint
118+
rev: v1.7.11
119+
hooks:
120+
- id: actionlint
121+
args: ["-ignore", "SC2317"]

0 commit comments

Comments
 (0)