Refactor workflow rust: Extract test into script

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-06-11 18:20:58 +10:00
parent 9bf1ce3000
commit 5302240829
No known key found for this signature in database
GPG key ID: 591C0B03040416D6
2 changed files with 23 additions and 10 deletions

View file

@ -98,16 +98,7 @@ jobs:
- name: Test (Unix) - name: Test (Unix)
if: ${{ matrix.test && matrix.os != 'windows-latest' }} if: ${{ matrix.test && matrix.os != 'windows-latest' }}
run: | run: ./ci-scripts/run_tests_unix.sh ${{ matrix.output }}
set -euxo pipefail
for bin in $bins; do ./${{ matrix.output }} binstall --log-level debug --no-confirm $bin; done
for bin in $test_bins; do $HOME/.cargo/bin/$bin --version; done
cargo binstall --help >/dev/null
./${{ matrix.output }} binstall --log-level debug --manifest-path . --no-confirm cargo-binstall
cargo binstall --help >/dev/null
env:
bins: cargo-deb cargo-llvm-cov cargo-binstall
test_bins: cargo-deb cargo-llvm-cov
- name: Test (Windows) - name: Test (Windows)
if: ${{ matrix.os == 'windows-latest' }} if: ${{ matrix.os == 'windows-latest' }}

22
ci-scripts/run_tests_unix.sh Executable file
View file

@ -0,0 +1,22 @@
#!/bin/bash
set -euxo pipefail
bins="cargo-deb cargo-llvm-cov cargo-binstall"
test_bins="cargo-deb cargo-llvm-cov"
# Install binaries using cargo-binstall
for bin in $bins; do
"./$1" binstall --log-level debug --no-confirm "$bin"
done
# Test that the installed binaries can be run
for bin in $test_bins; do
"$HOME/.cargo/bin/$bin" --version
done
cargo binstall --help >/dev/null
# Install binaries using `--manifest-path`
"./$1" binstall --log-level debug --manifest-path . --no-confirm cargo-binstall
# Test that the installed binaries can be run
cargo binstall --help >/dev/null