{"id":16517312,"url":"https://github.com/andyscott/misc_rules","last_synced_at":"2025-03-02T19:27:17.755Z","repository":{"id":54136934,"uuid":"171356039","full_name":"andyscott/misc_rules","owner":"andyscott","description":"bazel rules for: shellcheck, yamllint, black","archived":false,"fork":false,"pushed_at":"2023-02-20T11:43:41.000Z","size":40,"stargazers_count":11,"open_issues_count":3,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-13T06:42:24.880Z","etag":null,"topics":["bazel","build","linters","tools"],"latest_commit_sha":null,"homepage":"","language":"Starlark","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andyscott.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-18T21:05:40.000Z","updated_at":"2023-02-20T12:26:21.000Z","dependencies_parsed_at":"2024-11-13T18:53:51.113Z","dependency_job_id":null,"html_url":"https://github.com/andyscott/misc_rules","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyscott%2Fmisc_rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyscott%2Fmisc_rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyscott%2Fmisc_rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyscott%2Fmisc_rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andyscott","download_url":"https://codeload.github.com/andyscott/misc_rules/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241559412,"owners_count":19982259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bazel","build","linters","tools"],"created_at":"2024-10-11T16:29:52.841Z","updated_at":"2025-03-02T19:27:17.733Z","avatar_url":"https://github.com/andyscott.png","language":"Starlark","funding_links":[],"categories":[],"sub_categories":[],"readme":"# misc_rules\n\nRules for miscellaneous system tools, linters, etc.\n\n## Usage\n\nYou'll need to first load the rules in your WORKSPACE file.\n\n``` python\ngit_repository(\n    name = \"misc_rules\",\n    commit = \"\u003c\u003cpick-a-commit-sha\u003e\u003e\",\n    remote = \"git://github.com/andyscott/misc_rules\",\n)\n```\n\nNext, follow the configuration for any tools/rules you want to use.\n\n## Shellcheck\n\nFirst, register a shellcheck toolchain.\n\n**Prebuilt via rules_nixpkgs:**\n\n```python\nnixpkgs_package(\n    name = \"shellcheck\",\n    repository = \"@nixpkgs\",\n)\nregister_toolchains(\n    \"@misc_rules//toolchains/shellcheck:shellcheck_from_nixpkgs\",\n)\n```\n\n**Prebuilt from system path:**\n\n``` python\nregister_toolchains(\n    \"@misc_rules//toolchains/shellcheck:shellcheck_from_host_path\",\n)\n```\n\n*Note: You must set bazel option `--test_env=PATH` in your .bazelrc.*\n\n\n---\n\n\nNow you can shellcheck your scripts!\n\n``` python\nload(\"@misc_rules//rules/shellcheck:shellcheck.bzl\", \"shellcheck_test\")\n\nshellcheck_test(\n    name = \"myscript@shellcheck\",\n    srcs = [\n        \"myscript.sh\",\n    ],\n)\n```\n\nThere's also a series of macros that delegate to Bazel's `sh_**` rules.\n\n``` python\nload(\"//rules/shellcheck:shell.bzl\", \"shell_binary\")\n\nshell_binary(\n    name = \"ci\",\n    srcs = [\"src/ci.sh\"],\n    data = [\n        \":lint\",\n    ],\n    tags = [\"manual\"],\n    deps = [\n        \"@bazel_tools//tools/bash/runfiles\",\n    ],\n)\n\nshell_binary(\n    name = \"lint\",\n    srcs = [\"src/lint.sh\"],\n    tags = [\"manual\"],\n    deps = [\n        \"@bazel_tools//tools/bash/runfiles\",\n    ],\n)\n```\n\nThis macro gives you the usual targets as well as additional\n`@shellcheck` suffixed targets for running shellcheck.\n\n## Yamllint\n\nFirst, register a yamllint toolchain.\n\n**Prebuilt via rules_nixpkgs:**\n\n```python\nnixpkgs_package(\n    name = \"yamllint\",\n    attribute_path = \"python36Packages.yamllint\",\n    repository = \"@nixpkgs\",\n)\nregister_toolchains(\n    \"@misc_rules//toolchains/yamllint:yamllint_from_nixpkgs\",\n)\n```\n\n---\n\n\nNow you can yamllint your scripts!\n\n``` python\nload(\"@misc_rules//rules/yamllint:yamllint.bzl\", \"yamllint_test\")\n\nyamllint_test(\n    name = \"my_config@yamllint\",\n    srcs = [\n        \"my_config.yaml\",\n    ],\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyscott%2Fmisc_rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandyscott%2Fmisc_rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyscott%2Fmisc_rules/lists"}