mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 11:27:00 +08:00
ci: better structure (#13)
* struct ci; staged * seems good * ci try macos * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug
This commit is contained in:
parent
fa737d482f
commit
18dfca5f39
61
.github/workflows/test.yml
vendored
61
.github/workflows/test.yml
vendored
|
@ -3,15 +3,14 @@ on:
|
||||||
push: ~
|
push: ~
|
||||||
workflow_dispatch: ~
|
workflow_dispatch: ~
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test-ubuntu:
|
||||||
name: test
|
name: test on ubuntu
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install -y git python3 python3-pip zsh curl inetutils-ping
|
sudo apt install -y git python3 python3-pip zsh curl inetutils-ping
|
||||||
sudo apt remove -y vim tmux
|
|
||||||
sudo pip3 install requests
|
sudo pip3 install requests
|
||||||
|
|
||||||
- name: checkout repo
|
- name: checkout repo
|
||||||
|
@ -21,8 +20,9 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
rev=`git rev-parse HEAD`
|
rev=`git rev-parse HEAD`
|
||||||
pwd
|
pwd
|
||||||
|
export DFS_NO_COMPILE=1 DFS_NO_UPDATE=1
|
||||||
./install.sh
|
./install.sh
|
||||||
git checkout $rev
|
test `git rev-parse HEAD` = "$rev"
|
||||||
|
|
||||||
- name: antigen build
|
- name: antigen build
|
||||||
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
||||||
|
@ -30,36 +30,37 @@ jobs:
|
||||||
echo $SHELL
|
echo $SHELL
|
||||||
antigen list
|
antigen list
|
||||||
|
|
||||||
- name: check files
|
- name: run tests
|
||||||
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
||||||
run: |
|
run: source tools/test.zsh
|
||||||
l ~
|
|
||||||
l ~/.ssh
|
|
||||||
cat ~/.zshrc
|
|
||||||
|
|
||||||
- name: check scripts and alias
|
test-macos:
|
||||||
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
name: test on macos
|
||||||
|
runs-on: macos-12
|
||||||
|
steps:
|
||||||
|
- name: install dependencies
|
||||||
run: |
|
run: |
|
||||||
cd /
|
brew update
|
||||||
dfs
|
brew install git python3 zsh curl
|
||||||
dfs cd
|
sudo pip3 install requests
|
||||||
|
|
||||||
|
- name: checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: install dfs
|
||||||
|
run: |
|
||||||
|
rev=`git rev-parse HEAD`
|
||||||
pwd
|
pwd
|
||||||
dfs version
|
export DFS_NO_COMPILE=1 DFS_NO_UPDATE=1
|
||||||
dfs log 1
|
./install.sh
|
||||||
l
|
test `git rev-parse HEAD` = "$rev"
|
||||||
dogo
|
|
||||||
tools/common.sh get_os_type
|
|
||||||
tools/common.sh get_linux_dist
|
|
||||||
bash -x tools/common.sh post_log 1 2 3
|
|
||||||
|
|
||||||
- name: check scripts and alias (no ret check)
|
- name: antigen build
|
||||||
shell: /bin/zsh -il {0}
|
|
||||||
run: |
|
|
||||||
p114 -c 4
|
|
||||||
return 0
|
|
||||||
|
|
||||||
- name: check update
|
|
||||||
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
||||||
run: |
|
run: |
|
||||||
dfs update
|
echo $SHELL
|
||||||
dfs version
|
antigen list
|
||||||
|
|
||||||
|
- name: run tests
|
||||||
|
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
||||||
|
run: source tools/test.zsh
|
|
@ -93,7 +93,9 @@ install_tmux_tpm(){
|
||||||
git clone https://gitee.com/dictxiong/tpm "$TMUX_TPM"
|
git clone https://gitee.com/dictxiong/tpm "$TMUX_TPM"
|
||||||
if [[ -x $(command -v g++) && -x $(command -v cmake) && -x $(command -v make) ]]; then
|
if [[ -x $(command -v g++) && -x $(command -v cmake) && -x $(command -v make) ]]; then
|
||||||
fmt_note "initializing tmux plugins ..."
|
fmt_note "initializing tmux plugins ..."
|
||||||
|
if [[ -z "$DFS_NO_COMPILE" ]]; then
|
||||||
~/.tmux/plugins/tpm/bin/install_plugins
|
~/.tmux/plugins/tpm/bin/install_plugins
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
fmt_warning "pls install g++,cmake,make and then init tmux plugins by <prefix + I> or ~/.tmux/plugins/tpm/bin/install_plugins"
|
fmt_warning "pls install g++,cmake,make and then init tmux plugins by <prefix + I> or ~/.tmux/plugins/tpm/bin/install_plugins"
|
||||||
fi
|
fi
|
||||||
|
@ -106,16 +108,20 @@ install_vim_vundle(){
|
||||||
fmt_note "installing vim vundle ..."
|
fmt_note "installing vim vundle ..."
|
||||||
git clone https://gitee.com/dictxiong/Vundle.vim "$VIM_VUNDLE"
|
git clone https://gitee.com/dictxiong/Vundle.vim "$VIM_VUNDLE"
|
||||||
fmt_note "initializing vim plugins ..."
|
fmt_note "initializing vim plugins ..."
|
||||||
|
if [[ -z "$DFS_NO_COMPILE" ]]; then
|
||||||
vim +PluginInstall +qall
|
vim +PluginInstall +qall
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
install_update(){
|
install_update(){
|
||||||
fmt_note "installing update.sh ..."
|
fmt_note "installing update.sh ..."
|
||||||
cp "${DOTFILES}/.update.sh" "${DOTFILES}/update.sh"
|
cp "${DOTFILES}/.update.sh" "${DOTFILES}/update.sh"
|
||||||
chmod +x "${DOTFILES}/update.sh"
|
chmod +x "${DOTFILES}/update.sh"
|
||||||
|
if [[ -z "$DFS_NO_UPDATE" ]]; then
|
||||||
fmt_note "running update.sh ..."
|
fmt_note "running update.sh ..."
|
||||||
${DOTFILES}/update.sh
|
${DOTFILES}/update.sh
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
uninstall_update(){
|
uninstall_update(){
|
||||||
|
|
|
@ -7,7 +7,7 @@ logging.basicConfig(level=logging.INFO, format="[%(filename)s:%(lineno)d][%(leve
|
||||||
try:
|
try:
|
||||||
import requests
|
import requests
|
||||||
except ImportError:
|
except ImportError:
|
||||||
logging.fatal("Please install requests module")
|
logging.critical("Please install requests module")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,17 +57,17 @@ if __name__ == "__main__":
|
||||||
content=content.strip()
|
content=content.strip()
|
||||||
if not content:
|
if not content:
|
||||||
logging.error("empty log content")
|
logging.error("empty log content")
|
||||||
exit(1)
|
exit(0)
|
||||||
resp = post_log(url, hostname, uuid, content)
|
resp = post_log(url, hostname, uuid, content)
|
||||||
if resp.status_code == 200:
|
if resp.status_code == 200:
|
||||||
logging.info("200 ok")
|
logging.info("200 ok")
|
||||||
exit(0)
|
exit(0)
|
||||||
elif resp.status_code == 403:
|
elif resp.status_code == 403:
|
||||||
logging.warning("403 forbidden")
|
logging.error("403 forbidden")
|
||||||
logging.info("you may need to register your hostname and uuid")
|
logging.info("you may need to register your hostname and uuid")
|
||||||
logging.info(f"hostname: {hostname}, uuid: {uuid}")
|
logging.info(f"hostname: {hostname}, uuid: {uuid}")
|
||||||
exit(0)
|
exit(0)
|
||||||
else:
|
else:
|
||||||
logging.error("unknown error ")
|
logging.critical("unknown error ")
|
||||||
logging.error(f"{resp.status_code}: {resp.text}")
|
logging.error(f"{resp.status_code}: {resp.text}")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
27
tools/test.zsh
Normal file
27
tools/test.zsh
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/false "This script should be sourced in a shell, not executed directly"
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
# check files
|
||||||
|
cd /
|
||||||
|
dfs cd
|
||||||
|
pwd
|
||||||
|
test -f .zshrc2
|
||||||
|
diff -q ./.ssh/authorized_keys2 ~/.ssh/authorized_keys2
|
||||||
|
grep -q ".zshrc2" ~/.zshrc
|
||||||
|
|
||||||
|
# check scripts and functions
|
||||||
|
dfs version
|
||||||
|
dfs log 1
|
||||||
|
l
|
||||||
|
dogo
|
||||||
|
tools/common.sh get_os_type
|
||||||
|
tools/common.sh get_linux_dist
|
||||||
|
|
||||||
|
# check alias
|
||||||
|
alias p114 > /dev/null
|
||||||
|
|
||||||
|
# check update
|
||||||
|
dfs update
|
||||||
|
dfs version
|
||||||
|
test `git rev-parse HEAD` = `curl -fsSL https://api.beardic.cn/get-var/dfs-commit-id`
|
Loading…
Reference in New Issue
Block a user