Skip to content

Commit 1ef811f

Browse files
committed
Restore behavior to not touch existing RUSTFLAGS variable
Add changelog
1 parent 70241ab commit 1ef811f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
Before only the items listed in `rust-toolchain` were installed.
1616
Now all the items from the toolchain file are installed and then all the `target`s and `components` that are provided as action inputs.
1717
This allows installing extra tools only for CI or simplify testing special targets in CI.
18+
* Allow skipping the creation of a `RUSTFLAGS` environment variable.
19+
Cargos logic for rustflags is complicated, and setting the `RUSTFLAGS` environment variable prevents other ways of working.
20+
Provide a new `rustflags` input, which controls the environment variable creation.
21+
If the value is set to the empty string, then `RUSTFLAGS` is not created.
22+
23+
Pre-existing `RUSTFLAGS` variables are never modified by this extension.
1824

1925
## [1.4.4] - 2023-03-18
2026

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ Afterward, the `components` and `target` specified via inputs are installed in a
5757
### RUSTFLAGS
5858

5959
By default, this action sets the `RUSTFLAGS` environment variable to `-D warnings`.
60+
However, rustflags sources are mutually exclusive, so setting this environment variable omits any configuration through `target.*.rustflags` or `build.rustflags`.
6061

61-
However, rustflags sources are mutually exclusive, so setting this environment
62-
variable omits any configuration through `target.*.rustflags` or
63-
`build.rustflags`.
62+
* If `RUSTFLAGS` is already set, no modifications of the variable are made and the original value remains.
63+
* If `RUSTFLAGS` is unset and the `rustflags` input is empty (i.e., the empty string), then it will remain unset.
64+
Use this, if you want to prevent the value from being set because you make use of `target.*.rustflags` or `build.rustflags`.
65+
* Otherwise, the environment variable `RUSTFLAGS` is set to the content of `rustflags`.
6466

6567
To prevent this from happening, set the `rustflags` input to an empty string, which will
6668
prevent the action from setting `RUSTFLAGS` at all, keeping any existing preferences.
@@ -82,4 +84,4 @@ License].
8284

8385
[MIT License]: LICENSE
8486
[Problem Matchers]: https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md
85-
[Cargo reference]: https://doc.rust-lang.org/cargo/reference/config.html?highlight=unknown#buildrustflags
87+
[Cargo reference]: https://doc.rust-lang.org/cargo/reference/config.html?highlight=unknown#buildrustflags

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ runs:
8080
if [[ ! -v RUST_BACKTRACE ]]; then
8181
echo "RUST_BACKTRACE=short" >> $GITHUB_ENV
8282
fi
83-
if [[ "$NEW_RUSTFLAGS" != "" ]]; then
83+
if [[ ( ! -v RUSTFLAGS ) && $NEW_RUSTFLAGS != "" ]]; then
8484
echo "RUSTFLAGS=$NEW_RUSTFLAGS" >> $GITHUB_ENV
8585
fi
8686
# Enable faster sparse index on nightly

0 commit comments

Comments
 (0)