Skip to content

Commit

Permalink
Remove buildifier from dependencies and use pre-commit-hooks instead (#…
Browse files Browse the repository at this point in the history
…11)

* Remove buildifier from dependencies and use pre-commit-hooks instead

* Disable the fetching test on macos

* fix buildifier errors

* remove the buildifier definition

* don't use matrix for the different platform tests
  • Loading branch information
aignas authored May 30, 2022
1 parent f96cf5c commit b756fb0
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 74 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ on:

jobs:
build:
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest

runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Test fetch
if: ${{ matrix.os }} == 'ubuntu-latest'
run: bazel fetch //...

- name: Test
run: bazel test //...

test-mac:
runs-on: macos-latest

steps:
- uses: actions/checkout@v3

- name: Test
run: bazel test //...
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# See CONTRIBUTING.md for instructions.
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/keith/pre-commit-buildifier
rev: 4.0.1.1
hooks:
- id: buildifier
args: &args
# Keep this argument in sync with .bazelci/presubmit.yaml
- --warnings=all
- id: buildifier-lint
args: *args
8 changes: 2 additions & 6 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")

buildifier(name = "buildifier")

alias(
name = "shellcheck",
actual = select({
"@bazel_tools//src/conditions:linux_x86_64": "@shellcheck_linux_amd64//:shellcheck",
"@bazel_tools//src/conditions:linux_aarch64": "@shellcheck_linux_arm64//:shellcheck",
"@bazel_tools//src/conditions:darwin": "@shellcheck_darwin_amd64//:shellcheck",
"@bazel_tools//src/conditions:linux_aarch64": "@shellcheck_linux_arm64//:shellcheck",
"@bazel_tools//src/conditions:linux_x86_64": "@shellcheck_linux_amd64//:shellcheck",
#"@bazel_tools//src/conditions:darwin_arm64": "@shellcheck_darwin_arm64//:shellcheck",
#"@bazel_tools//src/conditions:windows_x64": "@shellcheck_windows_amd64//:shellcheck",
}),
Expand Down
58 changes: 0 additions & 58 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,63 +1,5 @@
workspace(name = "com_github_aignas_rules_shellcheck")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# buildifier is written in Go and hence needs rules_go to be built.
# See https://github.com/bazelbuild/rules_go for the up to date setup instructions.
http_archive(
name = "io_bazel_rules_go",
sha256 = "ab21448cef298740765f33a7f5acee0607203e4ea321219f2a4c85a6e0fb0a27",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.32.0/rules_go-v0.32.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.32.0/rules_go-v0.32.0.zip",
],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies")

go_rules_dependencies()

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains")

go_register_toolchains(version = "1.18.2")

http_archive(
name = "bazel_gazelle",
sha256 = "5982e5463f171da99e3bdaeff8c0f48283a7a5f396ec5282910b9e8a49c0dd7e",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.25.0/bazel-gazelle-v0.25.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.25.0/bazel-gazelle-v0.25.0.tar.gz",
],
)

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

# If you use WORKSPACE.bazel, use the following line instead of the bare gazelle_dependencies():
# gazelle_dependencies(go_repository_default_config = "@//:WORKSPACE.bazel")
gazelle_dependencies()

http_archive(
name = "com_google_protobuf",
sha256 = "3bd7828aa5af4b13b99c191e8b1e884ebfa9ad371b0ce264605d347f135d2568",
strip_prefix = "protobuf-3.19.4",
urls = [
"https://github.com/protocolbuffers/protobuf/archive/v3.19.4.tar.gz",
],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

http_archive(
name = "com_github_bazelbuild_buildtools",
sha256 = "",
strip_prefix = "buildtools-5.1.0",
urls = [
"https://github.com/bazelbuild/buildtools/archive/refs/tags/5.1.0.tar.gz",
],
)

load("//:deps.bzl", "shellcheck_dependencies")

shellcheck_dependencies()
3 changes: 3 additions & 0 deletions def.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""This file provides all user facing functions.
"""

def _impl_test(ctx):
files = [ctx.file._shellcheck] + ctx.files.data
script = "exec " + " ".join([f.short_path for f in files])
Expand Down
9 changes: 7 additions & 2 deletions deps.bzl
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
"""Provides shellcheck dependencies on all supported platforms:
- Linux 64-bit and ARM64
- OSX 64-bit
"""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

_LABELS = {
"darwin_amd64": "darwin.x86_64",
"linux_amd64": "linux.x86_64",
"linux_arm64": "linux.aarch64",
"darwin_amd64": "darwin.x86_64",
# darwin_arm64 shellcheck binaries are not distributed from GitHub releases.
# windows_amd64 shellcheck binaries are not distributed from GitHub releases.
}
Expand All @@ -20,9 +25,9 @@ def _urls(arch, version):
def shellcheck_dependencies():
version = "v0.8.0"
sha256 = {
"darwin_amd64": "e065d4afb2620cc8c1d420a9b3e6243c84ff1a693c1ff0e38f279c8f31e86634",
"linux_amd64": "ab6ee1b178f014d1b86d1e24da20d1139656c8b0ed34d2867fbb834dad02bf0a",
"linux_arm64": "9f47bbff5624babfa712eb9d64ece14c6c46327122d0c54983f627ae3a30a4ac",
"darwin_amd64": "e065d4afb2620cc8c1d420a9b3e6243c84ff1a693c1ff0e38f279c8f31e86634",
}

for arch, sha256 in sha256.items():
Expand Down

0 comments on commit b756fb0

Please sign in to comment.