Skip to content

Commit 5cc067d

Browse files
authored
fix(scripts): do not allow running scripts as root; prevent accidental mishaps; update rust checks (#259)
CHANGELOG: - [ ] Fix scripts so that the fail when run as root to prevent accidental mishaps. - [ ] Update rust lint checks. - [ ] Handlebarrz has linker errors when built individually, so exclude temporarily from workspace Cargo.toml. - [ ] Move handlebarrz-specific script to scripts/run_handlebarrz_tests - [ ] Add scripts to test rust code with nightly (non-failing) and stable.
1 parent 13a4b25 commit 5cc067d

24 files changed

+278
-525
lines changed

.github/workflows/python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
run: ./scripts/check_license
8585

8686
- name: Run Rust tests for handlebarrz
87-
run: ./scripts/run_rust_tests
87+
run: ./scripts/run_handlebarrz_tests
8888

8989
- name: Build Rust extension for Python ${{ matrix.python-version }}
9090
working-directory: ./python

.github/workflows/rust.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
name: "Rust checks"
18+
19+
on:
20+
pull_request:
21+
paths:
22+
- "rs/**"
23+
- "Cargo.toml"
24+
- "Cargo.lock"
25+
- ".github/workflows/rust.yml"
26+
27+
jobs:
28+
check-build-test:
29+
name: Check, Build & Test (${{ matrix.toolchain }}, ${{ matrix.os_config.os }}-${{ matrix.os_config.arch }})
30+
runs-on: ${{ matrix.os_config.os }}
31+
strategy:
32+
fail-fast: false # Keep running other jobs even if one fails
33+
matrix:
34+
os_config:
35+
- { os: ubuntu-latest, arch: x64 }
36+
- { os: ubuntu-latest, arch: arm64 }
37+
- { os: macos-latest, arch: arm64 }
38+
toolchain: [stable, nightly]
39+
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v4
43+
44+
- name: Install Rust toolchain (${{ matrix.toolchain }})
45+
uses: dtolnay/rust-toolchain@master
46+
with:
47+
toolchain: ${{ matrix.toolchain }}
48+
49+
- name: Cache Cargo registry and index
50+
uses: actions/cache@v4
51+
with:
52+
path: |
53+
~/.cargo/bin/
54+
~/.cargo/registry/index/
55+
~/.cargo/registry/cache/
56+
~/.cargo/git/db/
57+
target/
58+
key: ${{ matrix.os_config.os }}-${{ matrix.os_config.arch }}-cargo-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.lock') }}
59+
60+
- name: Check code
61+
run: cargo check --all-targets --workspace
62+
# Allow nightly check to fail without failing the entire workflow
63+
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
64+
65+
- name: Build code
66+
run: cargo build --all-targets --workspace
67+
# Allow nightly build to fail
68+
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
69+
70+
- name: Run tests
71+
run: cargo test --all-targets --workspace
72+
# Allow nightly tests to fail
73+
continue-on-error: ${{ matrix.toolchain == 'nightly' }}

0 commit comments

Comments
 (0)