From 5f7e200c8f9a858489575e999dc2db4bb14933b1 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 27 Dec 2022 20:23:24 +1030 Subject: [PATCH 01/60] build and release on tag or mainline --- .github/actions/compile-unix/action.yml | 31 +++++++ .github/actions/compile-windows/action.yml | 22 +++++ .github/actions/nvim-unix-test/action.yml | 51 +++++++++++ .github/actions/prepare-artifacts/action.yml | 44 +++++++++ .github/actions/release-binaries/action.yml | 86 ++++++++++++++++++ .github/actions/test-unix/action.yml | 26 ++++++ .github/workflows/ci.yml | 71 ++++----------- .github/workflows/lint.yml | 11 ++- .github/workflows/release.yml | 96 ++++++++++++++++++++ 9 files changed, 384 insertions(+), 54 deletions(-) create mode 100644 .github/actions/compile-unix/action.yml create mode 100644 .github/actions/compile-windows/action.yml create mode 100644 .github/actions/nvim-unix-test/action.yml create mode 100644 .github/actions/prepare-artifacts/action.yml create mode 100644 .github/actions/release-binaries/action.yml create mode 100644 .github/actions/test-unix/action.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/actions/compile-unix/action.yml b/.github/actions/compile-unix/action.yml new file mode 100644 index 0000000..89e3e82 --- /dev/null +++ b/.github/actions/compile-unix/action.yml @@ -0,0 +1,31 @@ +--- +name: Compile Unix Library + +description: | + Prepare and compile unix builds + +inputs: + compiler: + required: true + description: Compiler to use + +runs: + using: composite + steps: + + - name: Prepare + env: + CC: ${{ inputs.compiler }} + shell: bash + run: | + cc --version + git clone https://github.com/Conni2461/examiner + cd examiner + make && sudo make install + + - name: Build + env: + CC: ${{ inputs.compiler }} + LD_LIBRARY_PATH: /usr/lib:/usr/local/lib + shell: bash + run: make diff --git a/.github/actions/compile-windows/action.yml b/.github/actions/compile-windows/action.yml new file mode 100644 index 0000000..556e3ac --- /dev/null +++ b/.github/actions/compile-windows/action.yml @@ -0,0 +1,22 @@ +--- +name: Compile windows library + +description: | + Prepare and compile a windows build + +runs: + + using: composite + + steps: + - uses: lukka/get-cmake@latest + + - name: Build + # powershell 7 is part of the 2019 toolset: + # https://github.com/actions/runner-images/blob/win19/20221214.4/images/win/Windows2019-Readme.md + shell: pwsh + run: | + cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release + cmake --build build --config Release + cmake --install build --prefix build + diff --git a/.github/actions/nvim-unix-test/action.yml b/.github/actions/nvim-unix-test/action.yml new file mode 100644 index 0000000..a5e3e7c --- /dev/null +++ b/.github/actions/nvim-unix-test/action.yml @@ -0,0 +1,51 @@ +--- +name: Test Unix Library + +description: | + Run some neovim tests + +inputs: + os: + required: true + description: OS being tested + url: + required: true + description: OS being tested + +runs: + using: composite + steps: + + - name: create cache key + shell: bash + run: date +%F > todays-date + + - name: Restore cache for today's nightly. + uses: actions/cache@v2 + with: + path: _neovim + key: ${{ inputs.os }}-${{ hashFiles('todays-date') }} + + - name: Prepare + shell: bash + run: | + test -d _neovim || { + mkdir -p _neovim + curl -sL ${{ inputs.url }} | tar xzf - --strip-components=1 -C "${PWD}/_neovim" + } + mkdir -p ~/.local/share/nvim/site/pack/vendor/start + git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim + ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start + + - name: Build + shell: bash + run: make + + - name: Tests + shell: bash + run: | + export PATH="${PWD}/_neovim/bin:${PATH}" + export VIM="${PWD}/_neovim/share/nvim/runtime" + nvim --version + make ntest + diff --git a/.github/actions/prepare-artifacts/action.yml b/.github/actions/prepare-artifacts/action.yml new file mode 100644 index 0000000..d86cffc --- /dev/null +++ b/.github/actions/prepare-artifacts/action.yml @@ -0,0 +1,44 @@ +--- +name: Prepare artifacts + +description: | + Downloads all prior artifacts into a directory. + + each artifact will be in its own directory named after the + job that uploaded it. + +outputs: + staging_area: + description: Area in which artifacts from prior jobs are collated + value: ${{ steps.directories.outputs.staging_area }} + +runs: + using: composite + steps: + + - name: Prepare Staging Area + shell: bash + id: directories + run: | + echo "staging_area=$(mktemp -d)" >> $GITHUB_OUTPUT + echo "artifacts=$(mktemp -d)" >> $GITHUB_OUTPUT + + - name: Download artifact + uses: actions/download-artifact@v2 + with: + path: ${{ steps.directories.outputs.artifacts }} + + - name: Prepare Release + env: + STAGING: ${{ steps.directories.outputs.staging_area }} + ARTIFACTS: ${{ steps.directories.outputs.artifacts }} + shell: bash + run: | + for file in ${ARTIFACTS}/**/*; do + FILENAME=$(basename $file) + PLATFORM=$(basename $(dirname $file)) + cp $file "${STAGING}/${PLATFORM}-${FILENAME}" + done + + ls -al ${STAGING}/* + diff --git a/.github/actions/release-binaries/action.yml b/.github/actions/release-binaries/action.yml new file mode 100644 index 0000000..d2400f3 --- /dev/null +++ b/.github/actions/release-binaries/action.yml @@ -0,0 +1,86 @@ +--- +name: Create binary release + +description: | + Takes artifacts in a source directory and creates a release + +inputs: + + source: + required: true + description: source directory + + is_development_release: + description: Is this a dev release? + default: 'true' + + is_production_release: + description: Is this a prod release? + default: 'false' + + development_title: + description: Title of the release when it is a development release + required: true + + development_tag: + description: Name of the tag when it is a development release + required: true + + production_title: + description: Title of the release when it is a production release + required: true + + production_tag: + description: Name of the tag when it is a production release + required: true + +runs: + using: composite + + steps: + + # Development Release + # + # If workflow runs because commits are pushd to the mainline + # branch, then it's assumed to be a development release. + # + # There's only ever one "development" release, whatever is the latest + # changes to `main`. + # + # For version release, see below "Production Release" + # + - uses: ncipollo/release-action@v1 + name: Release Development + if: ${{ inputs.is_development_release == 'true' }} + with: + name: ${{ inputs.development_title }} + tag: ${{ inputs.development_tag }} + omitBody: true + omitBodyDuringUpdate: false + allowUpdates: true + makeLatest: false + prerelease: true + removeArtifacts: true + replacesArtifacts: true + artifacts: ${{ inputs.source }}/* + commit: ${{ github.sha }} + + + # Production Release + # + # If the workflow runs because a tag was pushed, then this is considered + # a production release. + # + - uses: ncipollo/release-action@v1 + name: Release Tag + if: ${{ inputs.is_production_release == 'true' }} + with: + name: ${{ inputs.production_title }} + tag: ${{ inputs.production_tag }} + omitBody: true + allowUpdates: true + makeLatest: true + removeArtifacts: true + replacesArtifacts: true + artifacts: ${{ inputs.source }}/* + commit: ${{ github.sha }} diff --git a/.github/actions/test-unix/action.yml b/.github/actions/test-unix/action.yml new file mode 100644 index 0000000..fb5b5f8 --- /dev/null +++ b/.github/actions/test-unix/action.yml @@ -0,0 +1,26 @@ +--- +name: Test unix library + +description: | + Compile and test a unix build + +inputs: + compiler: + required: true + description: Compiler to use + + +runs: + using: composite + steps: + - uses: ./.github/actions/compile-unix + with: + compiler: ${{ inputs.compiler }} + + - name: Tests + env: + CC: ${{ inputs.compiler }} + LD_LIBRARY_PATH: /usr/lib:/usr/local/lib + shell: bash + run: make test + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f158d68..d8dd496 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,10 +2,14 @@ name: CI on: [push, pull_request] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + + jobs: gcc: name: c build and tests - runs-on: ${{ matrix.os }} strategy: matrix: include: @@ -17,42 +21,23 @@ jobs: compiler: gcc - os: macos-10.15 compiler: clang + + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Prepare - env: - CC: ${{ matrix.compiler }} - run: | - cc --version - git clone https://github.com/Conni2461/examiner - cd examiner - make && sudo make install - - name: Build - env: - CC: ${{ matrix.compiler }} - LD_LIBRARY_PATH: /usr/lib:/usr/local/lib - run: make - - name: Tests - env: - CC: ${{ matrix.compiler }} - LD_LIBRARY_PATH: /usr/lib:/usr/local/lib - run: make test + - uses: actions/checkout@v3 + - uses: ./.github/actions/test-unix + with: + compiler: ${{ matrix.compiler }} windows: name: windows runs-on: windows-2019 steps: - - uses: actions/checkout@v2 - - uses: lukka/get-cmake@latest - - name: Build - run: | - cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release - cmake --build build --config Release - cmake --install build --prefix build + - uses: actions/checkout@v3 + - uses: ./.github/actions/compile-windows nvim-tests: name: nvim-tests - runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-20.04, macos-10.15] @@ -61,28 +46,12 @@ jobs: url: https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz - os: macos-10.15 url: https://github.com/neovim/neovim/releases/download/nightly/nvim-macos.tar.gz + + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - run: date +%F > todays-date - - name: Restore cache for today's nightly. - uses: actions/cache@v2 + - uses: actions/checkout@v3 + - uses: ./.github/actions/nvim-unix-test with: - path: _neovim - key: ${{ matrix.os }}-${{ hashFiles('todays-date') }} - - name: Prepare - run: | - test -d _neovim || { - mkdir -p _neovim - curl -sL ${{ matrix.url }} | tar xzf - --strip-components=1 -C "${PWD}/_neovim" - } - mkdir -p ~/.local/share/nvim/site/pack/vendor/start - git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim - ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start - - name: Build - run: make - - name: Tests - run: | - export PATH="${PWD}/_neovim/bin:${PATH}" - export VIM="${PWD}/_neovim/share/nvim/runtime" - nvim --version - make ntest + os: ${{ matrix.os }} + url: ${{ matrix.url }} + diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c46e905..ee909ad 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,12 +2,17 @@ name: Linting and style checking on: [push, pull_request] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + + jobs: lint: name: Lint runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Prepare run: | @@ -22,7 +27,7 @@ jobs: name: clangformat runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Prepare clang-format run: | sudo apt-get update @@ -34,7 +39,7 @@ jobs: name: stylua runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: JohnnyMorganz/stylua-action@v1 with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..47f753b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,96 @@ +name: Release + +on: + push: + tags: + - "*" + branches: + - "main" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + unix: + name: unix build + + strategy: + matrix: + include: + - os: ubuntu-20.04 + compiler: gcc + - os: ubuntu-20.04 + compiler: clang + - os: macos-10.15 + compiler: gcc + - os: macos-10.15 + compiler: clang + + runs-on: ${{ matrix.os }} + + steps: + + - uses: actions/checkout@v3 + + + - uses: ./.github/actions/compile-unix + with: + compiler: ${{ matrix.compiler }} + + + - uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.os }}-${{matrix.compiler}} + path: build/*.so + + windows: + name: windows build + + strategy: + matrix: + include: + # TODO: add in clang build too ? + - os: windows-2019 + # TODO: specify actual correct compiler name here for windows + compiler: cc + + runs-on: ${{ matrix.os }} + steps: + + - uses: actions/checkout@v3 + + - uses: ./.github/actions/compile-windows + + - uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.os }}-${{ matrix.compiler }} + path: build/*.dll + + release: + needs: + - windows + - unix + + name: Release binaries + + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v3 + + - name: Download artifacts from previous jobs + id: artifacts + uses: ./.github/actions/prepare-artifacts + + - name: Upload release binaries + uses: ./.github/actions/release-binaries + with: + source: ${{ steps.artifacts.outputs.staging_area }} + is_development_release: ${{ !startsWith(github.ref, 'refs/tags') }} + is_production_release: ${{ startsWith(github.ref, 'refs/tags') }} + development_tag: dev + development_title: "dev (unstable)" + production_tag: ${{ github.ref_name }} # if we only consider tagged runs to be prod, then this will be the tag name + production_title: "Release: ${{ github.ref_name }}" From c3edf7924aba1078b7727994d7eb870a45b172db Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 27 Dec 2022 20:49:07 +1030 Subject: [PATCH 02/60] Provide download tool and updated README --- README.md | 60 ++++++++- lua/telescope-fzf-native/download_library.lua | 122 ++++++++++++++++++ lua/telescope-fzf-native/init.lua | 5 + 3 files changed, 183 insertions(+), 4 deletions(-) create mode 100644 lua/telescope-fzf-native/download_library.lua create mode 100644 lua/telescope-fzf-native/init.lua diff --git a/README.md b/README.md index bc78527..5fc135c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# telescope-fzf-native.nvim +``# telescope-fzf-native.nvim **fzf-native** is a `c` port of **[fzf][fzf]**. It only covers the algorithm and implements few functions to support calculating the score. @@ -29,14 +29,65 @@ available for telescope (as native component or as lua component). ## Installation -To get **fzf-native** working, you need to build it with either `cmake` or `make`. As of now, we do not ship binaries. -Both install methods will be supported going forward. +`telescope-fzf-native` is mostly a native binary. We do not commit this to the +repo, so you'll need to include a post install step to get it downloaded from +our github releases. + +```lua +use { + 'nvim-telescope/telescope-fzf-native.nvim', + run = function() require('telescope-fzf-native').download_library() end +} +``` + +Normally this tries to detect your operating system and defaults to downloading +the latest version. + +For other package managers, you'll want to look at the postinstall step: + +- [`packer.nvim`](https://github.com/wbthomason/packer.nvim) wants `run` +- [`lazy.nvim`](https://github.com/folke/lazy.nvim) will want you to use `build` +- [`vimplug`](https://github.com/junegunn/vim-plug) will probably want some kind `do` involving `:lua` :shrug: + + +```vim +Plug 'nvim-telescope/telescope-fzf-native.nvim', { + 'do': ':lua require("telescope-fzf-native").download_library()' +} +``` + +### download options + +```lua +use { + 'nvim-telescope/telescope-fzf-native.nvim', + run = function() + require('telescope-fzf-native').download_library({ + platform = 'windows' -- windows | ubuntu | macos + compiler = 'cc', -- windows: cc, unix: gcc | clang + version = 'latest' -- any release name found on our github releases page + }) + end +} +``` + +> 🤚 Note +> +> You'll need to have both `curl` and `sh` shell installed. +> +> On windows, this is done by installing git, and on linux and mac this should already be solved. + + + +## Building yourself + +If you want to build **fzf-native** yourself, you will need either `cmake` or `make`. ### CMake (Windows, Linux, MacOS) This requires: -- CMake, and the Microsoft C++ Build Tools on Windows +- CMake, and the Microsoft C++ Build Tools (vcc) on Windows - CMake, make, and GCC or Clang on Linux and MacOS #### vim-plug @@ -47,6 +98,7 @@ Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'cmake -S. -Bbuild -DCM #### packer.nvim + ```lua use {'nvim-telescope/telescope-fzf-native.nvim', run = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } ``` diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua new file mode 100644 index 0000000..c20cfc2 --- /dev/null +++ b/lua/telescope-fzf-native/download_library.lua @@ -0,0 +1,122 @@ +local uv = vim.loop +local plugin_path = string.sub(debug.getinfo(1).source, 2, #"/lua/telescope-fzf-native/download_library.lua" * -1) +local releases_url = "https://github.com/nvim-telescope/telescope-fzf-native.nvim/releases/download" + +local get_platform = function() + if vim.fn.has("win32") == 1 then + return 'windows' + end + + if vim.fn.has("mac") then + return 'macos' + end + + return "ubuntu" +end + +local get_valid_compiler = function(platform) + if platform == 'windows' then + return 'cc' + elseif platform == 'macos' then + return 'gcc' + elseif platform == 'linux' then + return 'gcc' + end +end + +local path_join = function(strings) + local path_separator = (platform == "windows") and '\\' or '/' + + return table.concat(strings, path_separator) +end + +local write_async = function(path, txt, flag) + uv.fs_open(path, flag, 438, function(open_err, fd) + assert(not open_err, open_err) + uv.fs_write(fd, txt, -1, function(write_err) + assert(not write_err, write_err) + uv.fs_close(fd, function(close_err) + assert(not close_err, close_err) + end) + end) + end) +end + +local spawn = function(cmd, on_exit) + local stdout = uv.new_pipe() + + local buffer = "" + + local real_cmd = table.remove(cmd, 1) + + uv.spawn(real_cmd, { + args = cmd, + stdio = { nil, stdout }, + verbatim = true + }, function() + stdout:read_stop() + if (type(on_exit) == "function") then + on_exit(buffer) + end + end) + + uv.read_start(stdout, function(err, data) + assert(not err, err) + if data then + buffer = buffer .. data + end + end) + +end + +local download = function(options) + options = options or {} + local platform = options.platform or get_platform() + local compiler = options.compiler or get_valid_compiler(platform) + local version = options.version or "latest" + + local command = nil + + if platform == 'windows' then + command = { + 'curl', '-L', + string.format("%s/%s/windows-2019-%s-libfzf.dll", releases_url, version, compiler), + '-o', path_join({ plugin_path, 'build', 'libfzf.dll' }) + } + end + + if platform == 'ubuntu' then + command = { + "curl", "-L", + string.format("%s/%s/ubuntu-%s-libfzf.so", releases_url, version, compiler), + "-o", path_join({ plugin_path, 'build', 'libfzf.so' }) + } + end + + if platform == 'macos' then + command = { + "curl", "-L", + string.format("%s/%s/macos-%s-libfzf.so", releases_url, version, compiler), + "-o", path_join({ plugin_path, 'build', 'libfzf.so' }) + } + end + + -- + -- Ensure the Build directory exists + -- + -- using format, becase we need to run the command in a subshell on windows. + -- + spawn({ + 'sh', + '-c', + string.format("' mkdir %s'", path_join({ plugin_path, 'build' })) + }) + + -- + -- Curl the download + -- + spawn(command) + +end + +return download diff --git a/lua/telescope-fzf-native/init.lua b/lua/telescope-fzf-native/init.lua new file mode 100644 index 0000000..e9d7f32 --- /dev/null +++ b/lua/telescope-fzf-native/init.lua @@ -0,0 +1,5 @@ +local download_library = require('telescope-fzf-native.download_library') + +return { + download_library = download_library +} From e3bc6031e03d4d776c8ab6087086216fdaaf5b7b Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Thu, 29 Dec 2022 08:12:09 +1030 Subject: [PATCH 03/60] remove unused code --- lua/telescope-fzf-native/download_library.lua | 59 ++++++++----------- 1 file changed, 24 insertions(+), 35 deletions(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index c20cfc2..86b5e9f 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -24,23 +24,6 @@ local get_valid_compiler = function(platform) end end -local path_join = function(strings) - local path_separator = (platform == "windows") and '\\' or '/' - - return table.concat(strings, path_separator) -end - -local write_async = function(path, txt, flag) - uv.fs_open(path, flag, 438, function(open_err, fd) - assert(not open_err, open_err) - uv.fs_write(fd, txt, -1, function(write_err) - assert(not write_err, write_err) - uv.fs_close(fd, function(close_err) - assert(not close_err, close_err) - end) - end) - end) -end local spawn = function(cmd, on_exit) local stdout = uv.new_pipe() @@ -69,36 +52,37 @@ local spawn = function(cmd, on_exit) end +-- +-- Given a platform, compiler and version; download +-- the appropriate binary from our releases on github. +-- +-- Ensures the expected 'build' directory exists before +-- dowloading. +-- local download = function(options) options = options or {} local platform = options.platform or get_platform() local compiler = options.compiler or get_valid_compiler(platform) local version = options.version or "latest" - local command = nil + local path_separator = (platform == "windows") and '\\' or '/' + local build_path = table.concat({ plugin_path, 'build' }, path_separator) + local download_file = nil + local binary_file = nil if platform == 'windows' then - command = { - 'curl', '-L', - string.format("%s/%s/windows-2019-%s-libfzf.dll", releases_url, version, compiler), - '-o', path_join({ plugin_path, 'build', 'libfzf.dll' }) - } + download_file = string.format("windows-2019-%s-libfzf.dll", compiler) + binary_file = 'libfzf.dll' end if platform == 'ubuntu' then - command = { - "curl", "-L", - string.format("%s/%s/ubuntu-%s-libfzf.so", releases_url, version, compiler), - "-o", path_join({ plugin_path, 'build', 'libfzf.so' }) - } + download_file = string.format("ubuntu-%s-libfzf.so", compiler) + binary_file = 'libfzf.so' end if platform == 'macos' then - command = { - "curl", "-L", - string.format("%s/%s/macos-%s-libfzf.so", releases_url, version, compiler), - "-o", path_join({ plugin_path, 'build', 'libfzf.so' }) - } + download_file = string.format("macos-%s-libfzf.so", compiler) + binary_file = 'libfzf.so' end -- @@ -109,13 +93,18 @@ local download = function(options) spawn({ 'sh', '-c', - string.format("' mkdir %s'", path_join({ plugin_path, 'build' })) + -- Unsure if the space here before mkdir is required for windows. + string.format("' mkdir %s'", build_path) }) -- -- Curl the download -- - spawn(command) + spawn({ + 'curl', + '-L', table.concat({ releases_url, version, download_file }, path_separator), + '-o', table.concat({ build_path, binary_file }, path_separator) + }) end From 35cea687fc3becc5a79ae46abe5c1e8bdcff945f Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Thu, 29 Dec 2022 08:21:12 +1030 Subject: [PATCH 04/60] basic documentation --- lua/telescope-fzf-native/download_library.lua | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index 86b5e9f..abd76b4 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -57,7 +57,29 @@ end -- the appropriate binary from our releases on github. -- -- Ensures the expected 'build' directory exists before --- dowloading. +-- downloading. +-- +-- Reminder: +-- +-- The filenames to download are defined as a side effect of the +-- matrix build names in `.github/actions/compile-unix/action.yml` and +-- `.github/actions/compile-windows/action.yml`, then also due to how +-- `.github/actions/prepare-artifacts/action.yml` downloads the artifacts +-- before uploading as releases. +-- +-- The filename pattern is generally: +-- +-- mac and linux: {github-runner-osname}-{compiler}/libfzf.so +-- windows: {github-runner-osname}-{compiler}/libfzf.dll +-- +-- Files in a github release are required to be unique per filename, so we +-- mutate the above downloaded artifacts into: +-- +-- {github-runner-osname}-{compiler}-libfzf.{type} +-- +-- This downloader then can pick the right binary and save it the users +-- local disk as `libfzf.so` or `libfzf.dll` +-- -- local download = function(options) options = options or {} @@ -70,6 +92,7 @@ local download = function(options) local download_file = nil local binary_file = nil + if platform == 'windows' then download_file = string.format("windows-2019-%s-libfzf.dll", compiler) binary_file = 'libfzf.dll' From b648cba280d6ff8f8bb87f3bf189af56f26a45ea Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Thu, 29 Dec 2022 08:32:43 +1030 Subject: [PATCH 05/60] highlight the two methods --- README.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5fc135c..f472c21 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -``# telescope-fzf-native.nvim +# telescope-fzf-native.nvim **fzf-native** is a `c` port of **[fzf][fzf]**. It only covers the algorithm and implements few functions to support calculating the score. @@ -29,9 +29,16 @@ available for telescope (as native component or as lua component). ## Installation -`telescope-fzf-native` is mostly a native binary. We do not commit this to the -repo, so you'll need to include a post install step to get it downloaded from -our github releases. +`telescope-fzf-native` is mostly a native binary, you'll need to either download our prebuilt binary or build it yourself. + + +### Prebuilt binaries + +You can either : + +- head over to our releases page for the version you want, download it and depending on your platform, put it into the `build` directory as either `libfzf.so` or `libfzf.dll`. +- Use the downloader in a postinstall step as demostrated below + ```lua use { From 0a64309228eb28b7b0cfd5cb6868cf58f0311478 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Thu, 29 Dec 2022 08:50:44 +1030 Subject: [PATCH 06/60] PR feedback changes --- lua/telescope-fzf-native/download_library.lua | 46 +++++++------------ lua/telescope-fzf-native/init.lua | 4 +- 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index abd76b4..f1b87b2 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -81,7 +81,7 @@ end -- local disk as `libfzf.so` or `libfzf.dll` -- -- -local download = function(options) +return function(options) options = options or {} local platform = options.platform or get_platform() local compiler = options.compiler or get_valid_compiler(platform) @@ -89,46 +89,34 @@ local download = function(options) local path_separator = (platform == "windows") and '\\' or '/' local build_path = table.concat({ plugin_path, 'build' }, path_separator) - local download_file = nil - local binary_file = nil + local download_file, binary_file = (function() + if platform == 'windows' then + return string.format("windows-2019-%s-libfzf.dll", compiler), + 'libfzf.dll' + end - if platform == 'windows' then - download_file = string.format("windows-2019-%s-libfzf.dll", compiler) - binary_file = 'libfzf.dll' - end - - if platform == 'ubuntu' then - download_file = string.format("ubuntu-%s-libfzf.so", compiler) - binary_file = 'libfzf.so' - end + if platform == 'ubuntu' then + return string.format("ubuntu-%s-libfzf.so", compiler), + 'libfzf.so' + end - if platform == 'macos' then - download_file = string.format("macos-%s-libfzf.so", compiler) - binary_file = 'libfzf.so' - end + if platform == 'macos' then + return string.format("macos-%s-libfzf.so", compiler), + 'libfzf.so' + end + end)() - -- - -- Ensure the Build directory exists - -- - -- using format, becase we need to run the command in a subshell on windows. - -- spawn({ - 'sh', - '-c', + -- we need to run the command in a subshell on windows. + 'sh', '-c', -- Unsure if the space here before mkdir is required for windows. string.format("' mkdir %s'", build_path) }) - -- - -- Curl the download - -- spawn({ 'curl', '-L', table.concat({ releases_url, version, download_file }, path_separator), '-o', table.concat({ build_path, binary_file }, path_separator) }) - end - -return download diff --git a/lua/telescope-fzf-native/init.lua b/lua/telescope-fzf-native/init.lua index e9d7f32..84e1372 100644 --- a/lua/telescope-fzf-native/init.lua +++ b/lua/telescope-fzf-native/init.lua @@ -1,5 +1,3 @@ -local download_library = require('telescope-fzf-native.download_library') - return { - download_library = download_library + download_library = require('telescope-fzf-native.download_library') } From 37df86c6176e182df389289d41d76c7c9518f1a8 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Fri, 30 Dec 2022 06:29:14 +1030 Subject: [PATCH 07/60] fixed incorrect platform detection and added downloader output --- lua/telescope-fzf-native/download_library.lua | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index f1b87b2..274bd84 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -1,13 +1,15 @@ local uv = vim.loop -local plugin_path = string.sub(debug.getinfo(1).source, 2, #"/lua/telescope-fzf-native/download_library.lua" * -1) -local releases_url = "https://github.com/nvim-telescope/telescope-fzf-native.nvim/releases/download" +local plugin_path = string.sub(debug.getinfo(1).source, 2, #"//lua/telescope-fzf-native/download_library.lua" * -1) +local releases_url = "https://github.com/airtonix/telescope-fzf-native.nvim/releases/download" + +print(debug.getinfo(1).source) local get_platform = function() if vim.fn.has("win32") == 1 then return 'windows' end - if vim.fn.has("mac") then + if vim.fn.has("mac") == 1 then return 'macos' end @@ -19,7 +21,7 @@ local get_valid_compiler = function(platform) return 'cc' elseif platform == 'macos' then return 'gcc' - elseif platform == 'linux' then + elseif platform == 'ubuntu' then return 'gcc' end end @@ -85,7 +87,7 @@ return function(options) options = options or {} local platform = options.platform or get_platform() local compiler = options.compiler or get_valid_compiler(platform) - local version = options.version or "latest" + local version = options.version or "dev" local path_separator = (platform == "windows") and '\\' or '/' local build_path = table.concat({ plugin_path, 'build' }, path_separator) @@ -107,16 +109,25 @@ return function(options) end end)() + print('creating build dir', build_path) + spawn({ -- we need to run the command in a subshell on windows. 'sh', '-c', -- Unsure if the space here before mkdir is required for windows. - string.format("' mkdir %s'", build_path) + string.format("mkdir %s", build_path) }) + local download_url = table.concat({ releases_url, version, download_file }, path_separator) + local output_path = table.concat({ build_path, binary_file }, path_separator) + + print('downloading', download_url, 'to', output_path) + spawn({ 'curl', - '-L', table.concat({ releases_url, version, download_file }, path_separator), - '-o', table.concat({ build_path, binary_file }, path_separator) + '-L', download_url, + '-o', output_path }) + + print('downloaded') end From 2671b7dc5a3031abd1bce6619600e5b17a5545f3 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Fri, 30 Dec 2022 08:35:55 +1030 Subject: [PATCH 08/60] ubuntu and macos release files have os version in them --- lua/telescope-fzf-native/download_library.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index 274bd84..4b76cd4 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -2,8 +2,6 @@ local uv = vim.loop local plugin_path = string.sub(debug.getinfo(1).source, 2, #"//lua/telescope-fzf-native/download_library.lua" * -1) local releases_url = "https://github.com/airtonix/telescope-fzf-native.nvim/releases/download" -print(debug.getinfo(1).source) - local get_platform = function() if vim.fn.has("win32") == 1 then return 'windows' @@ -99,12 +97,12 @@ return function(options) end if platform == 'ubuntu' then - return string.format("ubuntu-%s-libfzf.so", compiler), + return string.format("ubuntu-20.04-%s-libfzf.so", compiler), 'libfzf.so' end if platform == 'macos' then - return string.format("macos-%s-libfzf.so", compiler), + return string.format("macos-10.15-%s-libfzf.so", compiler), 'libfzf.so' end end)() From 420529b44c5964c5c2fb7d024f7da8a5c07b205c Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Thu, 16 Feb 2023 22:33:42 +1030 Subject: [PATCH 09/60] bump runner os used in matrix builds --- .github/workflows/ci.yml | 13 ++++++++----- .github/workflows/lint.yml | 6 +++--- .github/workflows/release.yml | 8 ++++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8dd496..2932a8e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,13 +13,13 @@ jobs: strategy: matrix: include: - - os: ubuntu-20.04 + - os: ubuntu-22.04.04 compiler: gcc - - os: ubuntu-20.04 + - os: ubuntu-22.04 compiler: clang - - os: macos-10.15 + - os: macos-12 compiler: gcc - - os: macos-10.15 + - os: macos-12 compiler: clang runs-on: ${{ matrix.os }} @@ -40,7 +40,10 @@ jobs: name: nvim-tests strategy: matrix: - os: [ubuntu-20.04, macos-10.15] + os: + - ubuntu-22.04 + - macos-12 + include: - os: ubuntu-20.04 url: https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ee909ad..cb67bab 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,7 +10,7 @@ concurrency: jobs: lint: name: Lint - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -25,7 +25,7 @@ jobs: clangformat: name: clangformat - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Prepare clang-format @@ -37,7 +37,7 @@ jobs: stylua: name: stylua - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: JohnnyMorganz/stylua-action@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 47f753b..1f2c220 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,13 +18,13 @@ jobs: strategy: matrix: include: - - os: ubuntu-20.04 + - os: ubuntu-22.04 compiler: gcc - - os: ubuntu-20.04 + - os: ubuntu-22.04 compiler: clang - - os: macos-10.15 + - os: macos-12 compiler: gcc - - os: macos-10.15 + - os: macos-12 compiler: clang runs-on: ${{ matrix.os }} From b46ef2911956b72d113e1ee93f9dc550c06ebd3d Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Thu, 16 Feb 2023 22:34:00 +1030 Subject: [PATCH 10/60] use the builtin tools to make the dir --- lua/telescope-fzf-native/download_library.lua | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index abd76b4..ef482c9 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -113,12 +113,7 @@ local download = function(options) -- -- using format, becase we need to run the command in a subshell on windows. -- - spawn({ - 'sh', - '-c', - -- Unsure if the space here before mkdir is required for windows. - string.format("' mkdir %s'", build_path) - }) + uv.fs_mkdir(build_path, 511) -- -- Curl the download From 2044b6c45d2317192554c111e55f932beb2c904e Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Thu, 16 Feb 2023 22:33:42 +1030 Subject: [PATCH 11/60] bump runner os used in matrix builds --- .github/workflows/ci.yml | 13 ++++++++----- .github/workflows/lint.yml | 6 +++--- .github/workflows/release.yml | 8 ++++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8dd496..2932a8e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,13 +13,13 @@ jobs: strategy: matrix: include: - - os: ubuntu-20.04 + - os: ubuntu-22.04.04 compiler: gcc - - os: ubuntu-20.04 + - os: ubuntu-22.04 compiler: clang - - os: macos-10.15 + - os: macos-12 compiler: gcc - - os: macos-10.15 + - os: macos-12 compiler: clang runs-on: ${{ matrix.os }} @@ -40,7 +40,10 @@ jobs: name: nvim-tests strategy: matrix: - os: [ubuntu-20.04, macos-10.15] + os: + - ubuntu-22.04 + - macos-12 + include: - os: ubuntu-20.04 url: https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ee909ad..cb67bab 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,7 +10,7 @@ concurrency: jobs: lint: name: Lint - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -25,7 +25,7 @@ jobs: clangformat: name: clangformat - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Prepare clang-format @@ -37,7 +37,7 @@ jobs: stylua: name: stylua - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: JohnnyMorganz/stylua-action@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 47f753b..1f2c220 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,13 +18,13 @@ jobs: strategy: matrix: include: - - os: ubuntu-20.04 + - os: ubuntu-22.04 compiler: gcc - - os: ubuntu-20.04 + - os: ubuntu-22.04 compiler: clang - - os: macos-10.15 + - os: macos-12 compiler: gcc - - os: macos-10.15 + - os: macos-12 compiler: clang runs-on: ${{ matrix.os }} From e06f047099b21cf5dfa5b3b2f9fe4d077b9ee978 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Thu, 16 Feb 2023 22:34:00 +1030 Subject: [PATCH 12/60] use the builtin tools to make the dir --- lua/telescope-fzf-native/download_library.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index 4b76cd4..52b673d 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -109,12 +109,12 @@ return function(options) print('creating build dir', build_path) - spawn({ - -- we need to run the command in a subshell on windows. - 'sh', '-c', - -- Unsure if the space here before mkdir is required for windows. - string.format("mkdir %s", build_path) - }) + -- + -- Ensure the Build directory exists + -- + -- using format, becase we need to run the command in a subshell on windows. + -- + uv.fs_mkdir(build_path, 511) local download_url = table.concat({ releases_url, version, download_file }, path_separator) local output_path = table.concat({ build_path, binary_file }, path_separator) From 8d10c1a001514f4aa053d4a2a1de7c2208900b27 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Thu, 16 Feb 2023 22:51:07 +1030 Subject: [PATCH 13/60] fix incorrect os name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2932a8e..b8664b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: include: - - os: ubuntu-22.04.04 + - os: ubuntu-22.04 compiler: gcc - os: ubuntu-22.04 compiler: clang From 98db1d65275702b8b07df182c4ffb835ae96a53e Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Thu, 16 Feb 2023 23:05:02 +1030 Subject: [PATCH 14/60] linting --- lua/telescope-fzf-native/download_library.lua | 158 +++++++++--------- lua/telescope-fzf-native/init.lua | 4 +- 2 files changed, 80 insertions(+), 82 deletions(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index ef482c9..324b764 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -3,53 +3,51 @@ local plugin_path = string.sub(debug.getinfo(1).source, 2, #"/lua/telescope-fzf- local releases_url = "https://github.com/nvim-telescope/telescope-fzf-native.nvim/releases/download" local get_platform = function() - if vim.fn.has("win32") == 1 then - return 'windows' - end + if vim.fn.has "win32" == 1 then + return "windows" + end - if vim.fn.has("mac") then - return 'macos' - end + if vim.fn.has "mac" then + return "macos" + end - return "ubuntu" + return "ubuntu" end local get_valid_compiler = function(platform) - if platform == 'windows' then - return 'cc' - elseif platform == 'macos' then - return 'gcc' - elseif platform == 'linux' then - return 'gcc' - end + if platform == "windows" then + return "cc" + elseif platform == "macos" then + return "gcc" + elseif platform == "linux" then + return "gcc" + end end - local spawn = function(cmd, on_exit) - local stdout = uv.new_pipe() - - local buffer = "" - - local real_cmd = table.remove(cmd, 1) - - uv.spawn(real_cmd, { - args = cmd, - stdio = { nil, stdout }, - verbatim = true - }, function() - stdout:read_stop() - if (type(on_exit) == "function") then - on_exit(buffer) - end - end) - - uv.read_start(stdout, function(err, data) - assert(not err, err) - if data then - buffer = buffer .. data - end - end) + local stdout = uv.new_pipe() + + local buffer = "" + local real_cmd = table.remove(cmd, 1) + + uv.spawn(real_cmd, { + args = cmd, + stdio = { nil, stdout }, + verbatim = true, + }, function() + stdout:read_stop() + if type(on_exit) == "function" then + on_exit(buffer) + end + end) + + uv.read_start(stdout, function(err, data) + assert(not err, err) + if data then + buffer = buffer .. data + end + end) end -- @@ -82,48 +80,48 @@ end -- -- local download = function(options) - options = options or {} - local platform = options.platform or get_platform() - local compiler = options.compiler or get_valid_compiler(platform) - local version = options.version or "latest" - - local path_separator = (platform == "windows") and '\\' or '/' - local build_path = table.concat({ plugin_path, 'build' }, path_separator) - local download_file = nil - local binary_file = nil - - - if platform == 'windows' then - download_file = string.format("windows-2019-%s-libfzf.dll", compiler) - binary_file = 'libfzf.dll' - end - - if platform == 'ubuntu' then - download_file = string.format("ubuntu-%s-libfzf.so", compiler) - binary_file = 'libfzf.so' - end - - if platform == 'macos' then - download_file = string.format("macos-%s-libfzf.so", compiler) - binary_file = 'libfzf.so' - end - - -- - -- Ensure the Build directory exists - -- - -- using format, becase we need to run the command in a subshell on windows. - -- - uv.fs_mkdir(build_path, 511) - - -- - -- Curl the download - -- - spawn({ - 'curl', - '-L', table.concat({ releases_url, version, download_file }, path_separator), - '-o', table.concat({ build_path, binary_file }, path_separator) - }) - + options = options or {} + local platform = options.platform or get_platform() + local compiler = options.compiler or get_valid_compiler(platform) + local version = options.version or "latest" + + local path_separator = (platform == "windows") and "\\" or "/" + local build_path = table.concat({ plugin_path, "build" }, path_separator) + local download_file = nil + local binary_file = nil + + if platform == "windows" then + download_file = string.format("windows-2019-%s-libfzf.dll", compiler) + binary_file = "libfzf.dll" + end + + if platform == "ubuntu" then + download_file = string.format("ubuntu-%s-libfzf.so", compiler) + binary_file = "libfzf.so" + end + + if platform == "macos" then + download_file = string.format("macos-%s-libfzf.so", compiler) + binary_file = "libfzf.so" + end + + -- + -- Ensure the Build directory exists + -- + -- using format, becase we need to run the command in a subshell on windows. + -- + uv.fs_mkdir(build_path, 511) + + -- + -- Curl the download + -- + spawn { + "curl", + "-L", + table.concat({ releases_url, version, download_file }, path_separator), + "-o", + table.concat({ build_path, binary_file }, path_separator), + } end return download diff --git a/lua/telescope-fzf-native/init.lua b/lua/telescope-fzf-native/init.lua index e9d7f32..2613661 100644 --- a/lua/telescope-fzf-native/init.lua +++ b/lua/telescope-fzf-native/init.lua @@ -1,5 +1,5 @@ -local download_library = require('telescope-fzf-native.download_library') +local download_library = require "telescope-fzf-native.download_library" return { - download_library = download_library + download_library = download_library, } From bf46f6839e5e48f386938264012824b8bf9f23c2 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Thu, 16 Feb 2023 23:12:12 +1030 Subject: [PATCH 15/60] add missing export --- lua/telescope-fzf-native/download_library.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index 1ae6afd..ba86286 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -123,3 +123,5 @@ local download = function(options) table.concat({ build_path, binary_file }, path_separator), } end + +return download From d905cc9341d54143cae55b2cf4a5af521701f538 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Thu, 16 Feb 2023 23:13:06 +1030 Subject: [PATCH 16/60] return to origin state --- lua/telescope-fzf-native/download_library.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index ba86286..a83d2e5 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -79,7 +79,7 @@ end -- local disk as `libfzf.so` or `libfzf.dll` -- -- -local download = function(options) +return function(options) options = options or {} local platform = options.platform or get_platform() local compiler = options.compiler or get_valid_compiler(platform) @@ -124,4 +124,3 @@ local download = function(options) } end -return download From 3cc1c491fd101b8f594b9ea3de2967bc7b1d0385 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Thu, 16 Feb 2023 23:31:52 +1030 Subject: [PATCH 17/60] yet more linting --- lua/telescope-fzf-native/download_library.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index a83d2e5..2dbb3cf 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -123,4 +123,3 @@ return function(options) table.concat({ build_path, binary_file }, path_separator), } end - From f483919bbbb2f0e0d5a1144eff5b8538d03a4a24 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Fri, 17 Feb 2023 08:16:45 +1030 Subject: [PATCH 18/60] describe platform separately from build OS --- .github/workflows/release.yml | 19 ++- lua/telescope-fzf-native/download_library.lua | 160 +++++++++--------- 2 files changed, 98 insertions(+), 81 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1f2c220..8a61e14 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,14 @@ name: Release +description: | + Builds and uploads binaries to the releases page. + + Each matrix here contains information related to making the build + for the os and compiler. Platform here is used to ensure the file + uploaded to the release page is correlates with the download helper + in `telescope-fzf-native/download_library.lua#get_platform`. + + on: push: tags: @@ -19,12 +28,16 @@ jobs: matrix: include: - os: ubuntu-22.04 + platform: linux compiler: gcc - os: ubuntu-22.04 + platform: linux compiler: clang - os: macos-12 + platform: macos compiler: gcc - os: macos-12 + platform: macos compiler: clang runs-on: ${{ matrix.os }} @@ -41,7 +54,7 @@ jobs: - uses: actions/upload-artifact@v3 with: - name: ${{ matrix.os }}-${{matrix.compiler}} + name: ${{ matrix.platform }}-${{matrix.compiler}} path: build/*.so windows: @@ -52,6 +65,8 @@ jobs: include: # TODO: add in clang build too ? - os: windows-2019 + # correlates to the get_platform in download_library + platform: win32 # TODO: specify actual correct compiler name here for windows compiler: cc @@ -64,7 +79,7 @@ jobs: - uses: actions/upload-artifact@v3 with: - name: ${{ matrix.os }}-${{ matrix.compiler }} + name: ${{ matrix.platform }}-${{ matrix.compiler }} path: build/*.dll release: diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index 2dbb3cf..f0c7c9f 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -3,51 +3,51 @@ local plugin_path = string.sub(debug.getinfo(1).source, 2, #"//lua/telescope-fzf local releases_url = "https://github.com/airtonix/telescope-fzf-native.nvim/releases/download" local get_platform = function() - if vim.fn.has "win32" == 1 then - return "windows" - end + if vim.fn.has "win32" == 1 then + return "windows" + end - if vim.fn.has "mac" then - return "macos" - end + if vim.fn.has "mac" == 1 then + return "macos" + end - return "ubuntu" + return "linux" end local get_valid_compiler = function(platform) - if platform == "windows" then - return "cc" - elseif platform == "macos" then - return "gcc" - elseif platform == "linux" then - return "gcc" - end + if platform == "windows" then + return "cc" + elseif platform == "macos" then + return "gcc" + elseif platform == "linux" then + return "gcc" + end end local spawn = function(cmd, on_exit) - local stdout = uv.new_pipe() - - local buffer = "" - - local real_cmd = table.remove(cmd, 1) - - uv.spawn(real_cmd, { - args = cmd, - stdio = { nil, stdout }, - verbatim = true, - }, function() - stdout:read_stop() - if type(on_exit) == "function" then - on_exit(buffer) - end - end) - - uv.read_start(stdout, function(err, data) - assert(not err, err) - if data then - buffer = buffer .. data - end - end) + local stdout = uv.new_pipe() + + local buffer = "" + + local real_cmd = table.remove(cmd, 1) + + uv.spawn(real_cmd, { + args = cmd, + stdio = { nil, stdout }, + verbatim = true, + }, function() + stdout:read_stop() + if type(on_exit) == "function" then + on_exit(buffer) + end + end) + + uv.read_start(stdout, function(err, data) + assert(not err, err) + if data then + buffer = buffer .. data + end + end) end -- @@ -80,46 +80,48 @@ end -- -- return function(options) - options = options or {} - local platform = options.platform or get_platform() - local compiler = options.compiler or get_valid_compiler(platform) - local version = options.version or "latest" - - local path_separator = (platform == "windows") and "\\" or "/" - local build_path = table.concat({ plugin_path, "build" }, path_separator) - local download_file = nil - local binary_file = nil - - if platform == "windows" then - download_file = string.format("windows-2019-%s-libfzf.dll", compiler) - binary_file = "libfzf.dll" - end - - if platform == "ubuntu" then - download_file = string.format("ubuntu-%s-libfzf.so", compiler) - binary_file = "libfzf.so" - end - - if platform == "macos" then - download_file = string.format("macos-%s-libfzf.so", compiler) - binary_file = "libfzf.so" - end - - -- - -- Ensure the Build directory exists - -- - -- using format, becase we need to run the command in a subshell on windows. - -- - uv.fs_mkdir(build_path, 511) - - -- - -- Curl the download - -- - spawn { - "curl", - "-L", - table.concat({ releases_url, version, download_file }, path_separator), - "-o", - table.concat({ build_path, binary_file }, path_separator), - } + options = options or {} + local platform = options.platform or get_platform() + local compiler = options.compiler or get_valid_compiler(platform) + local version = options.version or "dev" + + local path_separator = (platform == "windows") and "\\" or "/" + local build_path = table.concat({ plugin_path, "build" }, path_separator) + local download_file = nil + local binary_file = nil + + if platform == "windows" then + download_file = string.format("windows-2019-%s-libfzf.dll", compiler) + binary_file = "libfzf.dll" + end + + if platform == "ubuntu" then + download_file = string.format("linux-%s-libfzf.so", compiler) + binary_file = "libfzf.so" + end + + if platform == "macos" then + download_file = string.format("macos-%s-libfzf.so", compiler) + binary_file = "libfzf.so" + end + + -- + -- Ensure the Build directory exists + -- + -- using format, becase we need to run the command in a subshell on windows. + -- + uv.fs_mkdir(build_path, 511) + + local source = table.concat({ releases_url, version, download_file }, path_separator) + local target = table.concat({ build_path, binary_file }, path_separator) + + print("downloading", source, "to", target) + -- + -- Curl the download + -- + spawn { + "curl", + "-L", source, + "-o", target + } end From 10b9dacfc8eb3d4d763b27a2b2a4f340d469c157 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Fri, 17 Feb 2023 08:17:48 +1030 Subject: [PATCH 19/60] linting --- lua/telescope-fzf-native/download_library.lua | 164 +++++++++--------- 1 file changed, 83 insertions(+), 81 deletions(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index f0c7c9f..cf8ed06 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -3,51 +3,51 @@ local plugin_path = string.sub(debug.getinfo(1).source, 2, #"//lua/telescope-fzf local releases_url = "https://github.com/airtonix/telescope-fzf-native.nvim/releases/download" local get_platform = function() - if vim.fn.has "win32" == 1 then - return "windows" - end + if vim.fn.has "win32" == 1 then + return "windows" + end - if vim.fn.has "mac" == 1 then - return "macos" - end + if vim.fn.has "mac" == 1 then + return "macos" + end - return "linux" + return "linux" end local get_valid_compiler = function(platform) - if platform == "windows" then - return "cc" - elseif platform == "macos" then - return "gcc" - elseif platform == "linux" then - return "gcc" - end + if platform == "windows" then + return "cc" + elseif platform == "macos" then + return "gcc" + elseif platform == "linux" then + return "gcc" + end end local spawn = function(cmd, on_exit) - local stdout = uv.new_pipe() - - local buffer = "" - - local real_cmd = table.remove(cmd, 1) - - uv.spawn(real_cmd, { - args = cmd, - stdio = { nil, stdout }, - verbatim = true, - }, function() - stdout:read_stop() - if type(on_exit) == "function" then - on_exit(buffer) - end - end) - - uv.read_start(stdout, function(err, data) - assert(not err, err) - if data then - buffer = buffer .. data - end - end) + local stdout = uv.new_pipe() + + local buffer = "" + + local real_cmd = table.remove(cmd, 1) + + uv.spawn(real_cmd, { + args = cmd, + stdio = { nil, stdout }, + verbatim = true, + }, function() + stdout:read_stop() + if type(on_exit) == "function" then + on_exit(buffer) + end + end) + + uv.read_start(stdout, function(err, data) + assert(not err, err) + if data then + buffer = buffer .. data + end + end) end -- @@ -80,48 +80,50 @@ end -- -- return function(options) - options = options or {} - local platform = options.platform or get_platform() - local compiler = options.compiler or get_valid_compiler(platform) - local version = options.version or "dev" - - local path_separator = (platform == "windows") and "\\" or "/" - local build_path = table.concat({ plugin_path, "build" }, path_separator) - local download_file = nil - local binary_file = nil - - if platform == "windows" then - download_file = string.format("windows-2019-%s-libfzf.dll", compiler) - binary_file = "libfzf.dll" - end - - if platform == "ubuntu" then - download_file = string.format("linux-%s-libfzf.so", compiler) - binary_file = "libfzf.so" - end - - if platform == "macos" then - download_file = string.format("macos-%s-libfzf.so", compiler) - binary_file = "libfzf.so" - end - - -- - -- Ensure the Build directory exists - -- - -- using format, becase we need to run the command in a subshell on windows. - -- - uv.fs_mkdir(build_path, 511) - - local source = table.concat({ releases_url, version, download_file }, path_separator) - local target = table.concat({ build_path, binary_file }, path_separator) - - print("downloading", source, "to", target) - -- - -- Curl the download - -- - spawn { - "curl", - "-L", source, - "-o", target - } + options = options or {} + local platform = options.platform or get_platform() + local compiler = options.compiler or get_valid_compiler(platform) + local version = options.version or "dev" + + local path_separator = (platform == "windows") and "\\" or "/" + local build_path = table.concat({ plugin_path, "build" }, path_separator) + local download_file = nil + local binary_file = nil + + if platform == "windows" then + download_file = string.format("windows-2019-%s-libfzf.dll", compiler) + binary_file = "libfzf.dll" + end + + if platform == "ubuntu" then + download_file = string.format("linux-%s-libfzf.so", compiler) + binary_file = "libfzf.so" + end + + if platform == "macos" then + download_file = string.format("macos-%s-libfzf.so", compiler) + binary_file = "libfzf.so" + end + + -- + -- Ensure the Build directory exists + -- + -- using format, becase we need to run the command in a subshell on windows. + -- + uv.fs_mkdir(build_path, 511) + + local source = table.concat({ releases_url, version, download_file }, path_separator) + local target = table.concat({ build_path, binary_file }, path_separator) + + print("downloading", source, "to", target) + -- + -- Curl the download + -- + spawn { + "curl", + "-L", + source, + "-o", + target, + } end From 1348b5bd978cc4c01aeb2d248027bd29cf5a2d90 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Fri, 17 Feb 2023 08:22:43 +1030 Subject: [PATCH 20/60] fix linux platform name --- lua/telescope-fzf-native/download_library.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index cf8ed06..fda5181 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -95,7 +95,7 @@ return function(options) binary_file = "libfzf.dll" end - if platform == "ubuntu" then + if platform == "linux" then download_file = string.format("linux-%s-libfzf.so", compiler) binary_file = "libfzf.so" end From 486611c0e8bb685ef13e1afd1259ea5fef39fb14 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Fri, 17 Feb 2023 08:24:33 +1030 Subject: [PATCH 21/60] remove invalid key --- .github/workflows/release.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8a61e14..59d1eb1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,14 +1,5 @@ name: Release -description: | - Builds and uploads binaries to the releases page. - - Each matrix here contains information related to making the build - for the os and compiler. Platform here is used to ensure the file - uploaded to the release page is correlates with the download helper - in `telescope-fzf-native/download_library.lua#get_platform`. - - on: push: tags: From 7cc21565252a82d5010951a74df8b76196ec19e0 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Sun, 19 Feb 2023 11:56:19 +1030 Subject: [PATCH 22/60] use correct binary name for windows --- lua/telescope-fzf-native/download_library.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index fda5181..b77470b 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -91,7 +91,7 @@ return function(options) local binary_file = nil if platform == "windows" then - download_file = string.format("windows-2019-%s-libfzf.dll", compiler) + download_file = string.format("win32-%s-libfzf.dll", compiler) binary_file = "libfzf.dll" end From 31d6026d69bf98314bfe7005d4bcad81a126d3b1 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Sun, 19 Feb 2023 12:10:12 +1030 Subject: [PATCH 23/60] prefix job names for easier use in branch protection --- .github/workflows/ci.yml | 6 ++--- .github/workflows/lint.yml | 8 +++--- .github/workflows/release.yml | 47 +++++++++++++++++++++-------------- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8664b7..fbb8316 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ concurrency: jobs: gcc: - name: c build and tests + name: "CI/gcc: c build and tests" strategy: matrix: include: @@ -30,14 +30,14 @@ jobs: compiler: ${{ matrix.compiler }} windows: - name: windows + name: CI/windows runs-on: windows-2019 steps: - uses: actions/checkout@v3 - uses: ./.github/actions/compile-windows nvim-tests: - name: nvim-tests + name: CI/nvim-tests strategy: matrix: os: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cb67bab..e47b503 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,8 +8,8 @@ concurrency: jobs: - lint: - name: Lint + luacheck: + name: Lint/luacheck runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -24,7 +24,7 @@ jobs: run: make lint clangformat: - name: clangformat + name: Lint/clangformat runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -36,7 +36,7 @@ jobs: run: make format stylua: - name: stylua + name: Lint/stylua runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8a61e14..a84ab5a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,14 +1,5 @@ name: Release -description: | - Builds and uploads binaries to the releases page. - - Each matrix here contains information related to making the build - for the os and compiler. Platform here is used to ensure the file - uploaded to the release page is correlates with the download helper - in `telescope-fzf-native/download_library.lua#get_platform`. - - on: push: tags: @@ -21,23 +12,43 @@ concurrency: cancel-in-progress: true jobs: - unix: - name: unix build + linux: + name: Release/make-linux-binaries strategy: matrix: include: - os: ubuntu-22.04 - platform: linux compiler: gcc - os: ubuntu-22.04 - platform: linux compiler: clang + + runs-on: ${{ matrix.os }} + + steps: + + - uses: actions/checkout@v3 + + + - uses: ./.github/actions/compile-unix + with: + compiler: ${{ matrix.compiler }} + + + - uses: actions/upload-artifact@v3 + with: + name: linux-${{matrix.compiler}} + path: build/*.so + + macos: + name: Release/make-macos-binaries + + strategy: + matrix: + include: - os: macos-12 - platform: macos compiler: gcc - os: macos-12 - platform: macos compiler: clang runs-on: ${{ matrix.os }} @@ -54,11 +65,11 @@ jobs: - uses: actions/upload-artifact@v3 with: - name: ${{ matrix.platform }}-${{matrix.compiler}} + name: macos-${{matrix.compiler}} path: build/*.so windows: - name: windows build + name: Release/make-windows-binaries strategy: matrix: @@ -87,7 +98,7 @@ jobs: - windows - unix - name: Release binaries + name: Release/upload-binaries runs-on: ubuntu-latest From 7085841857b724a8c3731f09d4da13f75f6abe25 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Sun, 19 Feb 2023 12:16:42 +1030 Subject: [PATCH 24/60] remove prefix --- .github/workflows/ci.yml | 6 +++--- .github/workflows/lint.yml | 6 +++--- .github/workflows/release.yml | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fbb8316..bfb9eb1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ concurrency: jobs: gcc: - name: "CI/gcc: c build and tests" + name: gcc-clang-build-and-tests strategy: matrix: include: @@ -30,14 +30,14 @@ jobs: compiler: ${{ matrix.compiler }} windows: - name: CI/windows + name: windows-cmake-build-tests runs-on: windows-2019 steps: - uses: actions/checkout@v3 - uses: ./.github/actions/compile-windows nvim-tests: - name: CI/nvim-tests + name: nvim-tests strategy: matrix: os: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e47b503..ce14d8f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,7 +9,7 @@ concurrency: jobs: luacheck: - name: Lint/luacheck + name: luacheck runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -24,7 +24,7 @@ jobs: run: make lint clangformat: - name: Lint/clangformat + name: clangformat runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -36,7 +36,7 @@ jobs: run: make format stylua: - name: Lint/stylua + name: stylua runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a84ab5a..0ff474e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ concurrency: jobs: linux: - name: Release/make-linux-binaries + name: make-linux-binaries strategy: matrix: @@ -41,7 +41,7 @@ jobs: path: build/*.so macos: - name: Release/make-macos-binaries + name: make-macos-binaries strategy: matrix: @@ -69,7 +69,7 @@ jobs: path: build/*.so windows: - name: Release/make-windows-binaries + name: make-windows-binaries strategy: matrix: @@ -98,7 +98,7 @@ jobs: - windows - unix - name: Release/upload-binaries + name: upload-binaries-to-release-page runs-on: ubuntu-latest From 7fdf272ab311a5abe4ec6b41d1fdc6d648ee06be Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Sun, 19 Feb 2023 12:22:55 +1030 Subject: [PATCH 25/60] fix release workflow dependencies --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0ff474e..b1f9766 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -96,7 +96,8 @@ jobs: release: needs: - windows - - unix + - linux + - macos name: upload-binaries-to-release-page From 6388c4f4ec5eab8b89f974a9fa57fc955a67bbb2 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Sun, 19 Feb 2023 12:37:46 +1030 Subject: [PATCH 26/60] always use forward slash for urls --- lua/telescope-fzf-native/download_library.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index b77470b..404514c 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -112,7 +112,7 @@ return function(options) -- uv.fs_mkdir(build_path, 511) - local source = table.concat({ releases_url, version, download_file }, path_separator) + local source = table.concat({ releases_url, version, download_file }, '/') local target = table.concat({ build_path, binary_file }, path_separator) print("downloading", source, "to", target) From 4adec983f564862f4832491bc0525cfb39b6fd21 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Mon, 3 Apr 2023 10:08:23 +0930 Subject: [PATCH 27/60] no longer uses subshell to make directorioes --- lua/telescope-fzf-native/download_library.lua | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index 404514c..e9116b9 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -78,7 +78,6 @@ end -- This downloader then can pick the right binary and save it the users -- local disk as `libfzf.so` or `libfzf.dll` -- --- return function(options) options = options or {} local platform = options.platform or get_platform() @@ -105,20 +104,15 @@ return function(options) binary_file = "libfzf.so" end - -- -- Ensure the Build directory exists - -- - -- using format, becase we need to run the command in a subshell on windows. - -- uv.fs_mkdir(build_path, 511) - local source = table.concat({ releases_url, version, download_file }, '/') + local source = table.concat({ releases_url, version, download_file }, "/") local target = table.concat({ build_path, binary_file }, path_separator) print("downloading", source, "to", target) - -- + -- Curl the download - -- spawn { "curl", "-L", From 3cc1d5c47d85e0043ff11f71e00112422197f528 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Mon, 3 Apr 2023 17:16:12 +0930 Subject: [PATCH 28/60] refactor actions to support arm64 builds --- .github/actions/compile-unix-arm64/action.yml | 25 +++++++ .../action.yml | 4 +- .../action.yml | 4 +- .../action.yml | 4 +- .../actions/run-on-linux-aarch64/action.yml | 49 ++++++++++++ .../actions/unittest-unix-arm64/action.yml | 26 +++++++ .../action.yml | 6 +- .github/workflows/ci.yml | 75 +++++++++++++++---- .github/workflows/release.yml | 62 ++++++++++----- lua/telescope-fzf-native/download_library.lua | 14 +--- 10 files changed, 218 insertions(+), 51 deletions(-) create mode 100644 .github/actions/compile-unix-arm64/action.yml rename .github/actions/{compile-unix => compile-unix-x86_64}/action.yml (85%) rename .github/actions/{compile-windows => compile-windows-x86_64}/action.yml (82%) rename .github/actions/{nvim-unix-test => e2etest-unix-x86_64}/action.yml (92%) create mode 100644 .github/actions/run-on-linux-aarch64/action.yml create mode 100644 .github/actions/unittest-unix-arm64/action.yml rename .github/actions/{test-unix => unittest-unix-x86_64}/action.yml (70%) diff --git a/.github/actions/compile-unix-arm64/action.yml b/.github/actions/compile-unix-arm64/action.yml new file mode 100644 index 0000000..f2881be --- /dev/null +++ b/.github/actions/compile-unix-arm64/action.yml @@ -0,0 +1,25 @@ +--- +name: Compile Unix Library (arm64) + +description: | + Prepare and compile unix builds for arm64 cpus + +inputs: + compiler: + required: true + description: Compiler to use + distro: + required: false + description: the base os to run in arm64 mode + default: ubuntu20-04 + +runs: + using: composite + steps: + + - name: Compile + uses: ./.github/actions/run-on-linux-aarch64 + with: + distro: ${{ inputs.distro }} + compiler: ${{ inputs.compiler }} + run: make && sudo make install diff --git a/.github/actions/compile-unix/action.yml b/.github/actions/compile-unix-x86_64/action.yml similarity index 85% rename from .github/actions/compile-unix/action.yml rename to .github/actions/compile-unix-x86_64/action.yml index 89e3e82..ad57785 100644 --- a/.github/actions/compile-unix/action.yml +++ b/.github/actions/compile-unix-x86_64/action.yml @@ -1,8 +1,8 @@ --- -name: Compile Unix Library +name: Compile Unix Library (x86_64) description: | - Prepare and compile unix builds + Prepare and compile unix builds for x86_64 cpus inputs: compiler: diff --git a/.github/actions/compile-windows/action.yml b/.github/actions/compile-windows-x86_64/action.yml similarity index 82% rename from .github/actions/compile-windows/action.yml rename to .github/actions/compile-windows-x86_64/action.yml index 556e3ac..d9b79a3 100644 --- a/.github/actions/compile-windows/action.yml +++ b/.github/actions/compile-windows-x86_64/action.yml @@ -1,8 +1,8 @@ --- -name: Compile windows library +name: Compile windows library (x86_64) description: | - Prepare and compile a windows build + Prepare and compile a windows build for x86_64 cpus runs: diff --git a/.github/actions/nvim-unix-test/action.yml b/.github/actions/e2etest-unix-x86_64/action.yml similarity index 92% rename from .github/actions/nvim-unix-test/action.yml rename to .github/actions/e2etest-unix-x86_64/action.yml index a5e3e7c..d184ac7 100644 --- a/.github/actions/nvim-unix-test/action.yml +++ b/.github/actions/e2etest-unix-x86_64/action.yml @@ -1,8 +1,8 @@ --- -name: Test Unix Library +name: Unit Test Unix Library (arm64) description: | - Run some neovim tests + Run some e2e neovim tests for unix on arm64 cpus inputs: os: diff --git a/.github/actions/run-on-linux-aarch64/action.yml b/.github/actions/run-on-linux-aarch64/action.yml new file mode 100644 index 0000000..2289b92 --- /dev/null +++ b/.github/actions/run-on-linux-aarch64/action.yml @@ -0,0 +1,49 @@ +--- +name: Execute on linux aarch64 cpu + +description: | + Spins up a qemu vm in a container to execute provided commands in a aarch64 cpu + +inputs: + compiler: + required: true + description: Compiler to use + distro: + required: false + description: the base os to run in arm64 mode + default: ubuntu20-04 + run: + required: false + description: the cmd to run + default: make + +runs: + using: composite + steps: + + - name: Prepare + uses: uraimo/run-on-arch-action@v2.0.5 + # see: https://github.com/uraimo/run-on-arch-action#usage + with: + arch: aarch64 + distro: ${{ inputs.distro }} + env: + CC: ${{ inputs.compiler }} + LD_LIBRARY_PATH: /usr/lib:/usr/local/lib + RUN: ${{ inputs.run }} + install: | + case "${{ inputs.distro }}" in + ubuntu*|jessie|stretch|buster) + apt update -q -y + apt install -q -y build-essential + ;; + esac + run: | + cc --version + + git clone https://github.com/Conni2461/examiner + + env -C examiner \ + make && sudo make install + + ${{env.RUN}} \ No newline at end of file diff --git a/.github/actions/unittest-unix-arm64/action.yml b/.github/actions/unittest-unix-arm64/action.yml new file mode 100644 index 0000000..5af202f --- /dev/null +++ b/.github/actions/unittest-unix-arm64/action.yml @@ -0,0 +1,26 @@ +--- +name: Compile Unix Library (arm64) + +description: | + Prepare and compile unix builds for arm64 cpus + +inputs: + compiler: + required: true + description: Compiler to use + distro: + required: false + description: the base os to run in arm64 mode + default: ubuntu20-04 + +runs: + using: composite + steps: + + - name: Compile + uses: ./.github/actions/run-on-linux-aarch64 + with: + distro: ${{ inputs.distro }} + compiler: ${{ inputs.compiler }} + run: make test + diff --git a/.github/actions/test-unix/action.yml b/.github/actions/unittest-unix-x86_64/action.yml similarity index 70% rename from .github/actions/test-unix/action.yml rename to .github/actions/unittest-unix-x86_64/action.yml index fb5b5f8..9a2940d 100644 --- a/.github/actions/test-unix/action.yml +++ b/.github/actions/unittest-unix-x86_64/action.yml @@ -1,8 +1,8 @@ --- -name: Test unix library +name: Unit Test Unix Library (x86_64) description: | - Compile and test a unix build + Compile and test a unix build on unix for x86_64 cpus inputs: compiler: @@ -13,7 +13,7 @@ inputs: runs: using: composite steps: - - uses: ./.github/actions/compile-unix + - uses: ./.github/actions/compile-unix-x86_64 with: compiler: ${{ inputs.compiler }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bfb9eb1..0f0d5bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,52 +8,101 @@ concurrency: jobs: - gcc: - name: gcc-clang-build-and-tests + unittest_linux_x86_64: + name: unittest-linux-x86_64 strategy: matrix: include: - os: ubuntu-22.04 compiler: gcc + arch: x86 - os: ubuntu-22.04 compiler: clang + arch: x86 + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/unittest-unix-x86_64 + with: + compiler: ${{ matrix.compiler }} + arch: ${{ matrix.arch }} + + unittest_linux_arm64: + name: unittest-linux-arm64 + strategy: + matrix: + include: + - os: ubuntu-22.04 + compiler: gcc + arch: x86 + - os: ubuntu-22.04 + compiler: clang + arch: x86 + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/unittest-unix-arm64 + with: + compiler: ${{ matrix.compiler }} + arch: ${{ matrix.arch }} + + unittest_macosx_x86_64: + name: unittests-macosx-x86_64 + strategy: + matrix: + include: - os: macos-12 compiler: gcc + arch: x86 - os: macos-12 compiler: clang + arch: x86 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - uses: ./.github/actions/test-unix + - uses: ./.github/actions/unittest-unix-x86_64 with: compiler: ${{ matrix.compiler }} + arch: ${{ matrix.arch }} - windows: - name: windows-cmake-build-tests + unittest_windows_x86_64: + name: unittest-windows-x86_64 runs-on: windows-2019 steps: - uses: actions/checkout@v3 - - uses: ./.github/actions/compile-windows + - uses: ./.github/actions/compile-windows-x86_64 - nvim-tests: - name: nvim-tests + e2etest_linux_x86_64: + name: e2etest-linux-x86_64 strategy: matrix: - os: - - ubuntu-22.04 - - macos-12 - include: - os: ubuntu-20.04 url: https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/e2etest-unix-x86_64 + with: + os: ${{ matrix.os }} + url: ${{ matrix.url }} + + e2etest_macos_x86_64: + name: e2etest-macos-x86_64 + strategy: + matrix: + include: - os: macos-10.15 url: https://github.com/neovim/neovim/releases/download/nightly/nvim-macos.tar.gz runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - uses: ./.github/actions/nvim-unix-test + - uses: ./.github/actions/e2etest-unix-x86_64 with: os: ${{ matrix.os }} url: ${{ matrix.url }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b1f9766..83cb1b0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,15 +12,17 @@ concurrency: cancel-in-progress: true jobs: - linux: + linux_x86_64: name: make-linux-binaries strategy: matrix: include: - os: ubuntu-22.04 + platform: linux compiler: gcc - os: ubuntu-22.04 + platform: linux compiler: clang runs-on: ${{ matrix.os }} @@ -29,26 +31,55 @@ jobs: - uses: actions/checkout@v3 - - - uses: ./.github/actions/compile-unix + - uses: ./.github/actions/compile-unix-x86_64 with: compiler: ${{ matrix.compiler }} + - uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.platform }}-x86_64-${{ matrix.compiler }} + path: build/*.so + + linux_arm64: + name: make-linux-binaries + + strategy: + matrix: + include: + - os: ubuntu-22.04 + platform: linux + compiler: gcc + - os: ubuntu-22.04 + platform: linux + compiler: clang + + runs-on: ${{ matrix.os }} + + steps: + + - uses: actions/checkout@v3 + + - uses: ./.github/actions/compile-unix-arm64 + with: + compiler: ${{ matrix.compiler }} + distro: ${{ matrix.os }} - uses: actions/upload-artifact@v3 with: - name: linux-${{matrix.compiler}} + name: ${{ matrix.platform }}-arm64-${{ matrix.compiler }} path: build/*.so - macos: + macos_x86_64: name: make-macos-binaries strategy: matrix: include: - os: macos-12 + platform: macos compiler: gcc - os: macos-12 + platform: macos compiler: clang runs-on: ${{ matrix.os }} @@ -57,18 +88,16 @@ jobs: - uses: actions/checkout@v3 - - - uses: ./.github/actions/compile-unix + - uses: ./.github/actions/compile-unix-x86_64 with: compiler: ${{ matrix.compiler }} - - uses: actions/upload-artifact@v3 with: - name: macos-${{matrix.compiler}} + name: ${{ matrix.platform }}-x86_64-${{ matrix.compiler }} path: build/*.so - windows: + windows_x86_64: name: make-windows-binaries strategy: @@ -76,9 +105,7 @@ jobs: include: # TODO: add in clang build too ? - os: windows-2019 - # correlates to the get_platform in download_library platform: win32 - # TODO: specify actual correct compiler name here for windows compiler: cc runs-on: ${{ matrix.os }} @@ -86,18 +113,19 @@ jobs: - uses: actions/checkout@v3 - - uses: ./.github/actions/compile-windows + - uses: ./.github/actions/compile-windows-x86_64 - uses: actions/upload-artifact@v3 with: - name: ${{ matrix.platform }}-${{ matrix.compiler }} + name: ${{ matrix.platform }}-x86_64-${{ matrix.compiler }} path: build/*.dll release: needs: - - windows - - linux - - macos + - linux_x86_64 + - linux_arm64 + - macos_x86_64 + - windows_x86_64 name: upload-binaries-to-release-page diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index e9116b9..4c3a5a6 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -2,17 +2,6 @@ local uv = vim.loop local plugin_path = string.sub(debug.getinfo(1).source, 2, #"//lua/telescope-fzf-native/download_library.lua" * -1) local releases_url = "https://github.com/airtonix/telescope-fzf-native.nvim/releases/download" -local get_platform = function() - if vim.fn.has "win32" == 1 then - return "windows" - end - - if vim.fn.has "mac" == 1 then - return "macos" - end - - return "linux" -end local get_valid_compiler = function(platform) if platform == "windows" then @@ -80,7 +69,8 @@ end -- return function(options) options = options or {} - local platform = options.platform or get_platform() + local platform = options.platform or jit.os + local arch = options.arch or jit.arch local compiler = options.compiler or get_valid_compiler(platform) local version = options.version or "dev" From 65026e45affdefe834eb8807078b1d815f8ca366 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Mon, 3 Apr 2023 17:21:12 +0930 Subject: [PATCH 29/60] no need for arch in the matrix now --- .github/workflows/ci.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f0d5bd..fb0dbd8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,10 +15,8 @@ jobs: include: - os: ubuntu-22.04 compiler: gcc - arch: x86 - os: ubuntu-22.04 compiler: clang - arch: x86 runs-on: ${{ matrix.os }} steps: @@ -26,7 +24,6 @@ jobs: - uses: ./.github/actions/unittest-unix-x86_64 with: compiler: ${{ matrix.compiler }} - arch: ${{ matrix.arch }} unittest_linux_arm64: name: unittest-linux-arm64 @@ -35,10 +32,8 @@ jobs: include: - os: ubuntu-22.04 compiler: gcc - arch: x86 - os: ubuntu-22.04 compiler: clang - arch: x86 runs-on: ${{ matrix.os }} steps: @@ -46,7 +41,7 @@ jobs: - uses: ./.github/actions/unittest-unix-arm64 with: compiler: ${{ matrix.compiler }} - arch: ${{ matrix.arch }} + distro: ${{ matrix.os }} unittest_macosx_x86_64: name: unittests-macosx-x86_64 @@ -55,10 +50,8 @@ jobs: include: - os: macos-12 compiler: gcc - arch: x86 - os: macos-12 compiler: clang - arch: x86 runs-on: ${{ matrix.os }} steps: @@ -66,7 +59,6 @@ jobs: - uses: ./.github/actions/unittest-unix-x86_64 with: compiler: ${{ matrix.compiler }} - arch: ${{ matrix.arch }} unittest_windows_x86_64: name: unittest-windows-x86_64 From 08274e117e3898410efc27ea989bad75df5fd69c Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Mon, 3 Apr 2023 17:43:49 +0930 Subject: [PATCH 30/60] make sure artifacts leave the container --- .github/actions/compile-unix-arm64/action.yml | 16 +++++++++++++++- .github/actions/compile-unix-x86_64/action.yml | 4 ++-- .github/actions/run-on-linux-aarch64/action.yml | 14 +++++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.github/actions/compile-unix-arm64/action.yml b/.github/actions/compile-unix-arm64/action.yml index f2881be..a37a76e 100644 --- a/.github/actions/compile-unix-arm64/action.yml +++ b/.github/actions/compile-unix-arm64/action.yml @@ -22,4 +22,18 @@ runs: with: distro: ${{ inputs.distro }} compiler: ${{ inputs.compiler }} - run: make && sudo make install + setup: | + mkdir -p "${PWD}/artifacts" + + run: | + make && sudo make install + # Produce a binary artifact and place it in the mounted volume + cp ./build/* /artifacts/ + + - name: Show the artifact + # Items placed in /artifacts in the container will be in + # ${PWD}/artifacts on the host.\ + shell: bash + run: | + echo "Produced artifact at" + ls -al "${PWD}/artifacts" \ No newline at end of file diff --git a/.github/actions/compile-unix-x86_64/action.yml b/.github/actions/compile-unix-x86_64/action.yml index ad57785..2c22938 100644 --- a/.github/actions/compile-unix-x86_64/action.yml +++ b/.github/actions/compile-unix-x86_64/action.yml @@ -20,8 +20,8 @@ runs: run: | cc --version git clone https://github.com/Conni2461/examiner - cd examiner - make && sudo make install + env -C examiner \ + { make && sudo make install } - name: Build env: diff --git a/.github/actions/run-on-linux-aarch64/action.yml b/.github/actions/run-on-linux-aarch64/action.yml index 2289b92..7a50231 100644 --- a/.github/actions/run-on-linux-aarch64/action.yml +++ b/.github/actions/run-on-linux-aarch64/action.yml @@ -16,6 +16,9 @@ inputs: required: false description: the cmd to run default: make + setup: + required: false + description: the host setup cmd to run runs: using: composite @@ -27,10 +30,13 @@ runs: with: arch: aarch64 distro: ${{ inputs.distro }} - env: + setup: ${{ inputs.setup }} + env: | CC: ${{ inputs.compiler }} LD_LIBRARY_PATH: /usr/lib:/usr/local/lib RUN: ${{ inputs.run }} + ${{ inputs.env }} + install: | case "${{ inputs.distro }}" in ubuntu*|jessie|stretch|buster) @@ -38,12 +44,14 @@ runs: apt install -q -y build-essential ;; esac + run: | cc --version git clone https://github.com/Conni2461/examiner env -C examiner \ - make && sudo make install + { make && sudo make install } + + ${{env.RUN}} - ${{env.RUN}} \ No newline at end of file From 9eb5b3bce3a4acd649bb672c6a9321337f3ea3dc Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Mon, 3 Apr 2023 17:56:56 +0930 Subject: [PATCH 31/60] let the run on arch always setup for artifacts --- .github/actions/compile-unix-arm64/action.yml | 2 -- .../actions/compile-unix-x86_64/action.yml | 4 ++-- .../actions/run-on-linux-aarch64/action.yml | 19 ++++++++++++++----- .github/workflows/ci.yml | 4 ++-- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/actions/compile-unix-arm64/action.yml b/.github/actions/compile-unix-arm64/action.yml index a37a76e..8e54522 100644 --- a/.github/actions/compile-unix-arm64/action.yml +++ b/.github/actions/compile-unix-arm64/action.yml @@ -22,8 +22,6 @@ runs: with: distro: ${{ inputs.distro }} compiler: ${{ inputs.compiler }} - setup: | - mkdir -p "${PWD}/artifacts" run: | make && sudo make install diff --git a/.github/actions/compile-unix-x86_64/action.yml b/.github/actions/compile-unix-x86_64/action.yml index 2c22938..ad57785 100644 --- a/.github/actions/compile-unix-x86_64/action.yml +++ b/.github/actions/compile-unix-x86_64/action.yml @@ -20,8 +20,8 @@ runs: run: | cc --version git clone https://github.com/Conni2461/examiner - env -C examiner \ - { make && sudo make install } + cd examiner + make && sudo make install - name: Build env: diff --git a/.github/actions/run-on-linux-aarch64/action.yml b/.github/actions/run-on-linux-aarch64/action.yml index 7a50231..0dfe4a1 100644 --- a/.github/actions/run-on-linux-aarch64/action.yml +++ b/.github/actions/run-on-linux-aarch64/action.yml @@ -30,7 +30,15 @@ runs: with: arch: aarch64 distro: ${{ inputs.distro }} - setup: ${{ inputs.setup }} + + # Create an artifacts directory + setup: | + mkdir -p "${PWD}/artifacts" + + # Mount the artifacts directory as /artifacts in the container + dockerRunArgs: | + --volume "${PWD}/artifacts:/artifacts" + env: | CC: ${{ inputs.compiler }} LD_LIBRARY_PATH: /usr/lib:/usr/local/lib @@ -48,10 +56,11 @@ runs: run: | cc --version - git clone https://github.com/Conni2461/examiner - - env -C examiner \ - { make && sudo make install } + git clone https://github.com/Conni2461/examiner; + + cd examiner; + make && sudo make install; + cd .. ${{env.RUN}} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb0dbd8..37c0036 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,9 +30,9 @@ jobs: strategy: matrix: include: - - os: ubuntu-22.04 + - os: ubuntu22.04 compiler: gcc - - os: ubuntu-22.04 + - os: ubuntu22.04 compiler: clang runs-on: ${{ matrix.os }} From 34c1daa568b49926a625aa30bdafd9f94f177efe Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Mon, 3 Apr 2023 18:08:39 +0930 Subject: [PATCH 32/60] runs-on-arch has different os names to github runson --- .github/actions/run-on-linux-aarch64/action.yml | 8 ++++---- .github/actions/unittest-unix-arm64/action.yml | 6 +++--- .github/workflows/ci.yml | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/actions/run-on-linux-aarch64/action.yml b/.github/actions/run-on-linux-aarch64/action.yml index 0dfe4a1..422c66a 100644 --- a/.github/actions/run-on-linux-aarch64/action.yml +++ b/.github/actions/run-on-linux-aarch64/action.yml @@ -8,9 +8,9 @@ inputs: compiler: required: true description: Compiler to use - distro: + dockerimage: required: false - description: the base os to run in arm64 mode + description: "the base os image to run in arm64 mode. see https://github.com/uraimo/run-on-arch-action#supported-platforms" default: ubuntu20-04 run: required: false @@ -29,7 +29,7 @@ runs: # see: https://github.com/uraimo/run-on-arch-action#usage with: arch: aarch64 - distro: ${{ inputs.distro }} + distro: ${{ inputs.dockerimage }} # Create an artifacts directory setup: | @@ -46,7 +46,7 @@ runs: ${{ inputs.env }} install: | - case "${{ inputs.distro }}" in + case "${{ inputs.dockerimage }}" in ubuntu*|jessie|stretch|buster) apt update -q -y apt install -q -y build-essential diff --git a/.github/actions/unittest-unix-arm64/action.yml b/.github/actions/unittest-unix-arm64/action.yml index 5af202f..d0bc24b 100644 --- a/.github/actions/unittest-unix-arm64/action.yml +++ b/.github/actions/unittest-unix-arm64/action.yml @@ -8,9 +8,9 @@ inputs: compiler: required: true description: Compiler to use - distro: + dockerimage: required: false - description: the base os to run in arm64 mode + description: "the base os image to run in arm64 mode. see https://github.com/uraimo/run-on-arch-action#supported-platforms" default: ubuntu20-04 runs: @@ -20,7 +20,7 @@ runs: - name: Compile uses: ./.github/actions/run-on-linux-aarch64 with: - distro: ${{ inputs.distro }} + dockerimage: ${{ inputs.dockerimage }} compiler: ${{ inputs.compiler }} run: make test diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37c0036..a097c84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,18 +30,18 @@ jobs: strategy: matrix: include: - - os: ubuntu22.04 + - dockerimage: ubuntu22.04 compiler: gcc - - os: ubuntu22.04 + - dockerimage: ubuntu22.04 compiler: clang - runs-on: ${{ matrix.os }} + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - uses: ./.github/actions/unittest-unix-arm64 with: compiler: ${{ matrix.compiler }} - distro: ${{ matrix.os }} + dockerimage: ${{ matrix.dockerimage }} unittest_macosx_x86_64: name: unittests-macosx-x86_64 From 93dd3768f3343080fc21cda544f5b6cdb4ed8133 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Mon, 3 Apr 2023 18:25:30 +0930 Subject: [PATCH 33/60] aarch64.ubuntu22.04 only exists on v2.5.0 --- .github/actions/run-on-linux-aarch64/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/run-on-linux-aarch64/action.yml b/.github/actions/run-on-linux-aarch64/action.yml index 422c66a..f1079dd 100644 --- a/.github/actions/run-on-linux-aarch64/action.yml +++ b/.github/actions/run-on-linux-aarch64/action.yml @@ -25,7 +25,7 @@ runs: steps: - name: Prepare - uses: uraimo/run-on-arch-action@v2.0.5 + uses: uraimo/run-on-arch-action@v2.5.0 # see: https://github.com/uraimo/run-on-arch-action#usage with: arch: aarch64 From b2a0149eb8ffb3aacfe58ad8ed5a64ac33c00a82 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Mon, 3 Apr 2023 19:14:29 +0930 Subject: [PATCH 34/60] add git --- .github/actions/run-on-linux-aarch64/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/run-on-linux-aarch64/action.yml b/.github/actions/run-on-linux-aarch64/action.yml index f1079dd..30e5538 100644 --- a/.github/actions/run-on-linux-aarch64/action.yml +++ b/.github/actions/run-on-linux-aarch64/action.yml @@ -49,7 +49,7 @@ runs: case "${{ inputs.dockerimage }}" in ubuntu*|jessie|stretch|buster) apt update -q -y - apt install -q -y build-essential + apt install -q -y build-essential git ;; esac From aee56a77d81fe5c142541248bf0203c8bceca138 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Mon, 3 Apr 2023 20:34:06 +0930 Subject: [PATCH 35/60] dont need sudo in the container, already root --- .github/actions/compile-unix-arm64/action.yml | 2 +- .github/actions/run-on-linux-aarch64/action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/compile-unix-arm64/action.yml b/.github/actions/compile-unix-arm64/action.yml index 8e54522..6061cab 100644 --- a/.github/actions/compile-unix-arm64/action.yml +++ b/.github/actions/compile-unix-arm64/action.yml @@ -24,7 +24,7 @@ runs: compiler: ${{ inputs.compiler }} run: | - make && sudo make install + make && make install # Produce a binary artifact and place it in the mounted volume cp ./build/* /artifacts/ diff --git a/.github/actions/run-on-linux-aarch64/action.yml b/.github/actions/run-on-linux-aarch64/action.yml index 30e5538..43857f0 100644 --- a/.github/actions/run-on-linux-aarch64/action.yml +++ b/.github/actions/run-on-linux-aarch64/action.yml @@ -59,7 +59,7 @@ runs: git clone https://github.com/Conni2461/examiner; cd examiner; - make && sudo make install; + make && make install; cd .. ${{env.RUN}} From 88da04f2ea2be772c009a736d1df2a2b2b52d444 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 01:09:33 +0930 Subject: [PATCH 36/60] jit.arch gives osx, windows and linux --- .../action.yml | 0 .../action.yml | 4 +- .../action.yml | 4 +- .../action.yml | 4 +- .../action.yml | 6 +-- .../action.yml | 6 +-- .github/workflows/release.yml | 38 +++++++------- README.md | 32 ++++++------ lua/telescope-fzf-native/download_library.lua | 49 +++++++++---------- 9 files changed, 67 insertions(+), 76 deletions(-) rename .github/actions/{compile-unix-arm64 => compile-unix-arm}/action.yml (100%) rename .github/actions/{compile-unix-x86_64 => compile-unix-x64}/action.yml (85%) rename .github/actions/{compile-windows-x86_64 => compile-windows-x64}/action.yml (82%) rename .github/actions/{e2etest-unix-x86_64 => e2etest-unix-x64}/action.yml (92%) rename .github/actions/{unittest-unix-arm64 => unittest-unix-arm}/action.yml (64%) rename .github/actions/{unittest-unix-x86_64 => unittest-unix-x64}/action.yml (70%) diff --git a/.github/actions/compile-unix-arm64/action.yml b/.github/actions/compile-unix-arm/action.yml similarity index 100% rename from .github/actions/compile-unix-arm64/action.yml rename to .github/actions/compile-unix-arm/action.yml diff --git a/.github/actions/compile-unix-x86_64/action.yml b/.github/actions/compile-unix-x64/action.yml similarity index 85% rename from .github/actions/compile-unix-x86_64/action.yml rename to .github/actions/compile-unix-x64/action.yml index ad57785..81c824e 100644 --- a/.github/actions/compile-unix-x86_64/action.yml +++ b/.github/actions/compile-unix-x64/action.yml @@ -1,8 +1,8 @@ --- -name: Compile Unix Library (x86_64) +name: Compile Unix Library (x64) description: | - Prepare and compile unix builds for x86_64 cpus + Prepare and compile unix builds for x64 cpus inputs: compiler: diff --git a/.github/actions/compile-windows-x86_64/action.yml b/.github/actions/compile-windows-x64/action.yml similarity index 82% rename from .github/actions/compile-windows-x86_64/action.yml rename to .github/actions/compile-windows-x64/action.yml index d9b79a3..0acf00e 100644 --- a/.github/actions/compile-windows-x86_64/action.yml +++ b/.github/actions/compile-windows-x64/action.yml @@ -1,8 +1,8 @@ --- -name: Compile windows library (x86_64) +name: Compile windows library (x64) description: | - Prepare and compile a windows build for x86_64 cpus + Prepare and compile a windows build for x64 cpus runs: diff --git a/.github/actions/e2etest-unix-x86_64/action.yml b/.github/actions/e2etest-unix-x64/action.yml similarity index 92% rename from .github/actions/e2etest-unix-x86_64/action.yml rename to .github/actions/e2etest-unix-x64/action.yml index d184ac7..130752d 100644 --- a/.github/actions/e2etest-unix-x86_64/action.yml +++ b/.github/actions/e2etest-unix-x64/action.yml @@ -1,8 +1,8 @@ --- -name: Unit Test Unix Library (arm64) +name: Unit Test Unix Library (arm) description: | - Run some e2e neovim tests for unix on arm64 cpus + Run some e2e neovim tests for unix on arm cpus inputs: os: diff --git a/.github/actions/unittest-unix-arm64/action.yml b/.github/actions/unittest-unix-arm/action.yml similarity index 64% rename from .github/actions/unittest-unix-arm64/action.yml rename to .github/actions/unittest-unix-arm/action.yml index d0bc24b..6928ce4 100644 --- a/.github/actions/unittest-unix-arm64/action.yml +++ b/.github/actions/unittest-unix-arm/action.yml @@ -1,8 +1,8 @@ --- -name: Compile Unix Library (arm64) +name: Compile Unix Library (arm) description: | - Prepare and compile unix builds for arm64 cpus + Prepare and compile unix builds for arm cpus inputs: compiler: @@ -10,7 +10,7 @@ inputs: description: Compiler to use dockerimage: required: false - description: "the base os image to run in arm64 mode. see https://github.com/uraimo/run-on-arch-action#supported-platforms" + description: "the base os image to run in aarch64 mode. see https://github.com/uraimo/run-on-arch-action#supported-platforms" default: ubuntu20-04 runs: diff --git a/.github/actions/unittest-unix-x86_64/action.yml b/.github/actions/unittest-unix-x64/action.yml similarity index 70% rename from .github/actions/unittest-unix-x86_64/action.yml rename to .github/actions/unittest-unix-x64/action.yml index 9a2940d..1de7fbf 100644 --- a/.github/actions/unittest-unix-x86_64/action.yml +++ b/.github/actions/unittest-unix-x64/action.yml @@ -1,8 +1,8 @@ --- -name: Unit Test Unix Library (x86_64) +name: Unit Test Unix Library (x64) description: | - Compile and test a unix build on unix for x86_64 cpus + Compile and test a unix build on unix for x64 cpus inputs: compiler: @@ -13,7 +13,7 @@ inputs: runs: using: composite steps: - - uses: ./.github/actions/compile-unix-x86_64 + - uses: ./.github/actions/compile-unix-x64 with: compiler: ${{ inputs.compiler }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 83cb1b0..9c93876 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ concurrency: cancel-in-progress: true jobs: - linux_x86_64: + linux_x64: name: make-linux-binaries strategy: @@ -31,16 +31,16 @@ jobs: - uses: actions/checkout@v3 - - uses: ./.github/actions/compile-unix-x86_64 + - uses: ./.github/actions/compile-unix-x64 with: compiler: ${{ matrix.compiler }} - uses: actions/upload-artifact@v3 with: - name: ${{ matrix.platform }}-x86_64-${{ matrix.compiler }} + name: ${{ matrix.platform }}-x64-${{ matrix.compiler }} path: build/*.so - linux_arm64: + linux_arm: name: make-linux-binaries strategy: @@ -66,20 +66,20 @@ jobs: - uses: actions/upload-artifact@v3 with: - name: ${{ matrix.platform }}-arm64-${{ matrix.compiler }} + name: ${{ matrix.platform }}-arm-${{ matrix.compiler }} path: build/*.so - macos_x86_64: - name: make-macos-binaries + osx_64: + name: make-osx_x64-binaries strategy: matrix: include: - os: macos-12 - platform: macos + platform: osx compiler: gcc - os: macos-12 - platform: macos + platform: osx compiler: clang runs-on: ${{ matrix.os }} @@ -94,18 +94,18 @@ jobs: - uses: actions/upload-artifact@v3 with: - name: ${{ matrix.platform }}-x86_64-${{ matrix.compiler }} + name: ${{ matrix.platform }}-x64-${{ matrix.compiler }} path: build/*.so - windows_x86_64: - name: make-windows-binaries + windows_x64: + name: make-windows_x64-binaries strategy: matrix: include: # TODO: add in clang build too ? - os: windows-2019 - platform: win32 + platform: windows compiler: cc runs-on: ${{ matrix.os }} @@ -113,19 +113,19 @@ jobs: - uses: actions/checkout@v3 - - uses: ./.github/actions/compile-windows-x86_64 + - uses: ./.github/actions/compile-windows-x64 - uses: actions/upload-artifact@v3 with: - name: ${{ matrix.platform }}-x86_64-${{ matrix.compiler }} + name: ${{ matrix.platform }}-x64-${{ matrix.compiler }} path: build/*.dll release: needs: - - linux_x86_64 - - linux_arm64 - - macos_x86_64 - - windows_x86_64 + - linux_x64 + - linux_arm + - osx_x64 + - windows_x64 name: upload-binaries-to-release-page diff --git a/README.md b/README.md index f472c21..bbaa1c2 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ A single bar character term acts as an OR operator. For example, the following query matches entries that start with `core` and end with either `go`, `rb`, or `py`. -``` +```vim ^core go$ | rb$ | py$ ``` @@ -31,7 +31,6 @@ available for telescope (as native component or as lua component). `telescope-fzf-native` is mostly a native binary, you'll need to either download our prebuilt binary or build it yourself. - ### Prebuilt binaries You can either : @@ -39,7 +38,6 @@ You can either : - head over to our releases page for the version you want, download it and depending on your platform, put it into the `build` directory as either `libfzf.so` or `libfzf.dll`. - Use the downloader in a postinstall step as demostrated below - ```lua use { 'nvim-telescope/telescope-fzf-native.nvim', @@ -56,7 +54,6 @@ For other package managers, you'll want to look at the postinstall step: - [`lazy.nvim`](https://github.com/folke/lazy.nvim) will want you to use `build` - [`vimplug`](https://github.com/junegunn/vim-plug) will probably want some kind `do` involving `:lua` :shrug: - ```vim Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': ':lua require("telescope-fzf-native").download_library()' @@ -65,12 +62,20 @@ Plug 'nvim-telescope/telescope-fzf-native.nvim', { ### download options +> 🤚 Note +> +> You'll need to have both `curl` and `sh` shell installed. +> +> On windows, this is done by installing git, and on linux and mac this should already be solved. +> Technically speaking this shouldn't be a problem because most neovim plugin managers encourage git to be present. + ```lua use { 'nvim-telescope/telescope-fzf-native.nvim', run = function() require('telescope-fzf-native').download_library({ platform = 'windows' -- windows | ubuntu | macos + arch = 'x86_64', -- x86_64 | arm64 compiler = 'cc', -- windows: cc, unix: gcc | clang version = 'latest' -- any release name found on our github releases page }) @@ -78,14 +83,6 @@ use { } ``` -> 🤚 Note -> -> You'll need to have both `curl` and `sh` shell installed. -> -> On windows, this is done by installing git, and on linux and mac this should already be solved. - - - ## Building yourself If you want to build **fzf-native** yourself, you will need either `cmake` or `make`. @@ -97,14 +94,13 @@ This requires: - CMake, and the Microsoft C++ Build Tools (vcc) on Windows - CMake, make, and GCC or Clang on Linux and MacOS -#### vim-plug +#### vim-plug using cmake ```viml Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } ``` -#### packer.nvim - +#### packer.nvim with cmake ```lua use {'nvim-telescope/telescope-fzf-native.nvim', run = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } @@ -114,19 +110,19 @@ use {'nvim-telescope/telescope-fzf-native.nvim', run = 'cmake -S. -Bbuild -DCMAK This requires `gcc` or `clang` and `make` -#### vim-plug +#### vim-plug with gcc ```viml Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' } ``` -#### packer.nvim +#### packer.nvim with gcc ```lua use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make' } ``` -## Telescope Setup and Configuration: +## Telescope Setup and Configuration ```lua -- You dont need to set any of these options. These are the default ones. Only diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index 4c3a5a6..bdef2f0 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -2,17 +2,24 @@ local uv = vim.loop local plugin_path = string.sub(debug.getinfo(1).source, 2, #"//lua/telescope-fzf-native/download_library.lua" * -1) local releases_url = "https://github.com/airtonix/telescope-fzf-native.nvim/releases/download" - local get_valid_compiler = function(platform) if platform == "windows" then return "cc" - elseif platform == "macos" then + elseif platform == "osx" then return "gcc" elseif platform == "linux" then return "gcc" end end +local get_valid_filename = function(platform) + if platform == "windows" then + return "libfzf.dll" + else + return "libfzf.so" + end +end + local spawn = function(cmd, on_exit) local stdout = uv.new_pipe() @@ -49,20 +56,24 @@ end -- Reminder: -- -- The filenames to download are defined as a side effect of the --- matrix build names in `.github/actions/compile-unix/action.yml` and --- `.github/actions/compile-windows/action.yml`, then also due to how +-- names used in the artifact upload steps in `.github/workflow/release.yml` and how -- `.github/actions/prepare-artifacts/action.yml` downloads the artifacts -- before uploading as releases. -- -- The filename pattern is generally: -- --- mac and linux: {github-runner-osname}-{compiler}/libfzf.so --- windows: {github-runner-osname}-{compiler}/libfzf.dll +-- linux-x64-{compiler}/libfzf.so +-- linux-arm-{compiler}/libfzf.so +-- osx-x64-{compiler}/libfzf.so +-- windows-x64-{compiler}/libfzf.dll -- -- Files in a github release are required to be unique per filename, so we -- mutate the above downloaded artifacts into: -- --- {github-runner-osname}-{compiler}-libfzf.{type} +-- linux-x64-{compiler}-libfzf.so +-- linux-arm-{compiler}-libfzf.so +-- osx-x64-{compiler}-libfzf.so +-- windows-x64-{compiler}-libfzf.dll -- -- This downloader then can pick the right binary and save it the users -- local disk as `libfzf.so` or `libfzf.dll` @@ -76,23 +87,9 @@ return function(options) local path_separator = (platform == "windows") and "\\" or "/" local build_path = table.concat({ plugin_path, "build" }, path_separator) - local download_file = nil - local binary_file = nil + local binary_file = get_valid_filename(platform) - if platform == "windows" then - download_file = string.format("win32-%s-libfzf.dll", compiler) - binary_file = "libfzf.dll" - end - - if platform == "linux" then - download_file = string.format("linux-%s-libfzf.so", compiler) - binary_file = "libfzf.so" - end - - if platform == "macos" then - download_file = string.format("macos-%s-libfzf.so", compiler) - binary_file = "libfzf.so" - end + local download_file = table.concat({platform, arch, compiler, binary_file}, "-") -- Ensure the Build directory exists uv.fs_mkdir(build_path, 511) @@ -105,9 +102,7 @@ return function(options) -- Curl the download spawn { "curl", - "-L", - source, - "-o", - target, + "-L", source, + "-o", target, } end From b093f23256d8dfe6e1c538e77f8cc718a002c02b Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 01:11:43 +0930 Subject: [PATCH 37/60] ensure platform and arch are lowercase --- lua/telescope-fzf-native/download_library.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index bdef2f0..fe2cd3e 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -80,10 +80,10 @@ end -- return function(options) options = options or {} - local platform = options.platform or jit.os - local arch = options.arch or jit.arch - local compiler = options.compiler or get_valid_compiler(platform) - local version = options.version or "dev" + local platform = string.lower(options.platform or jit.os) + local arch = string.lower(options.arch or jit.arch) + local compiler = string.lower(options.compiler or get_valid_compiler(platform)) + local version = string.lower(options.version or "dev") local path_separator = (platform == "windows") and "\\" or "/" local build_path = table.concat({ plugin_path, "build" }, path_separator) From f82726362daed8a065e76e9af84669654238853f Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 01:36:39 +0930 Subject: [PATCH 38/60] these dont need to be vars now --- .../{compile-unix-arm => compile-linux-arm}/action.yml | 4 ++-- .github/workflows/release.yml | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) rename .github/actions/{compile-unix-arm => compile-linux-arm}/action.yml (90%) diff --git a/.github/actions/compile-unix-arm/action.yml b/.github/actions/compile-linux-arm/action.yml similarity index 90% rename from .github/actions/compile-unix-arm/action.yml rename to .github/actions/compile-linux-arm/action.yml index 6061cab..16f57f9 100644 --- a/.github/actions/compile-unix-arm/action.yml +++ b/.github/actions/compile-linux-arm/action.yml @@ -1,8 +1,8 @@ --- -name: Compile Unix Library (arm64) +name: Compile Linux Library (arm) description: | - Prepare and compile unix builds for arm64 cpus + Prepare and compile linux builds for arm cpus inputs: compiler: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9c93876..f2d953c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,10 +47,8 @@ jobs: matrix: include: - os: ubuntu-22.04 - platform: linux compiler: gcc - os: ubuntu-22.04 - platform: linux compiler: clang runs-on: ${{ matrix.os }} @@ -59,14 +57,14 @@ jobs: - uses: actions/checkout@v3 - - uses: ./.github/actions/compile-unix-arm64 + - uses: ./.github/actions/compile-linux-arm with: compiler: ${{ matrix.compiler }} distro: ${{ matrix.os }} - uses: actions/upload-artifact@v3 with: - name: ${{ matrix.platform }}-arm-${{ matrix.compiler }} + name: linux-arm-${{ matrix.compiler }} path: build/*.so osx_64: From 6e84d8617ec56d656ff70bfd4bfcfb2d22fecf8f Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 11:14:36 +0930 Subject: [PATCH 39/60] ci jobs need to point to new action names --- .github/workflows/ci.yml | 52 ++++++++++++++++++----------------- .github/workflows/release.yml | 14 +++------- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a097c84..cbbb28a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,9 +7,13 @@ concurrency: cancel-in-progress: true +# Linux and Osx build definitions are separate, because they can involve +# sufficiently different requirements as projects evolve that abstracting +# them into one single action would just create complexity. #aha #wet + jobs: - unittest_linux_x86_64: - name: unittest-linux-x86_64 + unittest_linux_x64: + name: unittest-linux-x64 strategy: matrix: include: @@ -21,12 +25,12 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - uses: ./.github/actions/unittest-unix-x86_64 + - uses: ./.github/actions/unittest-unix-x64 with: compiler: ${{ matrix.compiler }} - unittest_linux_arm64: - name: unittest-linux-arm64 + unittest_linux_arm: + name: unittest-linux-arm strategy: matrix: include: @@ -35,40 +39,40 @@ jobs: - dockerimage: ubuntu22.04 compiler: clang + # when running arm jobs, we want a linux host. + # the real environment is defined by dockerimage runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - - uses: ./.github/actions/unittest-unix-arm64 + - uses: ./.github/actions/unittest-unix-arm with: compiler: ${{ matrix.compiler }} dockerimage: ${{ matrix.dockerimage }} - unittest_macosx_x86_64: - name: unittests-macosx-x86_64 + unittest_macosx_x64: + name: unittests-macosx-x64 strategy: matrix: include: - - os: macos-12 - compiler: gcc - - os: macos-12 - compiler: clang + - compiler: gcc + - compiler: clang - runs-on: ${{ matrix.os }} + runs-on: macos-12 steps: - uses: actions/checkout@v3 - - uses: ./.github/actions/unittest-unix-x86_64 + - uses: ./.github/actions/unittest-unix-x64 with: compiler: ${{ matrix.compiler }} - unittest_windows_x86_64: - name: unittest-windows-x86_64 + unittest_windows_x64: + name: unittest-windows-x64 runs-on: windows-2019 steps: - uses: actions/checkout@v3 - - uses: ./.github/actions/compile-windows-x86_64 + - uses: ./.github/actions/compile-windows-x64 - e2etest_linux_x86_64: - name: e2etest-linux-x86_64 + e2etest_linux_x64: + name: e2etest-linux-x64 strategy: matrix: include: @@ -78,13 +82,12 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - uses: ./.github/actions/e2etest-unix-x86_64 + - uses: ./.github/actions/e2etest-unix-x64 with: - os: ${{ matrix.os }} url: ${{ matrix.url }} - e2etest_macos_x86_64: - name: e2etest-macos-x86_64 + e2etest_macos_x64: + name: e2etest-macos-x64 strategy: matrix: include: @@ -94,8 +97,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - uses: ./.github/actions/e2etest-unix-x86_64 + - uses: ./.github/actions/e2etest-unix-x64 with: - os: ${{ matrix.os }} url: ${{ matrix.url }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f2d953c..4050cbc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,10 +19,8 @@ jobs: matrix: include: - os: ubuntu-22.04 - platform: linux compiler: gcc - os: ubuntu-22.04 - platform: linux compiler: clang runs-on: ${{ matrix.os }} @@ -37,7 +35,7 @@ jobs: - uses: actions/upload-artifact@v3 with: - name: ${{ matrix.platform }}-x64-${{ matrix.compiler }} + name: linux-x64-${{ matrix.compiler }} path: build/*.so linux_arm: @@ -74,10 +72,8 @@ jobs: matrix: include: - os: macos-12 - platform: osx compiler: gcc - os: macos-12 - platform: osx compiler: clang runs-on: ${{ matrix.os }} @@ -86,13 +82,13 @@ jobs: - uses: actions/checkout@v3 - - uses: ./.github/actions/compile-unix-x86_64 + - uses: ./.github/actions/compile-unix-64 with: compiler: ${{ matrix.compiler }} - uses: actions/upload-artifact@v3 with: - name: ${{ matrix.platform }}-x64-${{ matrix.compiler }} + name: osx-x64-${{ matrix.compiler }} path: build/*.so windows_x64: @@ -101,9 +97,7 @@ jobs: strategy: matrix: include: - # TODO: add in clang build too ? - os: windows-2019 - platform: windows compiler: cc runs-on: ${{ matrix.os }} @@ -115,7 +109,7 @@ jobs: - uses: actions/upload-artifact@v3 with: - name: ${{ matrix.platform }}-x64-${{ matrix.compiler }} + name: windows-x64-${{ matrix.compiler }} path: build/*.dll release: From 7157cf0f306f6d77fe205280c12a1785875e2776 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 11:22:22 +0930 Subject: [PATCH 40/60] job name should be consistent with other jobnames --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4050cbc..f7a0599 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -65,7 +65,7 @@ jobs: name: linux-arm-${{ matrix.compiler }} path: build/*.so - osx_64: + osx_x64: name: make-osx_x64-binaries strategy: From 6db4fda793f0c1cf451e2de4fa19ff3d8451dffd Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 11:32:25 +0930 Subject: [PATCH 41/60] same compile action inputs as test action --- .github/actions/compile-linux-arm/action.yml | 6 +++--- .github/actions/run-on-linux-aarch64/action.yml | 4 ++++ .github/actions/unittest-unix-arm/action.yml | 4 ++-- .github/workflows/release.yml | 8 ++++---- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/actions/compile-linux-arm/action.yml b/.github/actions/compile-linux-arm/action.yml index 16f57f9..0118320 100644 --- a/.github/actions/compile-linux-arm/action.yml +++ b/.github/actions/compile-linux-arm/action.yml @@ -8,9 +8,9 @@ inputs: compiler: required: true description: Compiler to use - distro: + dockerimage: required: false - description: the base os to run in arm64 mode + description: "the base os image to run in aarch64 mode. see https://github.com/uraimo/run-on-arch-action#supported-platforms" default: ubuntu20-04 runs: @@ -20,7 +20,7 @@ runs: - name: Compile uses: ./.github/actions/run-on-linux-aarch64 with: - distro: ${{ inputs.distro }} + dockerimage: ${{ inputs.dockerimage }} compiler: ${{ inputs.compiler }} run: | diff --git a/.github/actions/run-on-linux-aarch64/action.yml b/.github/actions/run-on-linux-aarch64/action.yml index 43857f0..f9e95d4 100644 --- a/.github/actions/run-on-linux-aarch64/action.yml +++ b/.github/actions/run-on-linux-aarch64/action.yml @@ -51,6 +51,10 @@ runs: apt update -q -y apt install -q -y build-essential git ;; + fedora*) + dnf update -q -y + sudo dnf install make automake gcc gcc-c++ kernel-devel git + ;; esac run: | diff --git a/.github/actions/unittest-unix-arm/action.yml b/.github/actions/unittest-unix-arm/action.yml index 6928ce4..ad7ff41 100644 --- a/.github/actions/unittest-unix-arm/action.yml +++ b/.github/actions/unittest-unix-arm/action.yml @@ -1,8 +1,8 @@ --- -name: Compile Unix Library (arm) +name: Unit Test Linux Library (arm) description: | - Prepare and compile unix builds for arm cpus + Compile and unit test linux builds for arm cpus inputs: compiler: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f7a0599..2329af7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,12 +44,12 @@ jobs: strategy: matrix: include: - - os: ubuntu-22.04 + - dockerimage: ubuntu22.04 compiler: gcc - - os: ubuntu-22.04 + - dockerimage: ubuntu22.04 compiler: clang - runs-on: ${{ matrix.os }} + runs-on: ubuntu-22.04 steps: @@ -58,7 +58,7 @@ jobs: - uses: ./.github/actions/compile-linux-arm with: compiler: ${{ matrix.compiler }} - distro: ${{ matrix.os }} + dockerimage: ${{ matrix.dockerimage }} - uses: actions/upload-artifact@v3 with: From 22795a0d254034f4b15db33d866e6bbf38e00dbb Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 11:33:49 +0930 Subject: [PATCH 42/60] action name has x64 not just 64 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2329af7..4e7b213 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,7 +82,7 @@ jobs: - uses: actions/checkout@v3 - - uses: ./.github/actions/compile-unix-64 + - uses: ./.github/actions/compile-unix-x64 with: compiler: ${{ matrix.compiler }} From acc701492f498c921f912cd43e57d5ada57cdef8 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 11:41:39 +0930 Subject: [PATCH 43/60] handle injected yaml multiline vars --- .github/actions/compile-linux-arm/action.yml | 6 +++--- .github/actions/run-on-linux-aarch64/action.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/actions/compile-linux-arm/action.yml b/.github/actions/compile-linux-arm/action.yml index 0118320..3d14f23 100644 --- a/.github/actions/compile-linux-arm/action.yml +++ b/.github/actions/compile-linux-arm/action.yml @@ -23,9 +23,9 @@ runs: dockerimage: ${{ inputs.dockerimage }} compiler: ${{ inputs.compiler }} - run: | - make && make install - # Produce a binary artifact and place it in the mounted volume + # Produce a binary artifact and place it in the mounted volume + run: >- + make && make install; cp ./build/* /artifacts/ - name: Show the artifact diff --git a/.github/actions/run-on-linux-aarch64/action.yml b/.github/actions/run-on-linux-aarch64/action.yml index f9e95d4..d7f9794 100644 --- a/.github/actions/run-on-linux-aarch64/action.yml +++ b/.github/actions/run-on-linux-aarch64/action.yml @@ -14,7 +14,7 @@ inputs: default: ubuntu20-04 run: required: false - description: the cmd to run + description: the cmd to run. multiline strings MUST use chomp mode ">-" and mark end of line with ";" default: make setup: required: false From 40fab2d5ec938cabc25dd5b95bb4a0e1cf67f880 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 11:46:08 +0930 Subject: [PATCH 44/60] ensure arm and x64 linux jobs are identifiable --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4e7b213..c116cbf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ concurrency: jobs: linux_x64: - name: make-linux-binaries + name: make-linux_x64-binaries strategy: matrix: @@ -39,7 +39,7 @@ jobs: path: build/*.so linux_arm: - name: make-linux-binaries + name: make-linux_arm-binaries strategy: matrix: From ba9f1e03b966ca433310ed809d43a822b8d653b8 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 12:51:45 +0930 Subject: [PATCH 45/60] linting --- lua/telescope-fzf-native/download_library.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index fe2cd3e..9629dc2 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -89,7 +89,7 @@ return function(options) local build_path = table.concat({ plugin_path, "build" }, path_separator) local binary_file = get_valid_filename(platform) - local download_file = table.concat({platform, arch, compiler, binary_file}, "-") + local download_file = table.concat({ platform, arch, compiler, binary_file }, "-") -- Ensure the Build directory exists uv.fs_mkdir(build_path, 511) @@ -102,7 +102,9 @@ return function(options) -- Curl the download spawn { "curl", - "-L", source, - "-o", target, + "-L", + source, + "-o", + target, } end From 6e9ad3973569bb766563cf846098c67fac84a6dd Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 13:10:54 +0930 Subject: [PATCH 46/60] cringe: pass inputs directingly into run. --- .github/actions/compile-linux-arm/action.yml | 12 +----------- .github/actions/run-on-linux-aarch64/action.yml | 11 +---------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/.github/actions/compile-linux-arm/action.yml b/.github/actions/compile-linux-arm/action.yml index 3d14f23..bc1214a 100644 --- a/.github/actions/compile-linux-arm/action.yml +++ b/.github/actions/compile-linux-arm/action.yml @@ -24,14 +24,4 @@ runs: compiler: ${{ inputs.compiler }} # Produce a binary artifact and place it in the mounted volume - run: >- - make && make install; - cp ./build/* /artifacts/ - - - name: Show the artifact - # Items placed in /artifacts in the container will be in - # ${PWD}/artifacts on the host.\ - shell: bash - run: | - echo "Produced artifact at" - ls -al "${PWD}/artifacts" \ No newline at end of file + run: make && make install; diff --git a/.github/actions/run-on-linux-aarch64/action.yml b/.github/actions/run-on-linux-aarch64/action.yml index d7f9794..e9b6aca 100644 --- a/.github/actions/run-on-linux-aarch64/action.yml +++ b/.github/actions/run-on-linux-aarch64/action.yml @@ -30,19 +30,10 @@ runs: with: arch: aarch64 distro: ${{ inputs.dockerimage }} - - # Create an artifacts directory - setup: | - mkdir -p "${PWD}/artifacts" - - # Mount the artifacts directory as /artifacts in the container - dockerRunArgs: | - --volume "${PWD}/artifacts:/artifacts" env: | CC: ${{ inputs.compiler }} LD_LIBRARY_PATH: /usr/lib:/usr/local/lib - RUN: ${{ inputs.run }} ${{ inputs.env }} install: | @@ -66,5 +57,5 @@ runs: make && make install; cd .. - ${{env.RUN}} + ${{ inputs.run }} From 62d19fa4d8491f30ed6e7ca3844612f1fa28657d Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 13:53:46 +0930 Subject: [PATCH 47/60] need clang tooling --- .github/actions/run-on-linux-aarch64/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/run-on-linux-aarch64/action.yml b/.github/actions/run-on-linux-aarch64/action.yml index e9b6aca..0eab711 100644 --- a/.github/actions/run-on-linux-aarch64/action.yml +++ b/.github/actions/run-on-linux-aarch64/action.yml @@ -40,11 +40,11 @@ runs: case "${{ inputs.dockerimage }}" in ubuntu*|jessie|stretch|buster) apt update -q -y - apt install -q -y build-essential git + apt install -q -y build-essential git clang clang-format clang-tidy ;; fedora*) dnf update -q -y - sudo dnf install make automake gcc gcc-c++ kernel-devel git + sudo dnf install make automake gcc gcc-c++ kernel-devel git clang clang-format clang-tidy ;; esac From a6f681909d1b08c078160f19bd584375206240b4 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 14:38:42 +0930 Subject: [PATCH 48/60] we dont install, only build --- .github/actions/compile-linux-arm/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/compile-linux-arm/action.yml b/.github/actions/compile-linux-arm/action.yml index bc1214a..572e8e4 100644 --- a/.github/actions/compile-linux-arm/action.yml +++ b/.github/actions/compile-linux-arm/action.yml @@ -24,4 +24,4 @@ runs: compiler: ${{ inputs.compiler }} # Produce a binary artifact and place it in the mounted volume - run: make && make install; + run: make From 44dfb195c52aa271e6134bf7ea9d2510a6060914 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 15:34:38 +0930 Subject: [PATCH 49/60] download same release as plugin tag installed. --- lua/telescope-fzf-native/download_library.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index 9629dc2..4ea09b8 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -20,6 +20,19 @@ local get_valid_filename = function(platform) end end +-- a function that returns the current git tag, if an exception is thrown return "dev" +local get_current_version = function() + local ok, tag = pcall(function() + return vim.fn.system("git describe --tags --exact-match") + end) + + if ok then + return tag + end + + return "dev" +end + local spawn = function(cmd, on_exit) local stdout = uv.new_pipe() @@ -83,7 +96,7 @@ return function(options) local platform = string.lower(options.platform or jit.os) local arch = string.lower(options.arch or jit.arch) local compiler = string.lower(options.compiler or get_valid_compiler(platform)) - local version = string.lower(options.version or "dev") + local version = string.lower(options.version or get_current_version()) local path_separator = (platform == "windows") and "\\" or "/" local build_path = table.concat({ plugin_path, "build" }, path_separator) From d0ad36e688d1daa735bd580f0d225f3a53f8d315 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 15:40:57 +0930 Subject: [PATCH 50/60] linting --- lua/telescope-fzf-native/download_library.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index 4ea09b8..1639c78 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -23,7 +23,7 @@ end -- a function that returns the current git tag, if an exception is thrown return "dev" local get_current_version = function() local ok, tag = pcall(function() - return vim.fn.system("git describe --tags --exact-match") + return vim.fn.system "git describe --tags --exact-match" end) if ok then From 25934dd2d966e3dbb285ed93c7d9e4f585382959 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 18:52:21 +0930 Subject: [PATCH 51/60] set cwd so we get the right repo --- lua/telescope-fzf-native/download_library.lua | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index 1639c78..5e5949d 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -22,19 +22,14 @@ end -- a function that returns the current git tag, if an exception is thrown return "dev" local get_current_version = function() - local ok, tag = pcall(function() - return vim.fn.system "git describe --tags --exact-match" - end) - - if ok then - return tag - end - - return "dev" + local tag = spawn { "git", "describe", "--tags", "--exact-match" }, { cwd = plugin_path } + return tag or "dev" end -local spawn = function(cmd, on_exit) +local spawn = function(cmd, options) local stdout = uv.new_pipe() + local on_exit = options and options.on_exit + local cwd = options and options.cwd local buffer = "" @@ -43,6 +38,7 @@ local spawn = function(cmd, on_exit) uv.spawn(real_cmd, { args = cmd, stdio = { nil, stdout }, + cwd = cwd, verbatim = true, }, function() stdout:read_stop() From 33f55c6a790355349061e151e5df3520755ef4aa Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 19:06:44 +0930 Subject: [PATCH 52/60] remove clever stuff. --- lua/telescope-fzf-native/download_library.lua | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index 5e5949d..5a24a08 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -20,12 +20,6 @@ local get_valid_filename = function(platform) end end --- a function that returns the current git tag, if an exception is thrown return "dev" -local get_current_version = function() - local tag = spawn { "git", "describe", "--tags", "--exact-match" }, { cwd = plugin_path } - return tag or "dev" -end - local spawn = function(cmd, options) local stdout = uv.new_pipe() local on_exit = options and options.on_exit @@ -92,7 +86,7 @@ return function(options) local platform = string.lower(options.platform or jit.os) local arch = string.lower(options.arch or jit.arch) local compiler = string.lower(options.compiler or get_valid_compiler(platform)) - local version = string.lower(options.version or get_current_version()) + local version = string.lower(options.version or 'dev') local path_separator = (platform == "windows") and "\\" or "/" local build_path = table.concat({ plugin_path, "build" }, path_separator) From b1f4e8162998b57e10f58da049491dadd7ddae98 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 4 Apr 2023 20:28:31 +0930 Subject: [PATCH 53/60] linting --- lua/telescope-fzf-native/download_library.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/telescope-fzf-native/download_library.lua b/lua/telescope-fzf-native/download_library.lua index 5a24a08..6dd82cc 100644 --- a/lua/telescope-fzf-native/download_library.lua +++ b/lua/telescope-fzf-native/download_library.lua @@ -86,7 +86,7 @@ return function(options) local platform = string.lower(options.platform or jit.os) local arch = string.lower(options.arch or jit.arch) local compiler = string.lower(options.compiler or get_valid_compiler(platform)) - local version = string.lower(options.version or 'dev') + local version = string.lower(options.version or "dev") local path_separator = (platform == "windows") and "\\" or "/" local build_path = table.concat({ plugin_path, "build" }, path_separator) From e485866dbeed8343a64bda035055a585cde28bda Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Wed, 5 Apr 2023 07:48:26 +0930 Subject: [PATCH 54/60] update README --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bbaa1c2..fb85a21 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ A single bar character term acts as an OR operator. For example, the following query matches entries that start with `core` and end with either `go`, `rb`, or `py`. -```vim +```viml ^core go$ | rb$ | py$ ``` @@ -54,7 +54,7 @@ For other package managers, you'll want to look at the postinstall step: - [`lazy.nvim`](https://github.com/folke/lazy.nvim) will want you to use `build` - [`vimplug`](https://github.com/junegunn/vim-plug) will probably want some kind `do` involving `:lua` :shrug: -```vim +```viml Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': ':lua require("telescope-fzf-native").download_library()' } @@ -64,7 +64,7 @@ Plug 'nvim-telescope/telescope-fzf-native.nvim', { > 🤚 Note > -> You'll need to have both `curl` and `sh` shell installed. +> You'll need to have `curl` installed. > > On windows, this is done by installing git, and on linux and mac this should already be solved. > Technically speaking this shouldn't be a problem because most neovim plugin managers encourage git to be present. @@ -75,9 +75,9 @@ use { run = function() require('telescope-fzf-native').download_library({ platform = 'windows' -- windows | ubuntu | macos - arch = 'x86_64', -- x86_64 | arm64 + arch = 'x64', -- x64 | arm compiler = 'cc', -- windows: cc, unix: gcc | clang - version = 'latest' -- any release name found on our github releases page + version = '0.0.2' -- the release name found on our github releases page, defaults to "dev" }) end } From 047f5c440d1b34ff1f448b0b7041827889bd9abb Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Wed, 5 Apr 2023 09:10:21 +0930 Subject: [PATCH 55/60] add experimental zig cross compiling --- .github/actions/compile-with-zig/action.yml | 106 ++++++++++++++++++++ .github/workflows/release.yml | 60 +++++++++++ 2 files changed, 166 insertions(+) create mode 100644 .github/actions/compile-with-zig/action.yml diff --git a/.github/actions/compile-with-zig/action.yml b/.github/actions/compile-with-zig/action.yml new file mode 100644 index 0000000..4ffd9b6 --- /dev/null +++ b/.github/actions/compile-with-zig/action.yml @@ -0,0 +1,106 @@ +--- +name: Compile Library with Zig + +description: | + Use Zig to cross compile builds + +inputs: + arch: + required: true + description: | + valid zig target. + + see + + zig targets | jq .libc + + as of 0.10.1 this is: + + "aarch64_be-linux-gnu", + "aarch64_be-linux-musl", + "aarch64_be-windows-gnu", + "aarch64-linux-gnu", + "aarch64-linux-musl", + "aarch64-windows-gnu", + "aarch64-macos-none", + "aarch64-macos-none", + "aarch64-macos-none", + "armeb-linux-gnueabi", + "armeb-linux-gnueabihf", + "armeb-linux-musleabi", + "armeb-linux-musleabihf", + "armeb-windows-gnu", + "arm-linux-gnueabi", + "arm-linux-gnueabihf", + "arm-linux-musleabi", + "arm-linux-musleabihf", + "thumb-linux-gnueabi", + "thumb-linux-gnueabihf", + "thumb-linux-musleabi", + "thumb-linux-musleabihf", + "arm-windows-gnu", + "csky-linux-gnueabi", + "csky-linux-gnueabihf", + "i386-linux-gnu", + "i386-linux-musl", + "i386-windows-gnu", + "m68k-linux-gnu", + "m68k-linux-musl", + "mips64el-linux-gnuabi64", + "mips64el-linux-gnuabin32", + "mips64el-linux-musl", + "mips64-linux-gnuabi64", + "mips64-linux-gnuabin32", + "mips64-linux-musl", + "mipsel-linux-gnueabi", + "mipsel-linux-gnueabihf", + "mipsel-linux-musl", + "mips-linux-gnueabi", + "mips-linux-gnueabihf", + "mips-linux-musl", + "powerpc64le-linux-gnu", + "powerpc64le-linux-musl", + "powerpc64-linux-gnu", + "powerpc64-linux-musl", + "powerpc-linux-gnueabi", + "powerpc-linux-gnueabihf", + "powerpc-linux-musl", + "riscv64-linux-gnu", + "riscv64-linux-musl", + "s390x-linux-gnu", + "s390x-linux-musl", + "sparc-linux-gnu", + "sparc64-linux-gnu", + "wasm32-freestanding-musl", + "wasm32-wasi-musl", + "x86_64-linux-gnu", + "x86_64-linux-gnux32", + "x86_64-linux-musl", + "x86_64-windows-gnu", + "x86_64-macos-none", + "x86_64-macos-none", + "x86_64-macos-none" + +runs: + using: composite + + + steps: + + - name: Prepare + shell: bash + env: + CC: "zig cc -target ${{ inputs.arch }}" + run: | + zig cc --version + git clone https://github.com/Conni2461/examiner + cd examiner + make && sudo make install + + - name: Build + env: + CC: "zig cc -target ${{ inputs.arch }}" + LD_LIBRARY_PATH: /usr/lib:/usr/local/lib + + shell: bash + run: make diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c116cbf..dc2b7b8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -112,6 +112,66 @@ jobs: name: windows-x64-${{ matrix.compiler }} path: build/*.dll + experimental_zig: + name: make-${{matrix.arch}}-binaries-with-zig + + strategy: + matrix: + include: + # windows + - target: arm-windows-gnu + os: windows + - target: aarch64-windows-gnu + os: windows + - target: x86_64-windows-gnu + os: windows + + # linux + - target: x86_64-linux-gnu + os: linux + - target: x86_64-linux-musl + os: linux + - target: aarch64-linux-gnu + os: linux + - target: aarch64-linux-musl + os: linux + - target: arm-linux-gnueabi + os: linux + - target: arm-linux-gnueabihf + os: linux + - target: arm-linux-musleabi + os: linux + - target: arm-linux-musleabihf + os: linux + # osx + - target: aarch64-macos-none + os: osx + - target: aarch64-macos-none + os: osx + - target: aarch64-macos-none + os: osx + - target: x86_64-macos-none + os: osx + - target: x86_64-macos-none + os: osx + - target: x86_64-macos-none + os: osx + + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v3 + + - uses: ./.github/actions/compile-with-zig + with: + arch: ${{ matrix.target }} + + - uses: actions/upload-artifact@v3 + with: + name: ${{matrix.os}}-${{ matrix.target }}-zig + path: build/* + release: needs: - linux_x64 From e4ab0a4f057e579d0ef3aae8bd8fbd2372344ec1 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Wed, 5 Apr 2023 09:23:08 +0930 Subject: [PATCH 56/60] allow custom command --- .../{compile-with-zig => with-zig}/action.yml | 17 +++- .github/workflows/ci.yml | 80 +++++++++++++++++++ .github/workflows/release.yml | 20 ++++- 3 files changed, 112 insertions(+), 5 deletions(-) rename .github/actions/{compile-with-zig => with-zig}/action.yml (89%) diff --git a/.github/actions/compile-with-zig/action.yml b/.github/actions/with-zig/action.yml similarity index 89% rename from .github/actions/compile-with-zig/action.yml rename to .github/actions/with-zig/action.yml index 4ffd9b6..1d9551b 100644 --- a/.github/actions/compile-with-zig/action.yml +++ b/.github/actions/with-zig/action.yml @@ -5,6 +5,15 @@ description: | Use Zig to cross compile builds inputs: + run: + required: false + default: make + description: optional command to run, defaults to make + + output: + required: true + description: output filename + arch: required: true description: | @@ -87,7 +96,7 @@ runs: steps: - - name: Prepare + - name: "Zig: Prepare" shell: bash env: CC: "zig cc -target ${{ inputs.arch }}" @@ -97,10 +106,10 @@ runs: cd examiner make && sudo make install - - name: Build + - name: "Zig: ${{ inputs.run }}" env: CC: "zig cc -target ${{ inputs.arch }}" LD_LIBRARY_PATH: /usr/lib:/usr/local/lib - + TARGET: ${{ inputs.output }} shell: bash - run: make + run: ${{ inputs.run }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cbbb28a..aeb07d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,6 +71,86 @@ jobs: - uses: actions/checkout@v3 - uses: ./.github/actions/compile-windows-x64 + unittest_zig: + name: make-${{matrix.arch}}-binaries-with-zig + + strategy: + matrix: + include: + # windows + - target: arm-windows-gnu + os: windows + output: libfzf.dll + - target: aarch64-windows-gnu + os: windows + output: libfzf.dll + - target: x86_64-windows-gnu + os: windows + output: libfzf.dll + + # linux + - target: x86_64-linux-gnu + os: linux + output: libfzf.so + - target: x86_64-linux-musl + os: linux + output: libfzf.so + - target: aarch64-linux-gnu + os: linux + output: libfzf.so + - target: aarch64-linux-musl + os: linux + output: libfzf.so + - target: arm-linux-gnueabi + os: linux + output: libfzf.so + - target: arm-linux-gnueabihf + os: linux + output: libfzf.so + - target: arm-linux-musleabi + os: linux + output: libfzf.so + - target: arm-linux-musleabihf + os: linux + output: libfzf.so + # osx + - target: aarch64-macos-none + os: osx + output: libfzf.so + - target: aarch64-macos-none + os: osx + output: libfzf.so + - target: aarch64-macos-none + os: osx + output: libfzf.so + - target: x86_64-macos-none + os: osx + output: libfzf.so + - target: x86_64-macos-none + os: osx + output: libfzf.so + - target: x86_64-macos-none + os: osx + output: libfzf.so + + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v3 + + - uses: ./.github/actions/with-zig + with: + arch: ${{ matrix.target }} + output: ${{ matrix.output }} + run: make test + + - uses: actions/upload-artifact@v3 + with: + name: ${{matrix.os}}-${{ matrix.target }}-zig + path: build/* + + e2etest_linux_x64: name: e2etest-linux-x64 strategy: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dc2b7b8..933f908 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -121,41 +121,58 @@ jobs: # windows - target: arm-windows-gnu os: windows + output: libfzf.dll - target: aarch64-windows-gnu os: windows + output: libfzf.dll - target: x86_64-windows-gnu os: windows + output: libfzf.dll # linux - target: x86_64-linux-gnu os: linux + output: libfzf.so - target: x86_64-linux-musl os: linux + output: libfzf.so - target: aarch64-linux-gnu os: linux + output: libfzf.so - target: aarch64-linux-musl os: linux + output: libfzf.so - target: arm-linux-gnueabi os: linux + output: libfzf.so - target: arm-linux-gnueabihf os: linux + output: libfzf.so - target: arm-linux-musleabi os: linux + output: libfzf.so - target: arm-linux-musleabihf os: linux + output: libfzf.so # osx - target: aarch64-macos-none os: osx + output: libfzf.so - target: aarch64-macos-none os: osx + output: libfzf.so - target: aarch64-macos-none os: osx + output: libfzf.so - target: x86_64-macos-none os: osx + output: libfzf.so - target: x86_64-macos-none os: osx + output: libfzf.so - target: x86_64-macos-none os: osx + output: libfzf.so runs-on: ubuntu-latest @@ -163,9 +180,10 @@ jobs: - uses: actions/checkout@v3 - - uses: ./.github/actions/compile-with-zig + - uses: ./.github/actions/with-zig with: arch: ${{ matrix.target }} + output: ${{ matrix.output }} - uses: actions/upload-artifact@v3 with: From ac5fdc569a4e460cb74e11ce1ab0812eb3a6d3f6 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Wed, 5 Apr 2023 09:26:19 +0930 Subject: [PATCH 57/60] make zig available --- .github/actions/with-zig/action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/actions/with-zig/action.yml b/.github/actions/with-zig/action.yml index 1d9551b..07d3a17 100644 --- a/.github/actions/with-zig/action.yml +++ b/.github/actions/with-zig/action.yml @@ -96,6 +96,10 @@ runs: steps: + - uses: goto-bus-stop/setup-zig@v2 + with: + version: 0.10.1 + - name: "Zig: Prepare" shell: bash env: From a3f739086c4a25eaa5c0d5fd453fde6653413eaa Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Wed, 5 Apr 2023 09:32:51 +0930 Subject: [PATCH 58/60] just test out macos for now --- .github/workflows/ci.yml | 48 ----------------------------------- .github/workflows/release.yml | 48 ----------------------------------- 2 files changed, 96 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aeb07d0..844f881 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,58 +77,10 @@ jobs: strategy: matrix: include: - # windows - - target: arm-windows-gnu - os: windows - output: libfzf.dll - - target: aarch64-windows-gnu - os: windows - output: libfzf.dll - - target: x86_64-windows-gnu - os: windows - output: libfzf.dll - - # linux - - target: x86_64-linux-gnu - os: linux - output: libfzf.so - - target: x86_64-linux-musl - os: linux - output: libfzf.so - - target: aarch64-linux-gnu - os: linux - output: libfzf.so - - target: aarch64-linux-musl - os: linux - output: libfzf.so - - target: arm-linux-gnueabi - os: linux - output: libfzf.so - - target: arm-linux-gnueabihf - os: linux - output: libfzf.so - - target: arm-linux-musleabi - os: linux - output: libfzf.so - - target: arm-linux-musleabihf - os: linux - output: libfzf.so # osx - target: aarch64-macos-none os: osx output: libfzf.so - - target: aarch64-macos-none - os: osx - output: libfzf.so - - target: aarch64-macos-none - os: osx - output: libfzf.so - - target: x86_64-macos-none - os: osx - output: libfzf.so - - target: x86_64-macos-none - os: osx - output: libfzf.so - target: x86_64-macos-none os: osx output: libfzf.so diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 933f908..aa85fd2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -118,58 +118,10 @@ jobs: strategy: matrix: include: - # windows - - target: arm-windows-gnu - os: windows - output: libfzf.dll - - target: aarch64-windows-gnu - os: windows - output: libfzf.dll - - target: x86_64-windows-gnu - os: windows - output: libfzf.dll - - # linux - - target: x86_64-linux-gnu - os: linux - output: libfzf.so - - target: x86_64-linux-musl - os: linux - output: libfzf.so - - target: aarch64-linux-gnu - os: linux - output: libfzf.so - - target: aarch64-linux-musl - os: linux - output: libfzf.so - - target: arm-linux-gnueabi - os: linux - output: libfzf.so - - target: arm-linux-gnueabihf - os: linux - output: libfzf.so - - target: arm-linux-musleabi - os: linux - output: libfzf.so - - target: arm-linux-musleabihf - os: linux - output: libfzf.so # osx - target: aarch64-macos-none os: osx output: libfzf.so - - target: aarch64-macos-none - os: osx - output: libfzf.so - - target: aarch64-macos-none - os: osx - output: libfzf.so - - target: x86_64-macos-none - os: osx - output: libfzf.so - - target: x86_64-macos-none - os: osx - output: libfzf.so - target: x86_64-macos-none os: osx output: libfzf.so From 05739401ab9ba555af9044571c08f9405f565f21 Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Wed, 5 Apr 2023 09:33:46 +0930 Subject: [PATCH 59/60] correctly name the job --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 844f881..6e407a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,7 @@ jobs: - uses: ./.github/actions/compile-windows-x64 unittest_zig: - name: make-${{matrix.arch}}-binaries-with-zig + name: make-${{matrix.target}}-binaries-with-zig strategy: matrix: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aa85fd2..2503479 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -113,7 +113,7 @@ jobs: path: build/*.dll experimental_zig: - name: make-${{matrix.arch}}-binaries-with-zig + name: make-${{matrix.target}}-binaries-with-zig strategy: matrix: From caf126a23debc6b34384d7282014589886db12ab Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Wed, 5 Apr 2023 09:35:47 +0930 Subject: [PATCH 60/60] doesnt work --- .github/workflows/ci.yml | 60 +++++++++++++++++------------------ .github/workflows/release.yml | 58 ++++++++++++++++----------------- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e407a1..14cd7b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,36 +71,36 @@ jobs: - uses: actions/checkout@v3 - uses: ./.github/actions/compile-windows-x64 - unittest_zig: - name: make-${{matrix.target}}-binaries-with-zig - - strategy: - matrix: - include: - # osx - - target: aarch64-macos-none - os: osx - output: libfzf.so - - target: x86_64-macos-none - os: osx - output: libfzf.so - - runs-on: ubuntu-latest - - steps: - - - uses: actions/checkout@v3 - - - uses: ./.github/actions/with-zig - with: - arch: ${{ matrix.target }} - output: ${{ matrix.output }} - run: make test - - - uses: actions/upload-artifact@v3 - with: - name: ${{matrix.os}}-${{ matrix.target }}-zig - path: build/* + # unittest_zig: + # name: make-${{matrix.target}}-binaries-with-zig + + # strategy: + # matrix: + # include: + # # osx + # - target: aarch64-macos-none + # os: osx + # output: libfzf.so + # - target: x86_64-macos-none + # os: osx + # output: libfzf.so + + # runs-on: ubuntu-latest + + # steps: + + # - uses: actions/checkout@v3 + + # - uses: ./.github/actions/with-zig + # with: + # arch: ${{ matrix.target }} + # output: ${{ matrix.output }} + # run: make test + + # - uses: actions/upload-artifact@v3 + # with: + # name: ${{matrix.os}}-${{ matrix.target }}-zig + # path: build/* e2etest_linux_x64: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2503479..1dc0958 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -112,35 +112,35 @@ jobs: name: windows-x64-${{ matrix.compiler }} path: build/*.dll - experimental_zig: - name: make-${{matrix.target}}-binaries-with-zig - - strategy: - matrix: - include: - # osx - - target: aarch64-macos-none - os: osx - output: libfzf.so - - target: x86_64-macos-none - os: osx - output: libfzf.so - - runs-on: ubuntu-latest - - steps: - - - uses: actions/checkout@v3 - - - uses: ./.github/actions/with-zig - with: - arch: ${{ matrix.target }} - output: ${{ matrix.output }} - - - uses: actions/upload-artifact@v3 - with: - name: ${{matrix.os}}-${{ matrix.target }}-zig - path: build/* + # experimental_zig: + # name: make-${{matrix.target}}-binaries-with-zig + + # strategy: + # matrix: + # include: + # # osx + # - target: aarch64-macos-none + # os: osx + # output: libfzf.so + # - target: x86_64-macos-none + # os: osx + # output: libfzf.so + + # runs-on: ubuntu-latest + + # steps: + + # - uses: actions/checkout@v3 + + # - uses: ./.github/actions/with-zig + # with: + # arch: ${{ matrix.target }} + # output: ${{ matrix.output }} + + # - uses: actions/upload-artifact@v3 + # with: + # name: ${{matrix.os}}-${{ matrix.target }}-zig + # path: build/* release: needs: