Skip to content

Commit 366cdcc

Browse files
authored
action linting (#59)
* add hooks specifically for actions * fix the easier suggestions for the python ci * figure out if setting it again is overkill * select the stable toolchain * print on all platforms * avoid setting env variables from the template * use powershell syntax for windows * set shell to bash for windows (no login shell) * print the command rather than executing it * avoid executing `pkg-config` ourselves * temporarily disable the cache * enable the cache again * use `repository_owner` to detect forks * follow zizmor recommendations for the rust ci * missing space * try using the standard bash shell * add back the arg * enable the pkg-config test again * print the github env * smaller execution footprint while testing * work around a weird windows bash * try using `export` * quotes and debug printing * skip other ci * remove extra shells * typo * the runner os * disable the rust setup [skip-rtd] * see if the python ci works * ignore the python-ci template injections (low-risk, these are not controlled by someone else) * ignore the rust-ci template injections * switch to inline comments * use the ignore outside of the string * follow recommendations for the publishing workflow * re-enable the different CI [skip-rtd]
1 parent 3725ccd commit 366cdcc

File tree

4 files changed

+82
-46
lines changed

4 files changed

+82
-46
lines changed

.github/workflows/python-ci.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,24 @@ concurrency:
1212
group: ${{ github.workflow }}-${{ github.ref }}
1313
cancel-in-progress: true
1414

15+
permissions: {}
16+
1517
jobs:
1618
detect-ci-trigger:
1719
name: detect ci trigger
1820
runs-on: ubuntu-latest
1921
if: |
20-
github.repository == 'keewis/grid-indexing'
22+
github.repository_owner == 'keewis'
2123
&& (github.event_name == 'push' || github.event_name == 'pull_request')
2224
outputs:
2325
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
2426
steps:
2527
- uses: actions/checkout@v5
2628
with:
2729
fetch-depth: 2
30+
persist-credentials: false
2831

29-
- uses: xarray-contrib/ci-trigger@v1
32+
- uses: xarray-contrib/ci-trigger@10cd2bfec3484946a4058a421ddf9cfad101e715 # v1.2.1
3033
id: detect-trigger
3134
with:
3235
keyword: "[skip-ci]"
@@ -52,16 +55,22 @@ jobs:
5255
- "ubuntu-latest"
5356
- "macos-latest"
5457
- "windows-latest"
55-
python-version: ["3.10", "3.12"]
58+
python-version:
59+
- "3.10"
60+
- "3.12"
5661

5762
steps:
5863
- uses: actions/checkout@v5
64+
with:
65+
persist-credentials: false
5966

6067
- name: Install Rust
61-
uses: dtolnay/rust-toolchain@stable
68+
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # 1.0
69+
with:
70+
toolchain: stable
6271

6372
- name: Setup micromamba
64-
uses: mamba-org/setup-micromamba@v2
73+
uses: mamba-org/setup-micromamba@7f29b8b80078b1b601dfa018b0f7425c587c63bb # 2.0.6
6574
with:
6675
environment-file: ci/requirements/environment.yaml
6776
environment-name: python-tests
@@ -71,7 +80,7 @@ jobs:
7180
python=${{matrix.python-version}}
7281
7382
- name: Create rust cache
74-
uses: Swatinem/rust-cache@v2
83+
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # 2.8.0
7584
with:
7685
prefix-key: "py${{ matrix.python-version }}"
7786

@@ -93,19 +102,21 @@ jobs:
93102
94103
- name: Clean up pkg-config
95104
if: runner.os == 'Windows'
96-
run: |
97-
export PKG_CONFIG_PATH="${{env.PKG_CONFIG_PATH}}"
105+
run: | # zizmor: ignore[template-injection]
106+
export PKG_CONFIG_PATH="${{ env.PKG_CONFIG_PATH }}"
98107
99108
# remove dependency paths
100-
sed -i '/Requires.private:/d' $PKG_CONFIG_PATH/*.pc
109+
sed -i '/Requires.private:/d' $(find $PKG_CONFIG_PATH -name "*.pc" -type f)
101110
102111
# check that this actually works
103112
pkg-config --libs --cflags proj 'proj >= 9.4.0'
104113
105114
- name: Install the package
106-
run: |
107-
export PKG_CONFIG_PATH="${{env.PKG_CONFIG_PATH}}"
108-
export PYO3_PYTHON="${{env.PYO3_PYTHON}}"
115+
run: | # zizmor: ignore[template-injection]
116+
if [[ "${{ runner.os }}" == "Windows" ]]; then
117+
export PKG_CONFIG_PATH="${{ env.PKG_CONFIG_PATH }}"
118+
export PYO3_PYTHON="${{ env.PYO3_PYTHON }}"
119+
fi
109120
110121
maturin develop
111122

.github/workflows/rust-ci.yml

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,24 @@ concurrency:
1010
group: ${{ github.workflow }}.${{ github.ref }}
1111
cancel-in-progress: true
1212

13+
permissions: {}
14+
1315
jobs:
1416
detect-ci-trigger:
1517
name: detect ci trigger
1618
runs-on: ubuntu-latest
1719
if: |
18-
github.repository == 'keewis/grid-indexing'
20+
github.repository_owner == 'keewis'
1921
&& (github.event_name == 'push' || github.event_name == 'pull_request')
2022
outputs:
2123
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
2224
steps:
2325
- uses: actions/checkout@v5
2426
with:
2527
fetch-depth: 2
28+
persist-credentials: false
2629

27-
- uses: xarray-contrib/ci-trigger@v1
30+
- uses: xarray-contrib/ci-trigger@10cd2bfec3484946a4058a421ddf9cfad101e715 # v1.2.1
2831
id: detect-trigger
2932
with:
3033
keyword: "[skip-ci]"
@@ -43,10 +46,12 @@ jobs:
4346
matrix:
4447
os:
4548
- "ubuntu-latest"
46-
# building proj-sys on windows appears to not really be possible
4749
- "windows-latest"
4850
- "macos-latest"
49-
python-version: ["3.10", "3.12", "3.13"]
51+
python-version:
52+
- "3.10"
53+
- "3.12"
54+
- "3.13"
5055

5156
env:
5257
FORCE_COLOR: 3
@@ -58,12 +63,16 @@ jobs:
5863
steps:
5964
- name: Checkout
6065
uses: actions/checkout@v5
66+
with:
67+
persist-credentials: false
6168

62-
- name: Install Rust
63-
uses: dtolnay/rust-toolchain@stable
69+
# - name: Install Rust
70+
# uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # 1.0
71+
# with:
72+
# toolchain: stable
6473

6574
- name: Setup micromamba
66-
uses: mamba-org/setup-micromamba@v2
75+
uses: mamba-org/setup-micromamba@7f29b8b80078b1b601dfa018b0f7425c587c63bb # 2.0.6
6776
with:
6877
environment-name: rust-tests
6978
environment-file: ci/requirements/environment-rust.yaml
@@ -72,10 +81,10 @@ jobs:
7281
create-args: >-
7382
python=${{ matrix.python-version }}
7483
75-
- name: Create rust cache
76-
uses: Swatinem/rust-cache@v2
77-
with:
78-
prefix-key: "py${{ matrix.python-version }}"
84+
# - name: Create rust cache
85+
# uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # 2.8.0
86+
# with:
87+
# prefix-key: "py${{ matrix.python-version }}"
7988

8089
- name: Help finding installed libraries
8190
run: |
@@ -98,8 +107,6 @@ jobs:
98107
- name: Help the linker on macos
99108
if: runner.os == 'MacOS'
100109
run: |
101-
export PKG_CONFIG_PATH="${{env.PKG_CONFIG_PATH}}"
102-
103110
mkdir -p target/debug/deps
104111
ln -s $CONDA_PREFIX/lib/*.dylib target/debug/deps/
105112
@@ -108,22 +115,21 @@ jobs:
108115
109116
- name: Clean up pkg-config on windows
110117
if: runner.os == 'Windows'
111-
run: |
112-
export PKG_CONFIG_PATH="${{env.PKG_CONFIG_PATH}}"
118+
run: | # zizmor: ignore[template-injection]
119+
export PKG_CONFIG_PATH="${{ env.PKG_CONFIG_PATH }}"
113120
114121
# remove dependency paths
115-
sed -i '/Requires.private:/d' $PKG_CONFIG_PATH/*.pc
116-
117-
ls -l ${{env.PYO3_PYTHON}}
118-
ls -l $CONDA_PREFIX
122+
sed -i '/Requires.private:/d' $(find $PKG_CONFIG_PATH -name "*.pc" -type f)
119123
120124
# check that this actually works
121125
pkg-config --libs --cflags proj 'proj >= 9.4.0'
122126
123127
- name: Run tests
124-
run: |
125-
export PKG_CONFIG_PATH="${{env.PKG_CONFIG_PATH}}"
126-
export PYO3_PYTHON="${{env.PYO3_PYTHON}}"
128+
run: | # zizmor: ignore[template-injection]
129+
if [[ "${{ runner.os }}" == "Windows" ]]; then
130+
export PKG_CONFIG_PATH="${{ env.PKG_CONFIG_PATH }}"
131+
export PYO3_PYTHON="${{ env.PYO3_PYTHON }}"
132+
fi
127133
128134
cargo build --tests --keep-going
129135
cargo test --no-fail-fast
@@ -146,14 +152,17 @@ jobs:
146152
steps:
147153
- name: Checkout
148154
uses: actions/checkout@v5
155+
with:
156+
persist-credentials: false
149157

150158
- name: Install Rust
151-
uses: dtolnay/rust-toolchain@stable
159+
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # 1.0
152160
with:
161+
toolchain: stable
153162
components: rustfmt, clippy
154163

155164
- name: Setup micromamba
156-
uses: mamba-org/setup-micromamba@v2
165+
uses: mamba-org/setup-micromamba@7f29b8b80078b1b601dfa018b0f7425c587c63bb # 2.0.6
157166
with:
158167
environment-name: rust-tests
159168
environment-file: ci/requirements/environment-rust.yaml
@@ -163,7 +172,7 @@ jobs:
163172
python=${{ matrix.python-version }}
164173
165174
- name: Create rust cache
166-
uses: Swatinem/rust-cache@v2
175+
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # 2.8.0
167176

168177
- name: Cargo clippy
169178
run: |

.github/workflows/wheels.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ jobs:
4343
# manylinux: auto
4444
steps:
4545
- uses: actions/checkout@v5
46+
with:
47+
persist-credentials: false
4648

4749
- name: Build wheels
48-
uses: PyO3/maturin-action@v1
50+
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4
4951
with:
5052
target: ${{ matrix.platform.target }}
5153
args: --release --out dist -i 3.10 -i 3.11 -i 3.12 -i 3.13
52-
sccache: "true"
54+
sccache: "false"
5355
manylinux: ${{ matrix.manylinux }}
5456
before-script-linux: |
5557
sudo apt-get update
@@ -83,13 +85,15 @@ jobs:
8385
target: armv7
8486
steps:
8587
- uses: actions/checkout@v5
88+
with:
89+
persist-credentials: false
8690

8791
- name: Build wheels
88-
uses: PyO3/maturin-action@v1
92+
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4
8993
with:
9094
target: ${{ matrix.platform.target }}
9195
args: --release --out dist -i 3.10 -i 3.11 -i 3.12 -i 3.13
92-
sccache: "true"
96+
sccache: "false"
9397
manylinux: musllinux_1_2
9498
before-script-linux: |
9599
sudo apt-get update
@@ -117,17 +121,19 @@ jobs:
117121
target: x64
118122
steps:
119123
- uses: actions/checkout@v5
124+
with:
125+
persist-credentials: false
120126

121127
- name: check installed libs
122128
run: |
123129
pkg-config --list-all
124130
125131
- name: Build wheels
126-
uses: PyO3/maturin-action@v1
132+
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4
127133
with:
128134
target: ${{ matrix.platform.target }}
129135
args: --release --out dist -i 3.10 -i 3.11 -i 3.12 -i 3.13
130-
sccache: "true"
136+
sccache: "false"
131137

132138
- name: Upload wheels
133139
uses: actions/upload-artifact@v4
@@ -146,17 +152,19 @@ jobs:
146152
target: aarch64
147153
steps:
148154
- uses: actions/checkout@v5
155+
with:
156+
persist-credentials: false
149157

150158
- name: check installed libs
151159
run: |
152160
pkg-config --list-all
153161
154162
- name: Build wheels
155-
uses: PyO3/maturin-action@v1
163+
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4
156164
with:
157165
target: ${{ matrix.platform.target }}
158166
args: --release --out dist -i 3.10 -i 3.11 -i 3.12 -i 3.13
159-
sccache: "true"
167+
sccache: "false"
160168

161169
- name: Upload wheels
162170
uses: actions/upload-artifact@v4
@@ -212,4 +220,4 @@ jobs:
212220
with:
213221
subject-path: "dist/*.whl"
214222
- name: Publish to PyPI
215-
uses: pypa/gh-action-pypi-publish@release/v1
223+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ repos:
5353
hooks:
5454
- id: typos
5555
exclude: ".*\\.ipynb$"
56+
- repo: https://github.com/mpalmer/action-validator
57+
rev: v0.7.0
58+
hooks:
59+
- id: action-validator
60+
- repo: https://github.com/zizmorcore/zizmor-pre-commit
61+
rev: v1.12.1
62+
hooks:
63+
- id: zizmor
5664
- repo: local
5765
hooks:
5866
- id: cargo-fmt

0 commit comments

Comments
 (0)