Skip to content

Commit ca14da6

Browse files
committed
add additional pre-commit hooks
1 parent 47953a2 commit ca14da6

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"]
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
@@ -49,19 +49,19 @@ 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
- name: Install conda-build
5454
run: conda install conda-build
5555
- name: Build conda package
5656
run: |
57-
CHANNELS="-c conda-forge --override-channels"
58-
VERSIONS="--python ${{ matrix.python }} --numpy ${{ matrix.numpy }}"
59-
TEST="--no-test"
57+
CHANNELS=(-c conda-forge --override-channels)
58+
VERSIONS=(--python "${{ matrix.python }}" --numpy "${{ matrix.numpy }}")
59+
TEST=(--no-test)
6060
6161
conda build \
62-
$TEST \
63-
$VERSIONS \
64-
$CHANNELS \
62+
"${TEST[@]}" \
63+
"${VERSIONS[@]}" \
64+
"${CHANNELS[@]}" \
6565
conda-recipe-cf
6666
- name: Upload artifact
6767
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
@@ -144,24 +144,24 @@ jobs:
144144
with:
145145
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
146146
- name: Add conda to system path
147-
run: echo $CONDA/bin >> $GITHUB_PATH
147+
run: echo "$CONDA/bin" >> "$GITHUB_PATH"
148148
- name: Install conda-build
149149
run: conda install conda-build
150150
- name: Create conda channel
151151
run: |
152-
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
153-
conda index $GITHUB_WORKSPACE/channel || exit 1
154-
mv ${PACKAGE_NAME}-*.conda $GITHUB_WORKSPACE/channel/linux-64 || exit 1
155-
conda index $GITHUB_WORKSPACE/channel || exit 1
152+
mkdir -p "$GITHUB_WORKSPACE/channel/linux-64"
153+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
154+
mv "${PACKAGE_NAME}"-*.conda "$GITHUB_WORKSPACE/channel/linux-64" || exit 1
155+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
156156
# Test channel
157-
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels --info --json > $GITHUB_WORKSPACE/ver.json
157+
conda search "$PACKAGE_NAME" -c "$GITHUB_WORKSPACE/channel" --override-channels --info --json > "$GITHUB_WORKSPACE/ver.json"
158158
cat ver.json
159159
- name: Collect dependencies
160160
run: |
161-
. $CONDA/etc/profile.d/conda.sh
162-
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
163-
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
164-
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS --only-deps --dry-run > lockfile
161+
. "$CONDA/etc/profile.d/conda.sh"
162+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
163+
export PACKAGE_VERSION
164+
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
165165
cat lockfile
166166
- name: Set pkgs_dirs
167167
run: |
@@ -180,16 +180,16 @@ jobs:
180180
181181
- name: Install mkl_random
182182
run: |
183-
. $CONDA/etc/profile.d/conda.sh
184-
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
185-
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
186-
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} pytest python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS
183+
. "$CONDA/etc/profile.d/conda.sh"
184+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
185+
export PACKAGE_VERSION
186+
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
187187
# Test installed packages
188188
conda list
189189
- name: Run tests
190190
run: |
191-
. $CONDA/etc/profile.d/conda.sh
192-
conda activate ${{ env.TEST_ENV_NAME }}
191+
. "$CONDA/etc/profile.d/conda.sh"
192+
conda activate "${{ env.TEST_ENV_NAME }}"
193193
pytest -vv --pyargs ${{ env.MODULE_NAME }}
194194
195195
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@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
@@ -158,27 +158,27 @@ jobs:
158158
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
159159

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

163163
- name: Install conda-build
164164
run: conda install conda-build
165165

166166
- name: Create conda channel
167167
run: |
168-
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
169-
conda index $GITHUB_WORKSPACE/channel || exit 1
170-
mv ${PACKAGE_NAME}-*.conda $GITHUB_WORKSPACE/channel/linux-64 || exit 1
171-
conda index $GITHUB_WORKSPACE/channel || exit 1
168+
mkdir -p "$GITHUB_WORKSPACE/channel/linux-64"
169+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
170+
mv "${PACKAGE_NAME}"-*.conda "$GITHUB_WORKSPACE/channel/linux-64" || exit 1
171+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
172172
# Test channel
173-
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels --info --json > $GITHUB_WORKSPACE/ver.json
173+
conda search "$PACKAGE_NAME" -c "$GITHUB_WORKSPACE/channel" --override-channels --info --json > "$GITHUB_WORKSPACE/ver.json"
174174
cat ver.json
175175
176176
- name: Collect dependencies
177177
run: |
178-
. $CONDA/etc/profile.d/conda.sh
179-
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
180-
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
181-
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS --only-deps --dry-run > lockfile
178+
. "$CONDA/etc/profile.d/conda.sh"
179+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
180+
export PACKAGE_VERSION
181+
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
182182
cat lockfile
183183
184184
- name: Set pkgs_dirs
@@ -199,19 +199,19 @@ jobs:
199199
200200
- name: Install mkl_random
201201
run: |
202-
. $CONDA/etc/profile.d/conda.sh
203-
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
204-
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
205-
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} pytest python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS
206-
conda activate ${{ env.TEST_ENV_NAME }}
202+
. "$CONDA/etc/profile.d/conda.sh"
203+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
204+
export PACKAGE_VERSION
205+
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
206+
conda activate "${{ env.TEST_ENV_NAME }}"
207207
208208
# Test installed packages
209209
conda list
210210
211211
- name: Run tests
212212
run: |
213-
. $CONDA/etc/profile.d/conda.sh
214-
conda activate ${{ env.TEST_ENV_NAME }}
213+
. "$CONDA/etc/profile.d/conda.sh"
214+
conda activate "${{ env.TEST_ENV_NAME }}"
215215
pytest -vv --pyargs ${{ env.MODULE_NAME }}
216216
217217
test_windows:
@@ -255,7 +255,7 @@ jobs:
255255
run: |
256256
mkdir ${{ env.GITHUB_WORKSPACE }}\channel\win-64
257257
move ${{ env.PACKAGE_NAME }}-*.conda ${{ env.GITHUB_WORKSPACE }}\channel\win-64
258-
python -m conda_index ${{ env.GITHUB_WORKSPACE }}/channel
258+
python -m conda_index "${{ env.GITHUB_WORKSPACE }}/channel"
259259
260260
# Test channel
261261
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.GITHUB_WORKSPACE }}/channel --override-channels --info --json > ${{ env.GITHUB_WORKSPACE }}\ver.json
@@ -305,5 +305,5 @@ jobs:
305305
306306
- name: Run tests
307307
run: |
308-
conda activate -n ${{ env.TEST_ENV_NAME }}
308+
conda activate -n "${{ env.TEST_ENV_NAME }}"
309309
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)