Skip to content

Commit

Permalink
refactor: use just instead of GNU make (#515)
Browse files Browse the repository at this point in the history
* refactor: use just instead of GNU make

Just is a more modern alternative to make. See
https://github.com/casey/just
  • Loading branch information
mikavilpas authored Oct 14, 2024
1 parent bff42c2 commit 5199400
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 70 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
with:
# Github secret token
token: ${{ secrets.GITHUB_TOKEN }}
# selene arguments, should be the same as in ../../Makefile
# selene arguments, should be the same as in ../../justfile
args:
--display-style=quiet ./lua/ ./spec/
./integration-tests/test-environment/config-modifications
Expand All @@ -24,3 +24,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: DavidAnson/[email protected]

just:
name: just
runs-on: ubuntu-latest
steps:
- uses: extractions/setup-just@v1
# https://github.com/casey/just
# use the latest version, probably doesn't matter much

- name: Run just format check
run: just --fmt --check
53 changes: 0 additions & 53 deletions Makefile

This file was deleted.

31 changes: 15 additions & 16 deletions documentation/for-developers/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,28 @@
- install [nlua](https://github.com/mfussenegger/nlua), the neovim lua
interpreter, which is used to run the tests.

- install [GNU Make](https://www.gnu.org/software/make/), which is used to run
the development commands that are defined in the Makefile.
- install [just](https://github.com/casey/just), which is used to run the
development commands that are defined in the justfile.

Next, install all the dependencies with the following command:

```sh
make
just
```

When successful, the output will greet you with a message similar to the
following:

```text
Welcome to yazi.nvim development! 🚀
Next, run one of these commands to get started:
make test
Run all tests
make test-focus
Run only the tests marked with #focus in the test name
make lint
Check the code for lint errors
make format
Reformat all code
Available recipes:
build # Build the project
check # Check the code for errors (lint + test + format)
default
format # Reformat all code
help
lint # Check the code for lint errors
test # Run all tests
test-focus # Run only the tests marked with #focus somewhere in the test name
```

## Neovim development tools
Expand Down Expand Up @@ -79,18 +78,18 @@ This project has two types of tests

```sh
# run all tests
make test
just test
# NOTE: if you get an error about "busted.runner" not being found, you may need
# to run the following command:
eval $(luarocks path --no-bin --lua-version 5.1)

# run only the tests marked with #focus in their name
make test-focus
just test-focus
```

Recommended: use a file watcher to run tests automatically when files change. I
like [watchexec 🦀](https://github.com/watchexec/watchexec), and I run it with
`watchexec make test`
`watchexec just test`

Optionally, you can install test integration plugins for Neovim to start the
tests from within Neovim. See the "Tools" section of
Expand Down
48 changes: 48 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
set unstable := true

# allow `just --fmt`

COLOR_RESET := '\033[0m'
COLOR_GREEN := '\033[1;32m'
COLOR_BLUE_ := '\033[1;34m'
COLOR_YELLO := '\033[1;33m'
COLOR_WHITE := '\033[1;37m'

default: help

@help:
just --list

# Build the project
@build:
echo "Building project..."
luarocks init --no-gitignore
luarocks install busted 2.2.0-1

just help

# Check the code for lint errors
lint:
selene ./lua/ ./spec/ ./integration-tests/test-environment/config-modifications

@if grep -r -e "#focus" --include \*.lua ./spec/; then \
echo "\n"; \
echo "Error: {{ COLOR_GREEN }}#focus{{ COLOR_RESET }} tags found in the codebase.\n"; \
echo "Please remove them to prevent issues with not accidentally running all tests."; \
exit 1; \
fi

# Run all tests
test:
luarocks test --local

# Run only the tests marked with #focus somewhere in the test name
test-focus:
luarocks test --local -- --filter=focus

# Reformat all code
format:
stylua lua/ spec/ integration-tests/ ./repro.lua

# Check the code for errors (lint + test + format)
check: lint test format

0 comments on commit 5199400

Please sign in to comment.