mirror of
https://oauth2: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@github.com/m1ngsama/chopsticks.git
synced 2026-05-10 19:10:59 +08:00
150 lines
5.2 KiB
YAML
150 lines
5.2 KiB
YAML
name: test
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
startup:
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest]
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Vim
|
|
run: |
|
|
if [ "$(uname)" = "Darwin" ]; then
|
|
brew install vim
|
|
else
|
|
sudo apt-get update && sudo apt-get install -y vim
|
|
fi
|
|
|
|
- name: Install vim-plug
|
|
run: |
|
|
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
|
|
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
|
|
|
- name: Symlink config
|
|
run: |
|
|
ln -sf "$PWD" ~/.vim/chopsticks-src
|
|
ln -sf "$PWD/.vimrc" ~/.vimrc
|
|
mkdir -p ~/.vim/modules
|
|
cp modules/*.vim ~/.vim/modules/
|
|
|
|
- name: Install plugins
|
|
run: |
|
|
set +e
|
|
vim -i NONE -es -u .vimrc -N -c 'PlugInstall --sync' -c 'qa!' 2>&1
|
|
plug_status=$?
|
|
set -e
|
|
if [ "$plug_status" -ne 0 ]; then
|
|
echo "PlugInstall exited with $plug_status; validating plugin directories"
|
|
fi
|
|
for plugin in fzf fzf.vim vim-fugitive vim-gitgutter ale vim-lsp vim-lsp-settings asyncomplete.vim asyncomplete-lsp.vim vim-markdown; do
|
|
test -d "$HOME/.vim/plugged/$plugin" || {
|
|
echo "FAIL: missing plugin $plugin"
|
|
exit 1
|
|
}
|
|
done
|
|
|
|
- name: Test startup
|
|
run: |
|
|
vim -u .vimrc -i NONE -es -N -c 'qa!' 2>&1
|
|
echo "Vim exited cleanly"
|
|
|
|
- name: Verify modules load
|
|
run: |
|
|
vim -u .vimrc -i NONE -es -N \
|
|
-c 'redir! > /tmp/test.txt' \
|
|
-c 'silent echo len(g:plugs)' \
|
|
-c 'redir END' \
|
|
-c 'qa!' 2>/dev/null
|
|
PLUGS=$(cat /tmp/test.txt | tr -d '[:space:]')
|
|
echo "Plugins registered: $PLUGS"
|
|
if [ "$PLUGS" -lt 20 ]; then
|
|
echo "FAIL: expected 20+ plugins, got $PLUGS"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Verify path-safe module loading
|
|
run: |
|
|
mkdir -p "/tmp/chopsticks path/modules"
|
|
cp .vimrc "/tmp/chopsticks path/.vimrc"
|
|
cp modules/*.vim "/tmp/chopsticks path/modules/"
|
|
vim -u "/tmp/chopsticks path/.vimrc" -i NONE -es -N -c 'qa!' 2>&1
|
|
|
|
- name: Verify minimal profile
|
|
run: |
|
|
vim -u NONE -i NONE -es -N \
|
|
-c 'let g:chopsticks_profile = "minimal"' \
|
|
-c 'source .vimrc' \
|
|
-c 'if has_key(g:plugs, "ale") || has_key(g:plugs, "vim-lsp") || has_key(g:plugs, "vim-lsp-settings") || has_key(g:plugs, "asyncomplete.vim") | cquit | endif' \
|
|
-c 'qa!' 2>&1
|
|
|
|
- name: Verify local config hook
|
|
run: |
|
|
mkdir -p /tmp/chopsticks-ci
|
|
printf "%s\n" "let g:chopsticks_profile = 'minimal'" > /tmp/chopsticks-ci/local.vim
|
|
vim -u NONE -i NONE -es -N \
|
|
-c 'let g:chopsticks_local_config = "/tmp/chopsticks-ci/local.vim"' \
|
|
-c 'source .vimrc' \
|
|
-c 'if g:chopsticks_profile !=# "minimal" || has_key(g:plugs, "ale") || has_key(g:plugs, "vim-lsp") | cquit | endif' \
|
|
-c 'qa!' 2>&1
|
|
|
|
- name: Verify profile-aware cheat sheet
|
|
run: |
|
|
vim -u NONE -i NONE -es -N \
|
|
-c 'let g:chopsticks_profile = "minimal"' \
|
|
-c 'source .vimrc' \
|
|
-c 'normal ,?' \
|
|
-c 'redir! > /tmp/chopsticks-cheat.txt' \
|
|
-c 'silent %print' \
|
|
-c 'redir END' \
|
|
-c 'qa!' 2>&1
|
|
if grep -Eq 'definition|LspInstallServer|ALE errors|undo tree|markdown preview' /tmp/chopsticks-cheat.txt; then
|
|
cat /tmp/chopsticks-cheat.txt
|
|
exit 1
|
|
fi
|
|
grep -q ',cr run file' /tmp/chopsticks-cheat.txt
|
|
|
|
- name: Verify Markdown quiet defaults
|
|
run: |
|
|
vim -u .vimrc -i NONE -es -N README.md \
|
|
-c 'set filetype=markdown' \
|
|
-c 'if &l:spell || &l:conceallevel != 0 || &l:signcolumn !=# "no" || exists("g:lsp_settings_filetype_markdown") | cquit | endif' \
|
|
-c 'qa!' 2>&1
|
|
|
|
- name: Verify ergonomic defaults
|
|
run: |
|
|
vim -u .vimrc -i NONE -es -N \
|
|
-c 'if maparg("s", "n") !=# "" | cquit | endif' \
|
|
-c 'if maparg(",w", "n") =~# "!" | cquit | endif' \
|
|
-c 'if !&swapfile || !&writebackup || &directory !~# "\.vim/.swap" | cquit | endif' \
|
|
-c 'qa!' 2>&1
|
|
|
|
- name: Measure startup time
|
|
run: |
|
|
vim -u .vimrc -i NONE --startuptime /tmp/startup.log -es -N -c 'qa!' 2>/dev/null
|
|
tail -1 /tmp/startup.log
|
|
STARTUP_MS=$(tail -1 /tmp/startup.log | awk '{print $1}')
|
|
awk -v ms="$STARTUP_MS" 'BEGIN { if (ms > 150) exit 1 }'
|
|
|
|
shellcheck:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Shellcheck install.sh
|
|
run: shellcheck install.sh get.sh
|
|
|
|
docs:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install markdownlint
|
|
run: npm install -g markdownlint-cli
|
|
- name: Lint Markdown
|
|
run: markdownlint README.md QUICKSTART.md CONTRIBUTING.md CHANGELOG.md
|