Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add testing using plenary and linting using luacheck #10

Merged

Conversation

mikavilpas
Copy link
Contributor

This PR adds testing and linting to the codebase. I think having tests will be a very good idea and will make collaboration much easier in the future. I don't feel that strongly about linting, but it was very easy to add so I figured why not 😄

The testing and linting setup is copied and adapted from https://github.com/S1M0N38/my-awesome-plugin.nvim, a project template for neovim plugin development.

Successful tests in the terminal

Here's how the testing and linting looks like on my computer:
image

Failed tests in the terminal

image

The tests can also be run inside neovim (probably more convenient). Here's some examples:

Successful tests in neovim

(ignore the warnings, I haven't looked into how to get rid of them yet) image

Failed tests in neovim

(can probably look a bit better if configured correctly) image

You can see an example CI run from this commit (follow the ✅ icon to see the builds).


Here's some ideas for future work:

@mikavilpas mikavilpas force-pushed the feature/add-base-for-testing-locally-and-in-CI branch from 95d4b91 to a3b8382 Compare January 19, 2024 19:06
Copy link
Owner

@gsuuon gsuuon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for getting this going! Just got a few comments:

  • Looks like there's a dupe of .github/workflows in project root
  • Luacheck looks pretty unmaintained, selene would be better (it would also be fewer dev dependencies since we already need cargo for stylua)
  • This repo doesn't get many issues so let's hold off on the issue templates for now
  • Testing setup options doesn't add a lot of value but will increase maintenance. The logic in both trail.lua and nav.lua could use some testing though! We can add a couple tests for those or just leave the test file empty here and tackle those later

@mikavilpas
Copy link
Contributor Author

All those comments have now been addressed.
Really appreciate the suggestions; as someone new to lua, they all make sense and are really valuable to me.

I added them as separate commits to make reviewing the changes easier. Let me know if you would like me to squash them.

@gsuuon
Copy link
Owner

gsuuon commented Jan 20, 2024

Thanks! A couple last comments:

  • we don't need .luacheckrc anymore
  • the init rule in the makefile is just for scaffolding projects based on that template, lets remove it to reduce confusion since it's not initing anything in this project

I'll get this merged after your updates

build: enable testing and linting in GitHub for pushes,pull_requests

test: setup() with no options

feat: configuration is typed using luals types

https://luals.github.io/wiki/annotations/

test: some public api is created when setup() is called

This doesn't test everything but it should be better than nothing.

chore: 'make format' formats all code and tests

chore: remove duplicate workflows that were added by accident

chore: remove unneeded issue templates for now

test: only have one example spec for now, don't test options

chore: add linting with the selene lua linter

build: run selene in Github instead of luacheck

chore: remove luacheckrc, not needed since we want to use selene instead

chore: remove 'make init', not needed

chore: make sure 'make format' reformats in all lua/ subdirectories

More might get added in the future, so it's good to format everything always
@mikavilpas mikavilpas force-pushed the feature/add-base-for-testing-locally-and-in-CI branch from c78fe30 to 7d26685 Compare January 22, 2024 07:25
@mikavilpas
Copy link
Contributor Author

Oops, you were right. .luacheckrc has now been removed, and make init has also been removed.

I pushed these changes, but after that I also squashed and separated the changes in this PR into 2 commits. I wanted to make it easy to review the most recent changes while also getting a cleaner history after merging, but looks like my force push made it so that the separate changes aren't visible in this PR as separate commits somehow.

Well, I hope they will still be easy to see since the PR is small.

Copy link
Owner

@gsuuon gsuuon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! No worries about the clean commits. I appreciate the thought, it does help with reviewing.

@gsuuon gsuuon merged commit 32a57fa into gsuuon:main Jan 22, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants