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:
Dict Xiong 2022-08-28 20:51:44 +08:00 committed by GitHub
parent fa737d482f
commit 18dfca5f39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 40 deletions

View File

@ -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,45 +20,47 @@ 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}
run: |
echo $SHELL
antigen list
- name: check files
shell: /bin/zsh -ileo PIPE_FAIL {0}
run: |
l ~
l ~/.ssh
cat ~/.zshrc
antigen list
- name: check scripts and alias
- name: run tests
shell: /bin/zsh -ileo PIPE_FAIL {0}
run: source tools/test.zsh
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

View File

@ -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(){

View File

@ -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
View 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`