mirror of
https://github.com/starship/starship.git
synced 2026-06-24 02:01:36 +07:00
ci: add install script workflow (#7159)
* ci: add install script workflow Add GitHub Actions workflow to test install.sh script. This prevents regressions like the one reported in issue #7133 where changes to the install script broke the recommended installation method. The workflow includes: - shellcheck for script linting (temporarily excludes SC3045) - Integration test using curl piped to sh as documented on starship.rs Signed-off-by: cappyzawa <cappyzawa@gmail.com> * fixup! ci: add install script workflow Signed-off-by: cappyzawa <cappyzawa@gmail.com> * fixup! ci: add install script workflow Signed-off-by: cappyzawa <cappyzawa@gmail.com> * ci: add shfmt check and format install scripts Add shfmt job to install-script workflow for consistent shell script formatting. Apply shfmt to all scripts under install/ directory. Signed-off-by: cappyzawa <cappyzawa@gmail.com> --------- Signed-off-by: cappyzawa <cappyzawa@gmail.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
name: Install Script
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- "install/**"
|
||||
pull_request:
|
||||
paths:
|
||||
- "install/**"
|
||||
|
||||
jobs:
|
||||
shellcheck:
|
||||
name: Shellcheck [Linter]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup | Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Lint | Run shellcheck
|
||||
run: shellcheck --severity=warning install/**/*.sh
|
||||
|
||||
shfmt:
|
||||
name: Shfmt [Formatter]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup | Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup | Install shfmt
|
||||
run: |
|
||||
curl -sS https://webi.sh/shfmt | sh
|
||||
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Format | Check shfmt
|
||||
run: shfmt -d install/**/*.sh
|
||||
|
||||
test_install_script:
|
||||
name: Test Install Script
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Setup | Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Test | Piped execution with curl
|
||||
run: |
|
||||
# Test the installation method described at https://starship.rs/
|
||||
mkdir -p "$HOME/.test-install"
|
||||
curl -sS "file://$(pwd)/install/install.sh" | sh -s -- --yes --bin-dir "$HOME/.test-install"
|
||||
"$HOME/.test-install/starship" --version
|
||||
+9
-12
@@ -209,7 +209,7 @@ detect_platform() {
|
||||
|
||||
case "${platform}" in
|
||||
msys_nt*) platform="pc-windows-msvc" ;;
|
||||
cygwin_nt*) platform="pc-windows-msvc";;
|
||||
cygwin_nt*) platform="pc-windows-msvc" ;;
|
||||
# mingw is Git-Bash
|
||||
mingw*) platform="pc-windows-msvc" ;;
|
||||
# use the statically compiled musl bins on linux to avoid linking issues.
|
||||
@@ -257,7 +257,6 @@ detect_target() {
|
||||
printf '%s' "${target}"
|
||||
}
|
||||
|
||||
|
||||
confirm() {
|
||||
if [ -z "${FORCE-}" ]; then
|
||||
printf "%s " "${MAGENTA}?${NO_COLOR} $* ${BOLD}[y/N]${NO_COLOR}"
|
||||
@@ -305,28 +304,27 @@ check_bin_dir() {
|
||||
print_install() {
|
||||
# if the shell does not fit the default case change the config file
|
||||
# and or the config cmd variable
|
||||
for s in "bash" "zsh" "ion" "tcsh" "xonsh" "fish"
|
||||
do
|
||||
for s in "bash" "zsh" "ion" "tcsh" "xonsh" "fish"; do
|
||||
# shellcheck disable=SC2088
|
||||
# we don't want these '~' expanding
|
||||
config_file="~/.${s}rc"
|
||||
config_cmd="eval \"\$(starship init ${s})\""
|
||||
|
||||
case ${s} in
|
||||
ion )
|
||||
ion)
|
||||
# shellcheck disable=SC2088
|
||||
config_file="~/.config/ion/initrc"
|
||||
config_cmd="eval \$(starship init ${s})"
|
||||
;;
|
||||
fish )
|
||||
fish)
|
||||
# shellcheck disable=SC2088
|
||||
config_file="~/.config/fish/config.fish"
|
||||
config_cmd="starship init fish | source"
|
||||
;;
|
||||
tcsh )
|
||||
tcsh)
|
||||
config_cmd="eval \`starship init ${s}\`"
|
||||
;;
|
||||
xonsh )
|
||||
xonsh)
|
||||
config_cmd="execx(\$(starship init xonsh))"
|
||||
;;
|
||||
esac
|
||||
@@ -337,18 +335,17 @@ print_install() {
|
||||
"${config_cmd}"
|
||||
done
|
||||
|
||||
for s in "elvish" "nushell"
|
||||
do
|
||||
for s in "elvish" "nushell"; do
|
||||
|
||||
warning="${BOLD}Warning${NO_COLOR}"
|
||||
case ${s} in
|
||||
elvish )
|
||||
elvish)
|
||||
# shellcheck disable=SC2088
|
||||
config_file="~/.config/elvish/rc.elv"
|
||||
config_cmd="eval (starship init elvish)"
|
||||
warning="${warning} Only elvish v0.17 or higher is supported."
|
||||
;;
|
||||
nushell )
|
||||
nushell)
|
||||
# shellcheck disable=SC2088
|
||||
config_file="${BOLD}your nu config file${NO_COLOR} (find it by running ${BOLD}\$nu.config-path${NO_COLOR} in Nushell)"
|
||||
config_cmd="mkdir (\$nu.data-dir | path join \"vendor/autoload\")
|
||||
|
||||
@@ -21,10 +21,10 @@ starship_version() {
|
||||
if [ "$STARSHIP_VERSION" != "" ]; then
|
||||
echo "$STARSHIP_VERSION" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+'
|
||||
elif "$starship_program_file" -V >/dev/null 2>&1; then
|
||||
"$starship_program_file" -V 2> /dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+'
|
||||
"$starship_program_file" -V 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+'
|
||||
else
|
||||
pushd "$(git rev-parse --show-toplevel)" &> /dev/null || true
|
||||
pushd "$(git rev-parse --show-toplevel)" &>/dev/null || true
|
||||
grep '^version = \"\(.*\)\"' Cargo.toml | head -n 1 | cut -f 2 -d '"' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+'
|
||||
popd &> /dev/null || true
|
||||
popd &>/dev/null || true
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user