Skip to content

Commit

Permalink
Add pre-commit hook for selene
Browse files Browse the repository at this point in the history
  • Loading branch information
amitds1997 committed Nov 1, 2024
1 parent e19e3c4 commit ae26621
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 5 deletions.
21 changes: 21 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
- id: selene-system
name: selene (system)
description: An opinionated Lua code linter
entry: selene
language: system
types: [lua]

- id: selene-docker
name: selene (docker)
description: An opinionated Lua code linter
entry: /selene
language: docker
types: [lua]

- id: selene-github
name: selene (GitHub)
description: An opinionated Lua code linter
entry: selene
language: python
types: [lua]
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Added `Path2DControlPoint.new` to the Roblox standard library
- [Adds `lua_versions` to standard library definitions](https://kampfkarren.github.io/selene/usage/std.html#lua_versions). Specifying this will only allow the syntax used by those languages. The default standard libraries now specify these, meaning that invalid syntax for that language will no longer be supported.
- Added missing third parameter to `PathWaypoint.new` in the Roblox standard library
- Added support for selene as a `pre-commit` hook

### Changed
- Upgrades to [full-moon 1.0.0](https://github.com/Kampfkarren/full-moon/blob/main/CHANGELOG.md#100---2024-10-08), which should provide faster parse speeds, support for multiple parsing errors at the same time, and support for some new Luau syntax.
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ FROM bash AS selene-light
COPY --from=selene-light-builder /usr/local/cargo/bin/selene /
CMD ["/selene"]

FROM bash AS selene-musl
COPY --from=selene-musl-builder /usr/local/cargo/bin/selene /
CMD ["/selene"]

FROM bash AS selene-light-musl
COPY --from=selene-light-musl-builder /usr/local/cargo/bin/selene /
CMD ["/selene"]

FROM bash AS selene-musl
COPY --from=selene-musl-builder /usr/local/cargo/bin/selene /
CMD ["/selene"]
3 changes: 2 additions & 1 deletion docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [Configuration](./usage/configuration.md)
- [Filtering](./usage/filtering.md)
- [Standard Library Format](./usage/std.md)
- [Git hooks (pre-commit)](./usage/git-hooks-pre-commit.md)
- [Roblox Guide](./roblox.md)
- [Contributing](./contributing.md)
- [Lints](./lints/index.md)
Expand Down Expand Up @@ -42,4 +43,4 @@
- [unscoped_variables](./lints/unscoped_variables.md)
- [unused_variable](./lints/unused_variable.md)
- [Archive](./archive/index.md)
- [TOML Standard Library Format](./archive/std_v1.md)
- [TOML Standard Library Format](./archive/std_v1.md)
35 changes: 35 additions & 0 deletions docs/src/usage/git-hooks-pre-commit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Pre-commit

`pre-commit` allows integration of `selene` into your Git workflow using git hooks. After [installing pre-commit](https://pre-commit.com/#install), add one of the following configurations to your `.pre-commit-config.yaml` file:

* Use the `selene` binary present on the system path (Should be pre-installed):

```yaml
repos:
- repo: https://github.com/Kampfkarren/selene
rev: ''
hooks:
- id: selene-system
```
* Use `selene` through GitHub releases:

```yaml
repos:
- repo: https://github.com/Kampfkarren/selene
rev: ''
hooks:
- id: selene-github
```

* Use the `selene` binary present in the `selene` docker image (Since this uses docker, it might take some time to bootstrap and is slower than the other two options):

```yaml
repos:
- repo: https://github.com/Kampfkarren/selene
rev: ''
hooks:
- id: selene-docker
```

You may see a `warning` being generated when pre-commit runs. To resolve that, set the `rev` key to any selene tag or commit, for e.g. `rev: '0.26.2'`.
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[build-system]
requires = ["release-gitter[builder]"]
build-backend = "pseudo_builder"

[tool.release-gitter]
git-url = "https://github.com/Kampfkarren/selene"
extract-files = ["selene"]
format = "selene-{version}-{system}.zip"

[tool.release-gitter.map-system]
Darwin = "macos"
Windows = "windows"
Linux = "linux"

0 comments on commit ae26621

Please sign in to comment.