Skip to content

Include dependencies headers with the `workspace.library` setting

Marc Jakobi edited this page Jan 6, 2024 · 3 revisions

Example for folke/neodev.nvim and busted:

  • Create a dedicated .luarc.json file for the action in .github/workflows/.luarc.json.
// ./.github/workflows/.luarc.json
{
  "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
  "runtime.version": "LuaJIT",
  "runtime.path": [
    "lua/?.lua",
    "lua/?/init.lua"
  ],
  "Lua.workspace.library": [
    "/github/workspace/deps/neodev.nvim/types/stable"
    "${3rd}/busted/library"
  ],
  "Lua.diagnostics.libraryFiles": "Disable",
  "Lua.workspace.checkThirdParty": "Disable"
}
  • Use actions/checkout or luarocks install --tree <path> to install the dependency into a deps subdirectory.
  • Point the configpath input to the dedicated .luarc.json.
# ./.github/workflows/lua_ls-typecheck.yml
# you could add `tests` folder at the end but it will raise errors for `describe, it, ...` anyways...
name: lua_ls-typecheck
on:
  pull_request: ~
  push:
    branches:
      - '*'

jobs:
  build:
    name: Type Check Code Base
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Code
        uses: actions/checkout@v3

      - name: Checkout dependency neodev
        uses: actions/checkout@v3
        with:
          repository: "folke/neodev.nvim"
          path: "deps/neodev.nvim"

      - name: Type Check Code Base
        uses: mrcjkb/[email protected]
        with:
          configpath: .github/workflows/.luarc.json
          directories: |
            lua

Thanks @pysan3!

Clone this wiki locally