Skip to content

Commit 5952bec

Browse files
committed
chore: configure RUST_BACKTRACE=1 for builds by default
1 parent 961d0db commit 5952bec

File tree

4 files changed

+82
-6
lines changed

4 files changed

+82
-6
lines changed

.github/workflows/rust.yml

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ jobs:
4141
- name: Checkout code
4242
uses: actions/checkout@v4
4343

44-
- name: Install Rust toolchain (${{ matrix.toolchain }})
45-
uses: dtolnay/rust-toolchain@master
46-
with:
47-
toolchain: ${{ matrix.toolchain }}
48-
4944
- name: Cache Cargo registry and index
5045
uses: actions/cache@v4
5146
with:
@@ -68,6 +63,70 @@ jobs:
6863
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
6964

7065
- name: Run tests
66+
env:
67+
RUST_BACKTRACE: 1
7168
run: cargo test --all-targets --workspace
7269
# Allow nightly tests to fail
7370
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
71+
72+
check-build-test-musl-matrix:
73+
name: Check, Build & Test (${{ matrix.toolchain }}, alpine-${{ matrix.arch }}-musl)
74+
runs-on: ubuntu-latest # Runner OS
75+
container: # Run steps inside this container
76+
image: rust:alpine # Use official Rust image based on Alpine (multi-arch)
77+
strategy:
78+
fail-fast: false
79+
matrix:
80+
include:
81+
- arch: x86_64
82+
target: x86_64-unknown-linux-musl
83+
- arch: aarch64
84+
target: aarch64-unknown-linux-musl
85+
toolchain: [stable, nightly]
86+
steps:
87+
- name: Checkout code
88+
uses: actions/checkout@v4
89+
90+
- name: Install musl build dependencies
91+
run: |
92+
apk add --no-cache musl-dev gcc bash docker-cli
93+
94+
- name: Set up QEMU
95+
uses: docker/setup-qemu-action@v3
96+
97+
- name: Install Rust toolchain (${{ matrix.toolchain }}) via rustup
98+
shell: bash
99+
run: |
100+
rustup toolchain install ${{ matrix.toolchain }} --profile minimal --target ${{ matrix.target }}
101+
rustup default ${{ matrix.toolchain }}
102+
103+
- name: Cache Cargo registry and index (musl)
104+
uses: actions/cache@v4
105+
with:
106+
path: |
107+
/usr/local/cargo/registry/index/
108+
/usr/local/cargo/registry/cache/
109+
/usr/local/cargo/git/db/
110+
target/
111+
# Include architecture and toolchain in cache key
112+
key: linux-musl-${{ matrix.arch }}-cargo-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.lock') }}
113+
114+
- name: Check code (musl, ${{ matrix.arch }}, ${{ matrix.toolchain }})
115+
shell: bash
116+
run: cargo check --all-targets --workspace --target ${{ matrix.target }}
117+
# Allow nightly check to fail
118+
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
119+
120+
- name: Build code (musl, ${{ matrix.arch }}, ${{ matrix.toolchain }})
121+
shell: bash
122+
run: cargo build --all-targets --workspace --target ${{ matrix.target }}
123+
# Allow nightly build to fail
124+
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
125+
126+
- name: Run tests (musl, ${{ matrix.arch }}, ${{ matrix.toolchain }})
127+
shell: bash
128+
env:
129+
RUST_BACKTRACE: 1 # Keep the backtrace env var
130+
run: cargo test --all-targets --workspace --target ${{ matrix.target }}
131+
# Allow nightly tests to fail
132+
continue-on-error: ${{ matrix.toolchain == 'nightly' }}

rust.bazelrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# RUST_BACKTRACE=1
2+
build --action_env=RUST_BACKTRACE=1
3+
run --run_env=RUST_BACKTRACE=1
4+
test --action_env=RUST_BACKTRACE=1
5+
test --test_env=RUST_BACKTRACE=1
6+
7+
# RUST_BACKTRACE=full
8+
build:debug --action_env=RUST_BACKTRACE=full
9+
run:debug --run_env=RUST_BACKTRACE=full
10+
test:debug --action_env=RUST_BACKTRACE=full
11+
test:debug --test_env=RUST_BACKTRACE=full

scripts/run_handlebarrz_tests

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ for arg in "$@"; do
4141
esac
4242
done
4343

44+
export RUST_BACKTRACE=1
45+
4446
if [ "$VERBOSE" = true ]; then
4547
echo "Running tests in verbose mode..."
4648
cargo test "${CARGO_ARGS[@]}"

scripts/run_rust_checks

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@ function error_exit() {
3030
}
3131

3232
# Check if rustup is installed
33-
if ! command -v rustup &> /dev/null; then
33+
if ! command -v rustup &>/dev/null; then
3434
error_exit "rustup could not be found. Please install rustup first: https://rustup.rs/"
3535
fi
3636

3737
echo "=== Running Rust tests ==="
3838

39+
# Show relevant stack traces.
40+
export RUST_BACKTRACE=1
41+
#export RUST_BACKTRACE=full # For more detailed stack traces.
42+
3943
# Install stable and nightly toolchains if they aren't already installed.
4044
echo "--- Ensuring stable and nightly toolchains are installed ---"
4145
rustup toolchain install stable --no-self-update || error_exit "Failed to install stable toolchain"

0 commit comments

Comments
 (0)