mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 09:27:04 +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: ~
|
||||
workflow_dispatch: ~
|
||||
jobs:
|
||||
test:
|
||||
name: test
|
||||
test-ubuntu:
|
||||
name: test on ubuntu
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y git python3 python3-pip zsh curl inetutils-ping
|
||||
sudo apt remove -y vim tmux
|
||||
sudo pip3 install requests
|
||||
|
||||
- name: checkout repo
|
||||
|
@ -21,8 +20,9 @@ jobs:
|
|||
run: |
|
||||
rev=`git rev-parse HEAD`
|
||||
pwd
|
||||
export DFS_NO_COMPILE=1 DFS_NO_UPDATE=1
|
||||
./install.sh
|
||||
git checkout $rev
|
||||
test `git rev-parse HEAD` = "$rev"
|
||||
|
||||
- name: antigen build
|
||||
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
||||
|
@ -30,36 +30,37 @@ jobs:
|
|||
echo $SHELL
|
||||
antigen list
|
||||
|
||||
- name: check files
|
||||
- name: run tests
|
||||
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
||||
run: |
|
||||
l ~
|
||||
l ~/.ssh
|
||||
cat ~/.zshrc
|
||||
run: source tools/test.zsh
|
||||
|
||||
- name: check scripts and alias
|
||||
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
||||
test-macos:
|
||||
name: test on macos
|
||||
runs-on: macos-12
|
||||
steps:
|
||||
- name: install dependencies
|
||||
run: |
|
||||
cd /
|
||||
dfs
|
||||
dfs cd
|
||||
brew update
|
||||
brew install git python3 zsh curl
|
||||
sudo pip3 install requests
|
||||
|
||||
- name: checkout repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: install dfs
|
||||
run: |
|
||||
rev=`git rev-parse HEAD`
|
||||
pwd
|
||||
dfs version
|
||||
dfs log 1
|
||||
l
|
||||
dogo
|
||||
tools/common.sh get_os_type
|
||||
tools/common.sh get_linux_dist
|
||||
bash -x tools/common.sh post_log 1 2 3
|
||||
export DFS_NO_COMPILE=1 DFS_NO_UPDATE=1
|
||||
./install.sh
|
||||
test `git rev-parse HEAD` = "$rev"
|
||||
|
||||
- name: check scripts and alias (no ret check)
|
||||
shell: /bin/zsh -il {0}
|
||||
run: |
|
||||
p114 -c 4
|
||||
return 0
|
||||
|
||||
- name: check update
|
||||
- name: antigen build
|
||||
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
||||
run: |
|
||||
dfs update
|
||||
dfs version
|
||||
echo $SHELL
|
||||
antigen list
|
||||
|
||||
- name: run tests
|
||||
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
||||
run: source tools/test.zsh
|
14
install.sh
14
install.sh
|
@ -93,7 +93,9 @@ install_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
|
||||
fmt_note "initializing tmux plugins ..."
|
||||
~/.tmux/plugins/tpm/bin/install_plugins
|
||||
if [[ -z "$DFS_NO_COMPILE" ]]; then
|
||||
~/.tmux/plugins/tpm/bin/install_plugins
|
||||
fi
|
||||
else
|
||||
fmt_warning "pls install g++,cmake,make and then init tmux plugins by <prefix + I> or ~/.tmux/plugins/tpm/bin/install_plugins"
|
||||
fi
|
||||
|
@ -106,7 +108,9 @@ install_vim_vundle(){
|
|||
fmt_note "installing vim vundle ..."
|
||||
git clone https://gitee.com/dictxiong/Vundle.vim "$VIM_VUNDLE"
|
||||
fmt_note "initializing vim plugins ..."
|
||||
vim +PluginInstall +qall
|
||||
if [[ -z "$DFS_NO_COMPILE" ]]; then
|
||||
vim +PluginInstall +qall
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -114,8 +118,10 @@ install_update(){
|
|||
fmt_note "installing update.sh ..."
|
||||
cp "${DOTFILES}/.update.sh" "${DOTFILES}/update.sh"
|
||||
chmod +x "${DOTFILES}/update.sh"
|
||||
fmt_note "running update.sh ..."
|
||||
${DOTFILES}/update.sh
|
||||
if [[ -z "$DFS_NO_UPDATE" ]]; then
|
||||
fmt_note "running update.sh ..."
|
||||
${DOTFILES}/update.sh
|
||||
fi
|
||||
}
|
||||
|
||||
uninstall_update(){
|
||||
|
|
|
@ -7,7 +7,7 @@ logging.basicConfig(level=logging.INFO, format="[%(filename)s:%(lineno)d][%(leve
|
|||
try:
|
||||
import requests
|
||||
except ImportError:
|
||||
logging.fatal("Please install requests module")
|
||||
logging.critical("Please install requests module")
|
||||
exit(1)
|
||||
|
||||
|
||||
|
@ -57,17 +57,17 @@ if __name__ == "__main__":
|
|||
content=content.strip()
|
||||
if not content:
|
||||
logging.error("empty log content")
|
||||
exit(1)
|
||||
exit(0)
|
||||
resp = post_log(url, hostname, uuid, content)
|
||||
if resp.status_code == 200:
|
||||
logging.info("200 ok")
|
||||
exit(0)
|
||||
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(f"hostname: {hostname}, uuid: {uuid}")
|
||||
exit(0)
|
||||
else:
|
||||
logging.error("unknown error ")
|
||||
logging.critical("unknown error ")
|
||||
logging.error(f"{resp.status_code}: {resp.text}")
|
||||
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