Skip to content

Commit 8996f89

Browse files
authored
ci: Add check for formatting [BUILD-446] (#17)
Adds buildifier to make sure files are formatted before merging to main.
1 parent ccebc1a commit 8996f89

File tree

5 files changed

+102
-1
lines changed

5 files changed

+102
-1
lines changed

.github/workflows/ci.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: rules_swiftnav
2+
3+
on:
4+
pull_request: ~
5+
push:
6+
branches:
7+
- 'main'
8+
9+
jobs:
10+
11+
check-formatting:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Set up credentials
15+
uses: aws-actions/configure-aws-credentials@v1
16+
with:
17+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
18+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
19+
aws-region: us-west-2
20+
21+
- name: Set up cache
22+
run: |
23+
npm install -g bazels3cache
24+
bazels3cache --bucket=${{ secrets.BAZEL_BUCKET }}
25+
26+
- name: Checkout source
27+
uses: actions/checkout@v2
28+
29+
- name: Run format
30+
run: |
31+
bazel run --remote_cache=http://localhost:7777 //:buildifier
32+
git diff --exit-code

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bazel-*

BUILD.bazel

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
2+
3+
buildifier(
4+
name = "buildifier",
5+
)

WORKSPACE

+60
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,63 @@
99
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
1010

1111
workspace(name = "rules_swiftnav")
12+
13+
# Everything below this comment is for buildifier
14+
15+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
16+
17+
# buildifier is written in Go and hence needs rules_go to be built.
18+
# See https://github.com/bazelbuild/rules_go for the up to date setup instructions.
19+
http_archive(
20+
name = "io_bazel_rules_go",
21+
sha256 = "d6b2513456fe2229811da7eb67a444be7785f5323c6708b38d851d2b51e54d83",
22+
urls = [
23+
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip",
24+
"https://github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip",
25+
],
26+
)
27+
28+
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies")
29+
30+
go_rules_dependencies()
31+
32+
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains")
33+
34+
go_register_toolchains(version = "1.17.2")
35+
36+
http_archive(
37+
name = "bazel_gazelle",
38+
sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
39+
urls = [
40+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
41+
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
42+
],
43+
)
44+
45+
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
46+
47+
# If you use WORKSPACE.bazel, use the following line instead of the bare gazelle_dependencies():
48+
# gazelle_dependencies(go_repository_default_config = "@//:WORKSPACE.bazel")
49+
gazelle_dependencies()
50+
51+
http_archive(
52+
name = "com_google_protobuf",
53+
sha256 = "3bd7828aa5af4b13b99c191e8b1e884ebfa9ad371b0ce264605d347f135d2568",
54+
strip_prefix = "protobuf-3.19.4",
55+
urls = [
56+
"https://github.com/protocolbuffers/protobuf/archive/v3.19.4.tar.gz",
57+
],
58+
)
59+
60+
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
61+
62+
protobuf_deps()
63+
64+
http_archive(
65+
name = "com_github_bazelbuild_buildtools",
66+
sha256 = "ae34c344514e08c23e90da0e2d6cb700fcd28e80c02e23e4d5715dddcb42f7b3",
67+
strip_prefix = "buildtools-4.2.2",
68+
urls = [
69+
"https://github.com/bazelbuild/buildtools/archive/refs/tags/4.2.2.tar.gz",
70+
],
71+
)

third_party/check.BUILD

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ cmake(
2323
lib_source = ":srcs",
2424
linkopts = select({
2525
"@bazel_tools//src/conditions:darwin": ["-lpthread"],
26-
"//conditions:default": ["-lpthread", "-lrt"],
26+
"//conditions:default": [
27+
"-lpthread",
28+
"-lrt",
29+
],
2730
}),
2831
out_static_libs = select({
2932
"@bazel_tools//src/conditions:windows": ["check.lib"],

0 commit comments

Comments
 (0)