Skip to content

Commit

Permalink
fix(luarocs-test): only run if .busted file is present (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb authored Jul 5, 2023
1 parent a1605bd commit dfd19f6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ result
/luarocks
/lua_modules
/.luarocks
.luarc.json
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [v5.0.1] - 2023-07-06
### Fixed
- Run `luarocks test` only if a `.busted` file exists in the project root.

## [v5.0.0] - 2023-06-04
### Added
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
# url = "github:mrcjkb/pre-commit-hooks.nix/lua-ls-shellhook-fix";
inputs.nixpkgs.follows = "nixpkgs";
};

Expand Down Expand Up @@ -53,7 +54,7 @@
luacheck.enable = true;
editorconfig-checker.enable = true;
markdownlint.enable = true;
lua-ls.enable = true;
# lua-ls.enable = true; # FIXME: This broke with a flake lock update
};
settings = {
markdownlint.config = {
Expand All @@ -67,7 +68,11 @@
lua-ls = {
config = {
Lua = {
workspace.library = base-dependencies;
workspace = {
library = base-dependencies;
checkThirdParty = false;
};
diagnostics.libraryFiles = "Disable";
};
};
};
Expand All @@ -88,6 +93,7 @@
editorconfig-checker
markdownlint-cli
]);
# FIXME: lua-ls pre-commit hook in nix shell
shellHook = ''
${self.checks.${system}.formatting.shellHook}
'';
Expand Down
17 changes: 15 additions & 2 deletions lua/luarocks-tag-release.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ local function luarocks_tag_release(args)
return content
end

---@param filename string
---@return boolean file_exists
local function file_exists(filename)
local f = io.open(filename, 'r')
if f then
f:close()
return true
end
return false
end

---@param content string
---@return nil
local function write_file(content)
Expand Down Expand Up @@ -202,8 +213,10 @@ local function luarocks_tag_release(args)
print('========================================================================================')

write_file(rockspec)
for _, interpreter in pairs(args.luarocks_test_interpreters) do
luarocks_test(interpreter)
if file_exists('.busted') then
for _, interpreter in pairs(args.luarocks_test_interpreters) do
luarocks_test(interpreter)
end
end
luarocks_upload()

Expand Down

0 comments on commit dfd19f6

Please sign in to comment.