Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andyscott/misc_rules
bazel rules for: shellcheck, yamllint, black
https://github.com/andyscott/misc_rules
bazel build linters tools
Last synced: about 1 month ago
JSON representation
bazel rules for: shellcheck, yamllint, black
- Host: GitHub
- URL: https://github.com/andyscott/misc_rules
- Owner: andyscott
- License: apache-2.0
- Created: 2019-02-18T21:05:40.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-02-20T11:43:41.000Z (almost 2 years ago)
- Last Synced: 2024-10-12T16:29:22.549Z (3 months ago)
- Topics: bazel, build, linters, tools
- Language: Starlark
- Homepage:
- Size: 39.1 KB
- Stars: 11
- Watchers: 1
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# misc_rules
Rules for miscellaneous system tools, linters, etc.
## Usage
You'll need to first load the rules in your WORKSPACE file.
``` python
git_repository(
name = "misc_rules",
commit = "<>",
remote = "git://github.com/andyscott/misc_rules",
)
```Next, follow the configuration for any tools/rules you want to use.
## Shellcheck
First, register a shellcheck toolchain.
**Prebuilt via rules_nixpkgs:**
```python
nixpkgs_package(
name = "shellcheck",
repository = "@nixpkgs",
)
register_toolchains(
"@misc_rules//toolchains/shellcheck:shellcheck_from_nixpkgs",
)
```**Prebuilt from system path:**
``` python
register_toolchains(
"@misc_rules//toolchains/shellcheck:shellcheck_from_host_path",
)
```*Note: You must set bazel option `--test_env=PATH` in your .bazelrc.*
---
Now you can shellcheck your scripts!
``` python
load("@misc_rules//rules/shellcheck:shellcheck.bzl", "shellcheck_test")shellcheck_test(
name = "myscript@shellcheck",
srcs = [
"myscript.sh",
],
)
```There's also a series of macros that delegate to Bazel's `sh_**` rules.
``` python
load("//rules/shellcheck:shell.bzl", "shell_binary")shell_binary(
name = "ci",
srcs = ["src/ci.sh"],
data = [
":lint",
],
tags = ["manual"],
deps = [
"@bazel_tools//tools/bash/runfiles",
],
)shell_binary(
name = "lint",
srcs = ["src/lint.sh"],
tags = ["manual"],
deps = [
"@bazel_tools//tools/bash/runfiles",
],
)
```This macro gives you the usual targets as well as additional
`@shellcheck` suffixed targets for running shellcheck.## Yamllint
First, register a yamllint toolchain.
**Prebuilt via rules_nixpkgs:**
```python
nixpkgs_package(
name = "yamllint",
attribute_path = "python36Packages.yamllint",
repository = "@nixpkgs",
)
register_toolchains(
"@misc_rules//toolchains/yamllint:yamllint_from_nixpkgs",
)
```---
Now you can yamllint your scripts!
``` python
load("@misc_rules//rules/yamllint:yamllint.bzl", "yamllint_test")yamllint_test(
name = "my_config@yamllint",
srcs = [
"my_config.yaml",
],
)
```