Skip to content

Commit

Permalink
Add fallback input option to ensure that fallback is not used
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jun 9, 2024
1 parent f6578d8 commit 4a88678
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
run: just --version & shfmt --version & protoc --version
shell: cmd
if: startsWith(matrix.os, 'windows')
# We use the version output to check the version of binstall, but they
# We use the version output to check the version of cargo-binstall, but they
# several times change the version output format in the past so we need to
# check it with CI. (e.g., 0.14.0->0.16.0 update change it
# from "cargo-binstall <version>" to "<version>")
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com

## [Unreleased]

- Add `fallback: none` input option to ensure that fallback is not used. ([#517](https://github.com/taiki-e/install-action/pull/517))

- `cargo-nextest` installation no longer use `cargo-binstall`.
This improves security, performance, robustness of installation. See [#487](https://github.com/taiki-e/install-action/issues/487) for more.

Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ See [TOOLS.md](TOOLS.md) for the list of tools that are installed from manifests

If a tool not included in the list above is specified, this action uses [cargo-binstall] as a fallback.

If you want to ensure that fallback is not used, use `fallback: none`.

```yaml
- uses: taiki-e/install-action@v2
with:
tool: cargo-hack
# Possible values:
# - none: disable all fallback
# - cargo-binstall (default): cargo-binstall (includes quickinstall)
fallback: none
```

### Add support for new tool

See the [development guide](DEVELOPMENT.md) for how to add support for new tool.
Expand All @@ -93,6 +105,8 @@ Additionally, we also verify signature if the tool distributes signed archives.

See the linked documentation for information on security when installed using [snap](https://snapcraft.io/docs) or [cargo-binstall](https://github.com/cargo-bins/cargo-binstall#faq).

See the [Supported tools section](#supported-tools) for how to ensure that fallback is not used.

## Compatibility

This action has been tested for GitHub-hosted runners (Ubuntu, macOS, Windows) and containers (Ubuntu, Debian, Fedora, CentOS, Alma, openSUSE, Arch, Alpine).
Expand Down
2 changes: 2 additions & 0 deletions TOOLS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This is a list of tools that are installed from manifests managed in this action

If a tool not included in the list below is specified, this action uses [cargo-binstall] as a fallback.

See the [Supported tools section in README.md](README.md#supported-tools) for how to ensure that fallback is not used.

> If `$CARGO_HOME/bin` is not available, Rust-related binaries will be installed to `$HOME/.cargo/bin`.<br>
> If `$HOME/.cargo/bin` is not available, Rust-related binaries will be installed to `/usr/local/bin`.<br>
> If `/usr/local/bin` is not available, binaries will be installed to `$HOME/.install-action/bin`.<br>
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ inputs:
description: Whether to enable checksums
required: false
default: 'true'
fallback:
description: Whether to use fallback (none or cargo-binstall)
required: false
default: 'cargo-binstall'

# Note:
# - inputs.* should be manually mapped to INPUT_* due to https://github.com/actions/runner/issues/665
Expand All @@ -22,3 +26,4 @@ runs:
env:
INPUT_TOOL: ${{ inputs.tool }}
INPUT_CHECKSUM: ${{ inputs.checksum }}
INPUT_FALLBACK: ${{ inputs.fallback }}
9 changes: 9 additions & 0 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,12 @@ case "${enable_checksum}" in
*) bail "'checksum' input option must be 'true' or 'false': '${enable_checksum}'" ;;
esac

fallback="${INPUT_FALLBACK:-}"
case "${fallback}" in
none | cargo-binstall) ;;
*) bail "'fallback' input option must be 'none' or 'cargo-binstall': '${fallback}'" ;;
esac

# Refs: https://github.com/rust-lang/rustup/blob/HEAD/rustup-init.sh
base_distro=""
exe=""
Expand Down Expand Up @@ -791,6 +797,9 @@ done

if [[ ${#unsupported_tools[@]} -gt 0 ]]; then
IFS=','
case "${fallback}" in
none) bail "install-action does not support ${unsupported_tools[*]} (fallback is disabled by 'fallback: none' input option)" ;;
esac
info "install-action does not support ${unsupported_tools[*]}; fallback to cargo-binstall"
IFS=$'\n\t'
install_cargo_binstall
Expand Down

0 comments on commit 4a88678

Please sign in to comment.