From 1169cd0cd50d3c61a86a9cf9d435963009954344 Mon Sep 17 00:00:00 2001 From: Aloxaf Date: Sun, 25 Feb 2024 18:58:28 +0800 Subject: [PATCH 1/3] ci: test different version of zsh --- .github/workflows/{ci.yaml => linux.yaml} | 16 +++----- .github/workflows/macos.yaml | 28 ++++++++++++++ .github/workflows/zsh.yaml | 45 +++++++++++++++++++++++ fzf-tab.zsh | 1 + lib/-ftb-build-module | 2 +- test/fzftab.ztst | 1 + 6 files changed, 82 insertions(+), 11 deletions(-) rename .github/workflows/{ci.yaml => linux.yaml} (58%) create mode 100644 .github/workflows/macos.yaml create mode 100644 .github/workflows/zsh.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/linux.yaml similarity index 58% rename from .github/workflows/ci.yaml rename to .github/workflows/linux.yaml index ae72c58..b6309f2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/linux.yaml @@ -1,4 +1,4 @@ -name: ci +name: test on linux on: push: @@ -10,29 +10,25 @@ on: jobs: test: - name: run test runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] steps: - name: checkout uses: actions/checkout@v1 with: fetch-depth: 1 - - name: install zsh (ubuntu) - if: matrix.os == 'ubuntu-latest' - run: sudo apt-get install zsh + - name: install zsh + run: sudo apt-get install -y zsh - - name: test completion (ubuntu) - if: matrix.os == 'ubuntu-latest' + - name: test completion run: cd test && zsh -f runtests.zsh fzftab.ztst - name: build binary module run: zsh -fc 'source ./fzf-tab.zsh && build-fzf-tab-module' - - name: test binary module (ubuntu) - if: matrix.os == 'ubuntu-latest' + - name: test binary module run: cd test && zsh -f runtests.zsh fzftab.ztst diff --git a/.github/workflows/macos.yaml b/.github/workflows/macos.yaml new file mode 100644 index 0000000..f76b8d4 --- /dev/null +++ b/.github/workflows/macos.yaml @@ -0,0 +1,28 @@ +name: test on macOS + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + runs-on: macos-latest + steps: + - name: checkout + uses: actions/checkout@v1 + with: + fetch-depth: 1 + + # FIXME: test on macOS + #- name: test completion + # run: cd test && zsh -f runtests.zsh fzftab.ztst + + - name: build binary module + run: zsh -fc 'source ./fzf-tab.zsh && build-fzf-tab-module' + + #- name: test binary module + # run: cd test && zsh -f runtests.zsh fzftab.ztst diff --git a/.github/workflows/zsh.yaml b/.github/workflows/zsh.yaml new file mode 100644 index 0000000..1358b27 --- /dev/null +++ b/.github/workflows/zsh.yaml @@ -0,0 +1,45 @@ +name: test on different zsh versions + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + # TODO: test fzf version? + zsh_version: + - 5.3.1 + - 5.4.2 + - 5.5.1 + - 5.6.2 + - 5.7.1 + - 5.8 + - 5.9 + container: + image: zshusers/zsh:${{ matrix.zsh_version }} + steps: + - name: checkout + uses: actions/checkout@v1 + with: + fetch-depth: 1 + + - name: install dependencies + run: apt update && apt-get install -y git build-essential autoconf + + - name: test completion + run: cd test && zsh -f runtests.zsh fzftab.ztst + + - name: build binary module + run: zsh -fc 'source ./fzf-tab.zsh && build-fzf-tab-module' + + - name: test binary module + run: cd test && zsh -f runtests.zsh fzftab.ztst + diff --git a/fzf-tab.zsh b/fzf-tab.zsh index 2eb4bc2..0761058 100644 --- a/fzf-tab.zsh +++ b/fzf-tab.zsh @@ -349,6 +349,7 @@ build-fzf-tab-module() { print -P "%F{green}%BThe module has been built successfully. Please restart zsh to apply it.%f%b" else print -P -u2 "%F{red}%BThe module building has failed. See the output above for details.%f%b" + return 1 fi } always { popd -q diff --git a/lib/-ftb-build-module b/lib/-ftb-build-module index 6f9f77e..9b62308 100644 --- a/lib/-ftb-build-module +++ b/lib/-ftb-build-module @@ -1,5 +1,5 @@ #!/hint/zsh -emulate -LR zsh -o extended_glob -o err_exit +emulate -LR zsh -o extended_glob -o err_return local zsh_version=${1:-${FZF_TAB_ZSH_SRC_VERSION:-$ZSH_VERSION}} diff --git a/test/fzftab.ztst b/test/fzftab.ztst index 98028f3..aa66dce 100644 --- a/test/fzftab.ztst +++ b/test/fzftab.ztst @@ -25,6 +25,7 @@ touch file1 && touch file2 touch dir1/file1 + # TODO: remove git from tests git init } else From ac5330b7968d192177b235e5ddec5ac5b83250e6 Mon Sep 17 00:00:00 2001 From: Aloxaf Date: Sun, 25 Feb 2024 21:58:17 +0800 Subject: [PATCH 2/3] ci: miss libncurses-dev --- .github/workflows/zsh.yaml | 2 +- test/fzftab.ztst | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/zsh.yaml b/.github/workflows/zsh.yaml index 1358b27..3a299e2 100644 --- a/.github/workflows/zsh.yaml +++ b/.github/workflows/zsh.yaml @@ -32,7 +32,7 @@ jobs: fetch-depth: 1 - name: install dependencies - run: apt update && apt-get install -y git build-essential autoconf + run: apt update && apt-get install -y git build-essential autoconf libncurses-dev - name: test completion run: cd test && zsh -f runtests.zsh fzftab.ztst diff --git a/test/fzftab.ztst b/test/fzftab.ztst index aa66dce..98028f3 100644 --- a/test/fzftab.ztst +++ b/test/fzftab.ztst @@ -25,7 +25,6 @@ touch file1 && touch file2 touch dir1/file1 - # TODO: remove git from tests git init } else From 2a268ad84de0864bd658602d6755d60982b2f247 Mon Sep 17 00:00:00 2001 From: Aloxaf Date: Sun, 25 Feb 2024 22:27:45 +0800 Subject: [PATCH 3/3] fix: compability with zsh 5.4.2 --- lib/-ftb-build-module | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/-ftb-build-module b/lib/-ftb-build-module index 9b62308..6be8b20 100644 --- a/lib/-ftb-build-module +++ b/lib/-ftb-build-module @@ -5,28 +5,24 @@ local zsh_version=${1:-${FZF_TAB_ZSH_SRC_VERSION:-$ZSH_VERSION}} # macos check local ret bundle nproc -if [[ $OSTYPE == darwin* ]]; then +[[ $OSTYPE == darwin* ]] && { [[ -n ${module_path[1]}/**/*.bundle(#qN) ]] && bundle=true nproc=$(sysctl -n hw.logicalcpu) -else +} || { nproc=$(nproc) -fi +} # clone zsh source code if not exists -if [[ ! -d ./zsh/$zsh_version ]]; then +[[ -d ./zsh/$zsh_version ]] || { git clone --depth=1 --branch zsh-$zsh_version https://github.com/zsh-users/zsh ./zsh/$zsh_version ln -s $PWD/src/fzftab.c ./zsh/$zsh_version/Src/Modules/ ln -s $PWD/src/fzftab.mdd ./zsh/$zsh_version/Src/Modules/ -fi +} # build zsh cd -q ./zsh/$zsh_version -if [[ ! -f ./configure ]]; then - ./Util/preconfig -fi -if [[ ! -f ./Makefile ]]; then - ./configure --disable-gdbm --disable-pcre --without-tcsetpgrp --prefix=/tmp/zsh-fzf-tab-module ${bundle:+DL_EXT=bundle} -fi +[[ -f ./configure ]] || ./Util/preconfig +[[ -f ./Makefile ]] || ./configure --disable-gdbm --disable-pcre --without-tcsetpgrp --prefix=/tmp/zsh-fzf-tab-module ${bundle:+DL_EXT=bundle} make -j$nproc # we only need aloxaf/fzftab.so