Skip to content

Commit d921e53

Browse files
authored
Merge pull request #4 from Reloaded-Project/binstall
Added: Support for cargo-binstall
2 parents 00a466b + 67d481a commit d921e53

File tree

2 files changed

+57
-24
lines changed

2 files changed

+57
-24
lines changed

README.MD

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -113,29 +113,45 @@ To use this action in your own repository:
113113

114114
### Inputs
115115

116-
| Input | Required | Default | Description |
117-
| ---------------------------- | -------- | ---------------- | -------------------------------------------------------------------------------------- |
118-
| `rust-project-path` | No | `.` | Path to the Rust project |
119-
| `workspace-path` | No | `.` | Workspace folder where `target` directory is. Uses `rust-project-path` if not set. |
120-
| `pgo-project-path` | No | `.` | Path to the Rust project used for gathering PGO data. Can be same or separate project. |
121-
| `crate-name` | Yes | | Name of the Rust crate (used to determine file name) |
122-
| `target` | Yes | | The target platform for the Rust compiler |
123-
| `features` | No | `''` | Comma-separated list of features to include in the build |
124-
| `no-default-features` | No | `false` | Do not include default features in the build |
125-
| `use-pgo` | No | `false` | Use Profile-Guided Optimization [PGO] to build the library. |
126-
| `pgo-benchmark-name` | No | `'my_benchmark'` | Benchmark name to use with PGO. |
127-
| `use-cross` | No | `false` | Use cross-rs for building. If false, use cargo. |
128-
| `additional-rustflags` | No | `''` | Additional RUSTFLAGS to pass to the Rust compiler |
129-
| `additional-rustc-args` | No | `''` | Additional arguments to pass directly to `rustc` |
130-
| `use-cache` | No | `true` | Enable or disable the build cache using `Swatinem/rust-cache`. |
131-
| `upload-artifacts` | No | `true` | Upload the built artifacts as a GitHub Actions artifact |
132-
| `abort-on-panic` | No | `true` | Abort immediately on panic. If false, the default panic handler is used. |
133-
| `build-library` | No | `false` | Build a library instead of a binary. |
134-
| `run-tests-and-coverage` | No | `false` | Run tests and coverage using the `devops-rust-test-and-coverage` action. |
135-
| `upload-coverage-to-codecov` | No | `true` | Uploads coverage to codecov if `run-tests-and-coverage` is enabled. |
136-
| `size-optimized-std` | No | `false` | Builds `std` with size optimizations, such as reduced `core::fmt` footprint. |
137-
| `additional-std-features` | No | `` | Specify extra `build-std` features. |
138-
| `use-tarpaulin` | No | `true` | Use tarpaulin for code coverage. If false, code coverage will be disabled. |
116+
#### Parameters Used by This Action
117+
118+
These parameters are processed and used directly by the `rust-lightweight-binary` action:
119+
120+
| Input | Required | Default | Description |
121+
| ------------------------- | -------- | ---------------- | -------------------------------------------------------------------------------------- |
122+
| `rust-project-path` | No | `.` | Path to the Rust project |
123+
| `workspace-path` | No | `.` | Workspace folder where `target` directory is. Uses `rust-project-path` if not set. |
124+
| `pgo-project-path` | No | `.` | Path to the Rust project used for gathering PGO data. Can be same or separate project. |
125+
| `crate-name` | Yes | | Name of the Rust crate (used to determine file name) |
126+
| `target` | Yes | | The target platform for the Rust compiler |
127+
| `features` | No | `''` | Comma-separated list of features to include in the build |
128+
| `no-default-features` | No | `false` | Do not include default features in the build |
129+
| `use-pgo` | No | `false` | Use Profile-Guided Optimization [PGO] to build the library. |
130+
| `pgo-benchmark-name` | No | `'my_benchmark'` | Benchmark name to use with PGO. |
131+
| `use-cross` | No | `false` | Use cross-rs for building. If false, use cargo. |
132+
| `additional-rustflags` | No | `''` | Additional RUSTFLAGS to pass to the Rust compiler |
133+
| `additional-rustc-args` | No | `''` | Additional arguments to pass directly to `rustc` |
134+
| `use-cache` | No | `true` | Enable or disable the build cache using `Swatinem/rust-cache`. |
135+
| `upload-artifacts` | No | `true` | Upload the built artifacts as a GitHub Actions artifact |
136+
| `abort-on-panic` | No | `true` | Abort immediately on panic. If false, the default panic handler is used. |
137+
| `build-library` | No | `false` | Build a library instead of a binary. |
138+
| `run-tests-and-coverage` | No | `false` | Run tests and coverage using the `devops-rust-test-and-coverage` action. |
139+
| `size-optimized-std` | No | `false` | Builds `std` with size optimizations, such as reduced `core::fmt` footprint. |
140+
| `additional-std-features` | No | `` | Specify extra `build-std` features. |
141+
142+
#### Parameters Passed Through to `devops-rust-test-and-coverage`
143+
144+
These parameters are only used when `run-tests-and-coverage` is enabled and are passed directly to the [devops-rust-test-and-coverage][devops-test-coverage] action:
145+
146+
| Input | Required | Default | Description |
147+
| ---------------------------- | -------- | ------- | ----------------------------------------------------------------------------------------------------- |
148+
| `upload-coverage-to-codecov` | No | `true` | Whether to upload coverage to Codecov |
149+
| `codecov-token` | No | | Codecov token for uploading coverage |
150+
| `use-tarpaulin` | No | `true` | Whether to use Tarpaulin for code coverage. If false, only runs tests. |
151+
| `use-binstall` | No | `true` | Whether to use cargo-binstall for installing components like tarpaulin. If false, uses cargo install. |
152+
| `install-binstall` | No | `true` | Whether to install cargo-binstall. If false, assumes it is already available in the environment. |
153+
154+
**Note:** The following parameters are used by both this action AND passed through to the test action: `target`, `features`, `no-default-features`, `use-cross`.
139155

140156
### Setting up Profile-Guided Optimization (PGO)
141157

@@ -263,6 +279,7 @@ build them in a single job:
263279
target: x86_64-unknown-linux-gnu
264280
use-cache: true # Only first build enables cache
265281
upload-artifacts: true
282+
# install-binstall: true (default)
266283
267284
- name: Build CLI Crate
268285
uses: Reloaded-Project/devops-rust-lightweight-binary@v1
@@ -271,6 +288,7 @@ build them in a single job:
271288
crate-name: cli-crate
272289
target: x86_64-unknown-linux-gnu
273290
use-cache: false # Subsequent builds disable cache
291+
install-binstall: false # Avoid installing cargo-binstall again
274292
upload-artifacts: true
275293
```
276294

@@ -282,6 +300,10 @@ So you should only set `use-cache` on the first project.
282300
> If you are using [devops-test-coverage] action, that also creates a cache by default.
283301
> Be aware of this, you may want to set `use-cache` false if running tests at the end, or set
284302
> `use-cache` false on `devops-rust-lightweight-binary` if tests are ran first.
303+
>
304+
> Additionally, cargo-binstall will be installed by default. If you want to avoid installing
305+
> cargo-binstall multiple times across multiple build steps, set `install-binstall` to false
306+
> on subsequent steps.
285307
>
286308
> ```yaml
287309
> - name: Run Tests
@@ -291,6 +313,7 @@ So you should only set `use-cache` on the first project.
291313
> use-cross: ${{ matrix.use-cross }}
292314
> codecov-token: ${{ secrets.CODECOV_TOKEN }}\
293315
> # use-cache: true # use-cache is enabled by default
316+
> # install-binstall: true # install-binstall is enabled by default
294317
> ```
295318

296319
#### Parallel Builds

action.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ inputs:
9090
description: 'Enable or disable the build cache using Swatinem/rust-cache.'
9191
required: false
9292
default: "true"
93+
use-binstall:
94+
description: 'Whether to use cargo-binstall in the test-and-coverage action for installing tools like tarpaulin. This parameter is passed through to the devops-rust-test-and-coverage action.'
95+
required: false
96+
default: "true"
97+
install-binstall:
98+
description: 'Whether to install cargo-binstall to make it available for the test-and-coverage action. If false, assumes it is already available in the environment.'
99+
required: false
100+
default: "true"
93101

94102
runs:
95103
using: 'composite'
@@ -343,4 +351,6 @@ runs:
343351
features: ${{ inputs.features }}
344352
no-default-features: ${{ inputs.no-default-features }}
345353
use-cross: ${{ inputs.use-cross }}
346-
use-tarpaulin: ${{ inputs.use-tarpaulin }}
354+
use-tarpaulin: ${{ inputs.use-tarpaulin }}
355+
use-binstall: ${{ inputs.use-binstall }}
356+
install-binstall: ${{ inputs.install-binstall }}

0 commit comments

Comments
 (0)