@@ -12,14 +12,22 @@ concurrency:
1212 cancel-in-progress : true
1313
1414env :
15- RUSTFLAGS : -Dwarnings
15+ FLAGS : ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '-D warnings' || '' }}
1616 CARGO_TERM_COLOR : always
1717
1818jobs :
1919 lint :
2020 name : Lint
2121 runs-on : ubuntu-latest
2222 steps :
23+ - name : Set environment
24+ # Setting `RUSTFLAGS` overrides any flags set on .cargo/config.toml, so we need to
25+ # set the target flags instead which are cumulative.
26+ # Track https://github.com/rust-lang/cargo/issues/5376
27+ run : |
28+ target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
29+ echo "CARGO_TARGET_${target}_RUSTFLAGS=$FLAGS" >> $GITHUB_ENV
30+
2331 - uses : actions/checkout@v4
2432 - uses : dtolnay/rust-toolchain@stable
2533 with :
4351 runs-on : ubuntu-latest
4452 timeout-minutes : 60
4553 steps :
54+ - name : Set environment
55+ run : |
56+ target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
57+ echo "CARGO_TARGET_${target}_RUSTFLAGS=$FLAGS" >> $GITHUB_ENV
58+
4659 - name : Checkout repository
4760 uses : actions/checkout@v4
4861
6174
6275 build-test :
6376 name : Test (${{ matrix.rust.name }}, ${{ matrix.os }})
77+ env :
78+ RUSTUP_WINDOWS_PATH_ADD_BIN : 1
79+ # NOTE: Boa comment mentions a small tool to handle this ... would be nice.
80+ CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS : ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '-D warnings' || '' }}
81+ CARGO_TARGET_AARCH64_APPLE_DARWIN_RUSTFLAGS : ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '-D warnings' || '' }}
6482 strategy :
6583 matrix :
6684 rust :
@@ -86,6 +104,11 @@ jobs:
86104 name : Test feature matrix
87105 runs-on : ubuntu-latest
88106 steps :
107+ - name : Set environment
108+ run : |
109+ target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
110+ echo "CARGO_TARGET_${target}_RUSTFLAGS=$FLAGS" >> $GITHUB_ENV
111+
89112 - uses : actions/checkout@v4
90113 - uses : dtolnay/rust-toolchain@master
91114 with :
@@ -110,6 +133,11 @@ jobs:
110133 os : [ubuntu-latest] # Todo: potentially add more if we add cpp tests
111134 runs-on : ${{ matrix.os }}
112135 steps :
136+ - name : Set environment
137+ run : |
138+ target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
139+ echo "CARGO_TARGET_${target}_RUSTFLAGS=$FLAGS" >> $GITHUB_ENV
140+
113141 - uses : actions/checkout@v4
114142 - uses : dtolnay/rust-toolchain@master
115143 with :
0 commit comments