Skip to content

Commit 4d16922

Browse files
authored
Merge pull request #196 from ocefpaf/add_zizmor_checks
Add zizmor checks
2 parents fff70e9 + b115a4c commit 4d16922

File tree

10 files changed

+126
-95
lines changed

10 files changed

+126
-95
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ updates:
1212
groups:
1313
github-actions:
1414
patterns:
15-
- '*'
15+
- '*'

.github/workflows/cibuildwheel.yml

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Wheels
22

33
on:
44
pull_request:
5-
65
push:
7-
tags:
8-
- "v*"
6+
release:
7+
types:
8+
- published
99

1010
jobs:
1111
build_bdist:
@@ -28,19 +28,20 @@ jobs:
2828
arch: x86_64
2929

3030
steps:
31-
- uses: actions/checkout@v4
31+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3232
with:
3333
fetch-depth: 0
34+
persist-credentials: false
3435

3536
# For aarch64 support
3637
# https://cibuildwheel.pypa.io/en/stable/faq/#emulation
37-
- uses: docker/setup-qemu-action@v3
38+
- uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
3839
with:
3940
platforms: all
4041
if: runner.os == 'Linux' && matrix.arch == 'aarch64'
4142

4243
- name: "Building ${{ matrix.os }} (${{ matrix.arch }}) wheels"
43-
uses: pypa/[email protected]
44+
uses: pypa/cibuildwheel@5f22145df44122af0f5a201f93cf0207171beca7 # v3.0.0
4445
env:
4546
# Skips pypy and musllinux for now.
4647
CIBW_SKIP: "pp* cp36-* cp37-* cp38-* *-musllinux*"
@@ -52,19 +53,21 @@ jobs:
5253
python -c "import gsw; print(f'gsw v{gsw.__version__}')" &&
5354
python -m pytest --pyargs gsw
5455
55-
- uses: actions/upload-artifact@v4
56+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
5657
with:
5758
name: pypi-artifacts-${{ matrix.os }}-${{ matrix.arch }}
5859
path: ${{ github.workspace }}/wheelhouse/*.whl
59-
60+
permissions:
61+
actions: write
6062

6163
build_sdist:
6264
name: Build source distribution
6365
runs-on: ubuntu-22.04
6466
steps:
65-
- uses: actions/checkout@v4
67+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
6668
with:
6769
fetch-depth: 0
70+
persist-credentials: false
6871

6972
- name: Build sdist
7073
run: >
@@ -73,17 +76,19 @@ jobs:
7376
&& twine check dist/*
7477
&& check-manifest --verbose
7578
76-
- uses: actions/upload-artifact@v4
79+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
7780
with:
7881
name: pypi-artifacts
7982
path: ${{ github.workspace }}/dist/*.tar.gz
83+
permissions:
84+
actions: write
8085

8186
show-artifacts:
8287
needs: [build_bdist, build_sdist]
8388
name: "Show artifacts"
8489
runs-on: ubuntu-22.04
8590
steps:
86-
- uses: actions/download-artifact@v4
91+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
8792
with:
8893
pattern: pypi-artifacts*
8994
path: ${{ github.workspace }}/dist
@@ -92,7 +97,8 @@ jobs:
9297
- shell: bash
9398
run: |
9499
ls -l ${{ github.workspace }}/dist
95-
100+
permissions:
101+
actions: none
96102

97103
publish-artifacts-pypi:
98104
needs: [build_bdist, build_sdist]
@@ -101,14 +107,16 @@ jobs:
101107
# upload to PyPI for every tag starting with 'v'
102108
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
103109
steps:
104-
- uses: actions/download-artifact@v4
110+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
105111
with:
106112
pattern: pypi-artifacts*
107113
path: ${{ github.workspace }}/dist
108114
merge-multiple: true
109115

110-
- uses: pypa/gh-action-pypi-publish@release/v1
111-
with:
112-
user: __token__
113-
password: ${{ secrets.PYPI_PASSWORD }}
114-
print_hash: true
116+
- name: Publish package distributions to PyPI
117+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
118+
environment:
119+
name: release
120+
url: https://pypi.org/p/gsw
121+
permissions:
122+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing

.github/workflows/deploy-docs.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Build and Deploy docs
22

33
on:
44
pull_request:
5-
65
push:
7-
tags:
8-
- "v*"
6+
release:
7+
types:
8+
- published
99

1010
defaults:
1111
run:
@@ -15,10 +15,14 @@ jobs:
1515
run:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v4
18+
- name: checkout
19+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20+
with:
21+
fetch-depth: 0
22+
persist-credentials: false
1923

2024
- name: Set up Python
21-
uses: actions/setup-python@v5
25+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2226
with:
2327
python-version: "3.x"
2428

@@ -36,7 +40,9 @@ jobs:
3640
3741
- name: GitHub Pages action
3842
if: success() && github.event_name == 'release'
39-
uses: peaceiris/actions-gh-pages@v4
43+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
4044
with:
4145
github_token: ${{ secrets.GITHUB_TOKEN }}
4246
publish_dir: docs/_build/html
47+
permissions:
48+
actions: write

.github/workflows/pre-commit.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ jobs:
99
pre-commit:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v4
13-
- uses: actions/setup-python@v5
14-
- uses: pre-commit/[email protected]
12+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
13+
with:
14+
fetch-depth: 0
15+
persist-credentials: false
16+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
17+
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
18+
permissions:
19+
actions: none

.github/workflows/test_code_generation.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Test code generation
33
on:
44
pull_request:
55
push:
6-
branches: [main]
6+
branches: [ main ]
77

88
defaults:
99
run:
@@ -14,10 +14,13 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18+
with:
19+
fetch-depth: 0
20+
persist-credentials: false
1821

1922
- name: Set up Python
20-
uses: actions/setup-python@v5
23+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2124
with:
2225
python-version: "3.x"
2326

@@ -39,4 +42,6 @@ jobs:
3942
- name: Install gsw
4043
run: >
4144
python -m pip install -v -e . --no-deps --no-build-isolation --force-reinstall
42-
&& python -m pytest -s -rxs -v gsw/tests
45+
&& python -m pytest -s -rxs -v gsw/tests
46+
permissions:
47+
actions: none

.github/workflows/tests.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Tests
33
on:
44
pull_request:
55
push:
6-
branches: [main]
6+
branches: [ main ]
77

88
defaults:
99
run:
@@ -24,10 +24,13 @@ jobs:
2424
fail-fast: false
2525

2626
steps:
27-
- uses: actions/checkout@v4
27+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28+
with:
29+
fetch-depth: 0
30+
persist-credentials: false
2831

2932
- name: Set up Python
30-
uses: actions/setup-python@v5
33+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
3134
with:
3235
python-version: ${{ matrix.python-version }}
3336

@@ -40,3 +43,5 @@ jobs:
4043
- name: Tests
4144
run: |
4245
python -m pytest -s -rxs -v gsw/tests
46+
permissions:
47+
actions: none

.pre-commit-config.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
3+
rev: v5.0.0
44
hooks:
55
- id: check-ast
66
- id: debug-statements
77
- id: check-added-large-files
88

99
- repo: https://github.com/codespell-project/codespell
10-
rev: v2.2.6
10+
rev: v2.4.1
1111
hooks:
1212
- id: codespell
1313
exclude: >
@@ -20,16 +20,21 @@ repos:
2020
- --ignore-words-list=nin,preformed,wih,
2121

2222
- repo: https://github.com/tox-dev/pyproject-fmt
23-
rev: 1.8.0
23+
rev: v2.6.0
2424
hooks:
2525
- id: pyproject-fmt
2626

2727

2828
- repo: https://github.com/charliermarsh/ruff-pre-commit
29-
rev: v0.3.7
29+
rev: v0.11.13
3030
hooks:
3131
- id: ruff
3232

33+
- repo: https://github.com/woodruffw/zizmor-pre-commit
34+
rev: v1.9.0
35+
hooks:
36+
- id: zizmor
37+
3338
ci:
3439
autofix_commit_msg: |
3540
[pre-commit.ci] auto fixes from pre-commit.com hooks

gsw/tests/_WIP_test_ufuncs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ def cfcf(request):
2929

3030
def test_mechanism(cfcf):
3131
cv, cf, mfunc = cfcf
32-
print("<%s>" % mfunc.name)
32+
print(f"<{mfunc.name}>")
3333
def value_from_name(vname):
3434
b, name = vname.split('.')
3535
if b == 'cf':
3636
return cf[name]
3737
elif b == 'cv':
3838
return cv[name]
3939
else:
40-
raise ValueError("Can't find cf. or cv. in %s" % vname)
40+
raise ValueError(f"Can't find cf. or cv. in {vname}")
4141
def set_from_name(vname, value):
4242
b, name = vname.split('.')
4343
if b == 'cf':
@@ -76,10 +76,10 @@ def set_from_name(vname, value):
7676
#set_from_name(mfunc.test_varstrings[0], expected - found)
7777

7878
else:
79-
print(">>%s<<" % mfunc.testline)
79+
print(f">>{mfunc.testline}<<")
8080
print("missing mfunc.test_varstrings")
8181
mfunc.run()
82-
if hasattr(mfunc, 'exception'):
83-
print(">>>%s<<<", mfunc.exception)
82+
if hasattr(mfunc, "exception"):
83+
print(f">>>{mfunc.exception}<<<")
8484
else:
8585
assert mfunc.passed

gsw/tests/check_functions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ def run(self, locals_=None):
177177

178178
# The following is needed for melting_ice_into_seawater.
179179
if len(self.outstrings) > 1:
180-
rl_ind = '[:%d]' % len(self.outstrings)
180+
rl_ind = f"[:{len(self.outstrings)}]"
181181
else:
182-
rl_ind = ''
182+
rl_ind = ""
183183

184184
exec(self.runline + rl_ind, *evalargs)
185185
if len(self.outstrings) == 1:
@@ -327,13 +327,13 @@ def parse_check_functions(mfile):
327327
isinstance(f.exception, exc)]
328328
ex_dict[exc] = elist
329329

330-
print("\n%s tests were translated from gsw_check_functions.m" % len(checks))
331-
print("\n%s tests ran with no error and with correct output" % len(passes))
330+
print(f"\n{len(checks)} tests were translated from gsw_check_functions.m")
331+
print(f"\n{len(passes)} tests ran with no error and with correct output")
332332
if args.verbose:
333333
for f in passes:
334334
print(f.name)
335335

336-
print("\n%s tests had an output mismatch:" % len(failures))
336+
print(f"\n{len(failures)} tests had an output mismatch:")
337337
for f in failures:
338338
print(f.name)
339339
print(f.runline)
@@ -348,7 +348,7 @@ def parse_check_functions(mfile):
348348

349349
print('')
350350

351-
print("\n%s exceptions were raised as follows:" % len(run_problems))
351+
print(f"\n{len(run_problems)} exceptions were raised as follows:")
352352
for exc in etypes:
353353
print(" ", exc.__name__)
354354
strings = [" {} : {}".format(*e) for e in ex_dict[exc]]

0 commit comments

Comments
 (0)