From d495a345d6412515a6bed446a81a9f91202ef608 Mon Sep 17 00:00:00 2001 From: bbassie <17990055+bbassie@users.noreply.github.com> Date: Fri, 7 Aug 2026 16:04:16 +0000 Subject: [PATCH] Resolve clusterio through CLUSTERIO rather than in ci only The library path was injected by the workflow, so an editor opened on this repo could not resolve `modules/clusterio/*`. It now comes from the environment in both places. It cannot be written relative to this repo: emmylua does not normalise `..` in a library path, and an absolute path containing `..` fails the same way, so the location has to come from outside. Co-Authored-By: Claude Opus 5 (1M context) --- .emmyrc.json | 2 ++ .github/workflows/fmtk.yml | 7 ++++--- CONTRIBUTING.md | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.emmyrc.json b/.emmyrc.json index dbaab2ba..e6d9de6d 100644 --- a/.emmyrc.json +++ b/.emmyrc.json @@ -6,6 +6,8 @@ }, "workspace": { "$comment-moduleMap": "Replaces the fmtk --clusterio-modules plugin, rewrites each file's own module path rather than the require string", + "$comment-library": "clusterio is outside this repo, set CLUSTERIO to your checkout. The factorio typedefs come from .luarc.json, which the factoriomod-debug extension manages", + "library": [ "$CLUSTERIO/packages/host" ], "ignoreDir": [ ".github", "web", "dist", "factorio" ], "ignoreGlobs": [ "**/node_modules/**", "**/dist/**" ], "moduleMap": [ diff --git a/.github/workflows/fmtk.yml b/.github/workflows/fmtk.yml index 75d877d3..c74249d7 100644 --- a/.github/workflows/fmtk.yml +++ b/.github/workflows/fmtk.yml @@ -6,6 +6,7 @@ on: env: EMMYLUA_CHECK_VERSION: "0.24.0" + CLUSTERIO: ${{ github.workspace }}/.clusterio jobs: lint: @@ -36,9 +37,9 @@ jobs: - name: Run Lint Report shell: bash run: | - # Library paths are machine specific, so they are merged in rather than committed - jq -n --arg lib "$RUNNER_TEMP/factorio/library" --arg clusterio "$PWD/.clusterio/packages/host" \ - '{ workspace: { library: [ $lib, $clusterio ], ignoreGlobs: [ ".clusterio/**" ] } }' \ + # The typedefs are generated per run, clusterio comes from CLUSTERIO above + jq -n --arg lib "$RUNNER_TEMP/factorio/library" \ + '{ workspace: { library: [ $lib ], ignoreGlobs: [ ".clusterio/**" ] } }' \ > "$RUNNER_TEMP/ci.emmyrc.json" # Exits non zero on error severity, so the gate below is used instead diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2d2fcc38..870be0f9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,6 +5,7 @@ All are welcome to make bug reports, feature requests, and pull requests for our For developers wanting to add features please follow these guidelines: - All lua code is documented using ldoc. +- Set `CLUSTERIO` to your clusterio checkout, the lint needs it to resolve `modules/clusterio/*`. emmylua does not normalise `..` in a library path, so it cannot be written relative to this repo. - Lua is checked with [emmylua](https://github.com/EmmyLuaLs/emmylua-analyzer-rust), configured by `.emmyrc.json`. Install the EmmyLua extension rather than sumneko, and let the factoriomod-debug extension write your machine local library paths to `.luarc.json`, which is git ignored. Note that an inline cast must be written `--[[@as T]]`, the spaced form is not parsed. - Changes should be made on your own fork and merged into `main` through a pull request. - Each pull request should be limited to one feature or a few bug fixes and link to the related issue page.