Skip to content

Commit

Permalink
Don't override RUSTFLAGS on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 committed Feb 4, 2025
1 parent 1afb0d8 commit a4998b6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 4 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ jobs:
name: Publish crates
runs-on: ubuntu-latest
timeout-minutes: 60
env:
RUSTFLAGS: ${{ github.ref == 'refs/heads/main' && '-D warnings' || '' }}
steps:
- name: Set environment
env:
W_FLAGS: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '-Dwarnings' || '' }}
# Setting `RUSTFLAGS` overrides any flags set on .cargo/config.toml, so we need to
# set the target flags instead which are cumulative.
# Track https://github.com/rust-lang/cargo/issues/5376
run: |
target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
echo "CARGO_TARGET_${target}_RUSTFLAGS=$W_FLAGS" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4

Expand Down
36 changes: 35 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ concurrency:
cancel-in-progress: true

env:
RUSTFLAGS: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '-D warnings' || '' }}
W_FLAGS: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '-D warnings' || '' }}

jobs:
coverage:
Expand All @@ -26,6 +26,13 @@ jobs:
timeout-minutes: 60
if: ${{ github.ref == 'refs/heads/main' || github.base_ref == 'main' }}
steps:
- name: Set environment
# Setting `RUSTFLAGS` overrides any flags set on .cargo/config.toml, so we need to
# set the target flags instead which are cumulative.
# Track https://github.com/rust-lang/cargo/issues/5376
run: |
target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
echo "CARGO_TARGET_${target}_RUSTFLAGS=$W_FLAGS" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4

Expand Down Expand Up @@ -56,6 +63,9 @@ jobs:
timeout-minutes: 60
env:
RUSTUP_WINDOWS_PATH_ADD_BIN: 1
# TODO: Make a small Rust tool that does this
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '-D warnings' || '' }}
CARGO_TARGET_AARCH64_APPLE_DARWIN_RUSTFLAGS: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '-D warnings' || '' }}
strategy:
matrix:
os:
Expand Down Expand Up @@ -88,6 +98,10 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Set environment
run: |
target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
echo "CARGO_TARGET_${target}_RUSTFLAGS=$W_FLAGS" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4

Expand All @@ -109,6 +123,10 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Set environment
run: |
target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
echo "CARGO_TARGET_${target}_RUSTFLAGS=$W_FLAGS" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4

Expand All @@ -126,6 +144,10 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Set environment
run: |
target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
echo "CARGO_TARGET_${target}_RUSTFLAGS=$W_FLAGS" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4

Expand Down Expand Up @@ -160,6 +182,10 @@ jobs:
env:
RUSTDOCFLAGS: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '-D warnings' || '' }}
steps:
- name: Set environment
run: |
target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
echo "CARGO_TARGET_${target}_RUSTFLAGS=$W_FLAGS" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4

Expand All @@ -179,6 +205,10 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Set environment
run: |
target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
echo "CARGO_TARGET_${target}_RUSTFLAGS=$W_FLAGS" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4

Expand All @@ -202,6 +232,10 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Set environment
run: |
target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
echo "CARGO_TARGET_${target}_RUSTFLAGS=$W_FLAGS" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4

Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/webassembly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ jobs:
timeout-minutes: 60
env:
WASM_PACK_PATH: ~/.cargo/bin/wasm-pack
RUSTFLAGS: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '-Dwarnings' || '' }}
steps:
- name: Set environment
env:
W_FLAGS: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '-Dwarnings' || '' }}
# Setting `RUSTFLAGS` overrides any flags set on .cargo/config.toml, so we need to
# set the target flags instead which are cumulative.
# Track https://github.com/rust-lang/cargo/issues/5376
run: echo "CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUSTFLAGS=$W_FLAGS" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4

Expand Down

0 comments on commit a4998b6

Please sign in to comment.