diff --git a/.github/.cspell/project-dictionary.txt b/.github/.cspell/project-dictionary.txt index 26e236d3..ca7e64b9 100644 --- a/.github/.cspell/project-dictionary.txt +++ b/.github/.cspell/project-dictionary.txt @@ -18,6 +18,7 @@ nextest protobuf protoc protocolbuffers +pwsh quickinstall rockylinux rustwasm diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b3e9bd53..baf02554 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,6 +64,21 @@ jobs: - uses: ./ with: tool: ${{ matrix.tool }} + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell + - name: Test bash + run: just --version; shfmt --version; protoc --version + shell: bash + - name: Test sh + run: just --version; shfmt --version; protoc --version + shell: sh + if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos') + - name: Test pwsh + run: just --version; shfmt --version; protoc --version + shell: pwsh + - name: Test powershell + run: just --version; shfmt --version; protoc --version + shell: powershell + if: startsWith(matrix.os, 'windows') # We use the version output to check the version of 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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 918761ab..6ef05e73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,14 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com ## [Unreleased] +- Support `cargo-tarpaulin`. ([#65](https://github.com/taiki-e/install-action/pull/65), thanks @orhun) + +- Allow installing cargo subcommands without `cargo`. + +- Fix issue where installed non-Rust related binaries cannot be found from PowerShell on Windows. Rust-related binaries, Unix shells such as bash, and non-Windows OS are not affected by this issue. + +- Fix install failure of Rust-related binaries when `$CARGO_HOME/bin` exists, but is not included in the `$PATH`. This failure occurred in slightly odd cases, such as multiple installations of rust in different directories. + ## [2.3.5] - 2023-02-04 - Update `cross@latest` to 0.2.5. diff --git a/README.md b/README.md index 0acfcb11..69c1db53 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ This action has been tested for GitHub-hosted runners (Ubuntu, macOS, Windows) a To use this action in self-hosted runners or in containers, at least the following tools are required: - bash -- cargo (if you install cargo subcommands or use cargo-binstall fallback) +- cargo (if you use cargo-binstall fallback) ## Related Projects diff --git a/main.sh b/main.sh index d7ef6ef7..1607381d 100755 --- a/main.sh +++ b/main.sh @@ -62,7 +62,7 @@ download_and_extract() { bin_dir="${HOME}/.install-action/bin" if [[ ! -d "${bin_dir}" ]]; then mkdir -p "${bin_dir}" - echo "${bin_dir}" >>"${GITHUB_PATH}" + canonicalize_windows_path "${bin_dir}" >>"${GITHUB_PATH}" export PATH="${PATH}:${bin_dir}" fi fi @@ -294,6 +294,12 @@ sys_install() { fedora) dnf_install "$@" ;; esac } +canonicalize_windows_path() { + case "${host_os}" in + windows) sed <<<"$1" 's/^\/c\//C:\\/' ;; + *) echo "$1" ;; + esac +} # cargo-binstall may call `cargo install` on their fallback: https://github.com/taiki-e/install-action/pull/54#issuecomment-1383140833 # cross calls rustup on `cross --version` if the current directly is cargo workspace. @@ -395,7 +401,10 @@ esac tmp_dir="${HOME}/.install-action/tmp" cargo_bin="${CARGO_HOME:-"${HOME}/.cargo"}/bin" -if [[ ! -d "${cargo_bin}" ]]; then +# If $CARGO_HOME does not exist, or cargo installed outside of $CARGO_HOME/bin +# is used ($CARGO_HOME/bin is most likely not included in the PATH), fallback to +# /usr/local/bin or $HOME/.install-action/bin. +if [[ ! -d "${cargo_bin}" ]] || [[ "${host_os}" != "windows" ]] && [[ "$(type -P cargo || true)" != "${cargo_bin}/cargo${exe}" ]]; then cargo_bin=/usr/local/bin fi @@ -438,7 +447,7 @@ for tool in "${tools[@]}"; do if [[ ! -d "${bin_dir}" ]]; then mkdir -p "${bin_dir}" mkdir -p "${include_dir}" - echo "${bin_dir}" >>"${GITHUB_PATH}" + canonicalize_windows_path "${bin_dir}" >>"${GITHUB_PATH}" export PATH="${PATH}:${bin_dir}" fi if ! type -P unzip &>/dev/null; then @@ -454,9 +463,7 @@ for tool in "${tools[@]}"; do mv "bin/protoc${exe}" "${bin_dir}/" mkdir -p "${include_dir}/" cp -r include/. "${include_dir}/" - case "${host_os}" in - windows) bin_dir=$(sed <<<"${bin_dir}" 's/^\/c\//C:\\/') ;; - esac + bin_dir=$(canonicalize_windows_path "${bin_dir}") if [[ -z "${PROTOC:-}" ]]; then info "setting PROTOC environment variable" echo "PROTOC=${bin_dir}/protoc${exe}" >>"${GITHUB_ENV}" @@ -527,9 +534,21 @@ for tool in "${tools[@]}"; do info "${tool} installed at $(type -P "${tool}${exe}")" case "${tool}" in - cargo-udeps) x cargo udeps --help | head -1 ;; # cargo-udeps v0.1.30 does not support --version option - cargo-valgrind) x cargo valgrind --help ;; # cargo-valgrind v2.1.0 does not support --version option - cargo-*) x cargo "${tool#cargo-}" --version ;; + cargo-*) + if type -P cargo &>/dev/null; then + case "${tool}" in + cargo-udeps) x cargo udeps --help | head -1 ;; # cargo-udeps v0.1.30 does not support --version option + cargo-valgrind) x cargo valgrind --help ;; # cargo-valgrind v2.1.0 does not support --version option + *) x cargo "${tool#cargo-}" --version ;; + esac + else + case "${tool}" in + cargo-udeps) x "${tool}" udeps --help | head -1 ;; # cargo-udeps v0.1.30 does not support --version option + cargo-valgrind) x "${tool}" valgrind --help ;; # cargo-valgrind v2.1.0 does not support --version option + *) x "${tool}" "${tool#cargo-}" --version ;; + esac + fi + ;; *) x "${tool}" --version ;; esac echo