notomo / vusted

A busted wrapper for testing neovim plugin
https://luarocks.org/modules/notomo/vusted
MIT License
78 stars 4 forks source link

How to generate code coverage report? #15

Closed linrongbin16 closed 1 year ago

linrongbin16 commented 1 year ago

Hi, I installed vusted in macOS with homebrew's luarocks, and other components:

luarocks install luacheck
luarocks install luacov
luarocks install cluacov
luarocks install vusted
luarocks --lua-version=5.1 install vusted

But there's error on generate the code coverage report:

busted: error: LuaCov not found on the system, try running without --coverage option, or install LuaCov first
linrongbin16 commented 1 year ago

I also try to use code coverage with codecov in Neovim plugin's CI/CD.

Here's the ci.yml:

https://github.com/linrongbin16/fzfx.nvim/blob/005291418a3d8c74b8ade3f3ca8b841938d5e364/.github/workflows/ci.yml#L36

If you don't want to read the source code, here's the core part:

  unit_test_stable:
    name: Unit test on stable nvim
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Setup neovim
        uses: rhysd/action-setup-vim@v1
        id: vim
        with:
          neovim: true
          version: stable
      - name: Install luajit
        uses: leafo/gh-actions-lua@v10
        with:
          luaVersion: "luajit-2.1.0-beta3"
      - name: Install luarocks
        uses: leafo/gh-actions-luarocks@v4
      - name: Run test cases
        shell: bash
        run: |
          luarocks install luacheck
          luarocks install luacov
          luarocks install cluacov
          luarocks install vusted
          vusted --coverage --shuffle ./test
      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@v3
        with:
          root_dir: ./test
        env:
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

But the codecov says it cannot find the codecov:

image
linrongbin16 commented 1 year ago

It's good now: https://github.com/linrongbin16/fzfx.nvim/actions/runs/6074583472/job/16478945158?pr=145