Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a more general way to config profile #578

Merged
merged 4 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: install

on:
pull_request:
branches:
- master
- release-*

jobs:
install:
name: Install
runs-on: ubuntu-latest
env:
working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
path: go/src/github.com/${{ github.repository }}
- name: Install And Check
working-directory: ${{env.working-directory}}
run: |
sh install.sh
source ~/.profile
which tiup || (echo "no tiup found" && exit 1)
local_install:
name: Local Install
runs-on: ubuntu-latest
env:
working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
path: go/src/github.com/${{ github.repository }}
- name: Build TiUP
working-directory: ${{env.working-directory}}
run: make build
- name: Setup TiUP
run: |
mkdir -p ~/.tiup/bin
curl https://tiup-mirrors.pingcap.com/root.json -o ~/.tiup/bin/root.json
- name: Clone Mirror
working-directory: ${{env.working-directory}}
run: ./bin/tiup mirror clone test-mirror
- name: Local Install And Check
working-directory: ${{env.working-directory}}/test-mirror
run: |
sh local_install.sh
source ~/.profile
which tiup || (echo "no tiup found" && exit 1)
lucklove marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ jobs:
working-directory: ${{env.working-directory}}
run: |
export PATH=$PATH:${{env.working-directory}}/bin/
echo $PATH
bash ${{env.working-directory}}/tests/tiup/${{matrix.cases}}.sh

- name: Upload cover files
Expand Down
19 changes: 12 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,18 @@ chmod 755 "$bin_dir/tiup"
bold=$(tput bold 2>/dev/null)
sgr0=$(tput sgr0 2>/dev/null)

echo "Detected shell: ${bold}$SHELL${sgr0}"
case $SHELL in
*bash*) PROFILE=$HOME/.bash_profile;;
*zsh*) PROFILE=$HOME/.zshrc;;
*) PROFILE=$HOME/.profile;;
esac

# Refrence: https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix
shell=$(echo $SHELL | awk 'BEGIN {FS="/";} { print $NF }')
lucklove marked this conversation as resolved.
Show resolved Hide resolved
echo "Detected shell: ${bold}$shell${sgr0}"
if [ -f "${HOME}/.${shell}_profile" ]; then
PROFILE=${HOME}/.${shell}_profile
elif [ -f "${HOME}/.${shell}_login" ]; then
PROFILE=${HOME}/.${shell}_login
elif [ -f "${HOME}/.${shell}rc" ]; then
PROFILE=${HOME}/.${shell}rc
else
PROFILE=${HOME}/.profile
fi
echo "Shell profile: ${bold}$PROFILE${sgr0}"

case :$PATH: in
Expand Down
19 changes: 12 additions & 7 deletions pkg/cluster/template/install/local_install.sh.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,18 @@ chmod 755 "$bin_dir/tiup"
bold=$(tput bold 2>/dev/null)
sgr0=$(tput sgr0 2>/dev/null)

echo "Detected shell: ${bold}$SHELL${sgr0}"
case $SHELL in
*bash*) PROFILE=$HOME/.bash_profile;;
*zsh*) PROFILE=$HOME/.zshrc;;
*) PROFILE=$HOME/.profile;;
esac

# Refrence: https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix
shell=$(echo $SHELL | awk 'BEGIN {FS="/";} { print $NF }')
echo "Detected shell: ${bold}$shell${sgr0}"
if [ -f "${HOME}/.${shell}_profile" ]; then
PROFILE=${HOME}/.${shell}_profile
elif [ -f "${HOME}/.${shell}_login" ]; then
PROFILE=${HOME}/.${shell}_login
elif [ -f "${HOME}/.${shell}rc" ]; then
PROFILE=${HOME}/.${shell}rc
else
PROFILE=${HOME}/.profile
fi
echo "Shell profile: ${bold}$PROFILE${sgr0}"

case :$PATH: in
Expand Down