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
|
case "${platform}" in
|
||||||
msys_nt*) platform="pc-windows-msvc" ;;
|
msys_nt*) platform="pc-windows-msvc" ;;
|
||||||
cygwin_nt*) platform="pc-windows-msvc";;
|
cygwin_nt*) platform="pc-windows-msvc" ;;
|
||||||
# mingw is Git-Bash
|
# mingw is Git-Bash
|
||||||
mingw*) platform="pc-windows-msvc" ;;
|
mingw*) platform="pc-windows-msvc" ;;
|
||||||
# use the statically compiled musl bins on linux to avoid linking issues.
|
# use the statically compiled musl bins on linux to avoid linking issues.
|
||||||
@@ -257,7 +257,6 @@ detect_target() {
|
|||||||
printf '%s' "${target}"
|
printf '%s' "${target}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
confirm() {
|
confirm() {
|
||||||
if [ -z "${FORCE-}" ]; then
|
if [ -z "${FORCE-}" ]; then
|
||||||
printf "%s " "${MAGENTA}?${NO_COLOR} $* ${BOLD}[y/N]${NO_COLOR}"
|
printf "%s " "${MAGENTA}?${NO_COLOR} $* ${BOLD}[y/N]${NO_COLOR}"
|
||||||
@@ -305,28 +304,27 @@ check_bin_dir() {
|
|||||||
print_install() {
|
print_install() {
|
||||||
# if the shell does not fit the default case change the config file
|
# if the shell does not fit the default case change the config file
|
||||||
# and or the config cmd variable
|
# and or the config cmd variable
|
||||||
for s in "bash" "zsh" "ion" "tcsh" "xonsh" "fish"
|
for s in "bash" "zsh" "ion" "tcsh" "xonsh" "fish"; do
|
||||||
do
|
|
||||||
# shellcheck disable=SC2088
|
# shellcheck disable=SC2088
|
||||||
# we don't want these '~' expanding
|
# we don't want these '~' expanding
|
||||||
config_file="~/.${s}rc"
|
config_file="~/.${s}rc"
|
||||||
config_cmd="eval \"\$(starship init ${s})\""
|
config_cmd="eval \"\$(starship init ${s})\""
|
||||||
|
|
||||||
case ${s} in
|
case ${s} in
|
||||||
ion )
|
ion)
|
||||||
# shellcheck disable=SC2088
|
# shellcheck disable=SC2088
|
||||||
config_file="~/.config/ion/initrc"
|
config_file="~/.config/ion/initrc"
|
||||||
config_cmd="eval \$(starship init ${s})"
|
config_cmd="eval \$(starship init ${s})"
|
||||||
;;
|
;;
|
||||||
fish )
|
fish)
|
||||||
# shellcheck disable=SC2088
|
# shellcheck disable=SC2088
|
||||||
config_file="~/.config/fish/config.fish"
|
config_file="~/.config/fish/config.fish"
|
||||||
config_cmd="starship init fish | source"
|
config_cmd="starship init fish | source"
|
||||||
;;
|
;;
|
||||||
tcsh )
|
tcsh)
|
||||||
config_cmd="eval \`starship init ${s}\`"
|
config_cmd="eval \`starship init ${s}\`"
|
||||||
;;
|
;;
|
||||||
xonsh )
|
xonsh)
|
||||||
config_cmd="execx(\$(starship init xonsh))"
|
config_cmd="execx(\$(starship init xonsh))"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -337,18 +335,17 @@ print_install() {
|
|||||||
"${config_cmd}"
|
"${config_cmd}"
|
||||||
done
|
done
|
||||||
|
|
||||||
for s in "elvish" "nushell"
|
for s in "elvish" "nushell"; do
|
||||||
do
|
|
||||||
|
|
||||||
warning="${BOLD}Warning${NO_COLOR}"
|
warning="${BOLD}Warning${NO_COLOR}"
|
||||||
case ${s} in
|
case ${s} in
|
||||||
elvish )
|
elvish)
|
||||||
# shellcheck disable=SC2088
|
# shellcheck disable=SC2088
|
||||||
config_file="~/.config/elvish/rc.elv"
|
config_file="~/.config/elvish/rc.elv"
|
||||||
config_cmd="eval (starship init elvish)"
|
config_cmd="eval (starship init elvish)"
|
||||||
warning="${warning} Only elvish v0.17 or higher is supported."
|
warning="${warning} Only elvish v0.17 or higher is supported."
|
||||||
;;
|
;;
|
||||||
nushell )
|
nushell)
|
||||||
# shellcheck disable=SC2088
|
# 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_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\")
|
config_cmd="mkdir (\$nu.data-dir | path join \"vendor/autoload\")
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ starship_version() {
|
|||||||
if [ "$STARSHIP_VERSION" != "" ]; then
|
if [ "$STARSHIP_VERSION" != "" ]; then
|
||||||
echo "$STARSHIP_VERSION" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+'
|
echo "$STARSHIP_VERSION" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+'
|
||||||
elif "$starship_program_file" -V >/dev/null 2>&1; then
|
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
|
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]+'
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user