-
Notifications
You must be signed in to change notification settings - Fork 4
/
BUILD.bazel
265 lines (231 loc) · 6.43 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
load("@bazel_gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load(
"//bzlformat:defs.bzl",
"bzlformat_missing_pkgs",
"bzlformat_pkg",
)
load("//bzltidy:defs.bzl", "tidy", "tidy_all")
load("//ci:defs.bzl", "ci_workflow")
load("//shlib/rules:execute_binary.bzl", "execute_binary")
load("//tests:integration_test_common.bzl", "INTEGRATION_TEST_TAGS")
load("//updatesrc:defs.bzl", "updatesrc_update_all")
# MARK: - Gazelle
gazelle_binary(
name = "gazelle_bin",
languages = DEFAULT_LANGUAGES + [
"@bazel_skylib_gazelle_plugin//bzl",
],
)
# gazelle:prefix github.com/cgrindel/bazel-starlib
# gazelle:go_naming_convention import
gazelle(
name = "update_build_files",
gazelle = ":gazelle_bin",
)
gazelle(
name = "gazelle_update_repos",
args = [
"-from_file=go.mod",
"-to_macro=go_deps.bzl%bazel_starlib_go_dependencies",
"-build_external=external",
"-prune",
],
command = "update-repos",
)
# MARK: - Bazel Starlark Lint and Formatting
bzlformat_pkg(name = "bzlformat")
bzlformat_missing_pkgs(name = "bzlformat_missing_pkgs")
# MARK: - Update Source Files
updatesrc_update_all(name = "update_all")
tidy(
name = "tidy",
targets = [
# Remove the child workspace symlinks before doing some of the other
# operations that my experience infinite symlink expansion errors.
"@rules_bazel_integration_test//tools:remove_child_wksp_bazel_symlinks",
"@rules_bazel_integration_test//tools:update_deleted_packages",
":bzlformat_missing_pkgs_fix",
":update_all",
# Run go mod tidy before we gazelle_update_repos
":go_mod_tidy",
":gazelle_update_repos",
":update_build_files",
],
)
# This is meant to be fast and convenient to quickly update the source files
# with the latest.
tidy(
name = "update_files",
targets = [
":update_all",
":update_build_files",
],
)
tidy_all(name = "tidy_all")
tidy_all(
name = "tidy_modified",
mode = "modified",
)
# MARK: - Golang
execute_binary(
name = "go_mod_tidy",
arguments = [
"mod",
"tidy",
],
binary = "@io_bazel_rules_go//go",
execute_in_workspace = True,
)
# MARK: - Markdown Files
package_group(
name = "markdown_test_visibility",
packages = [
"//tests/repo_markdown_tests/...",
],
)
# GH140: Temporarily disable markdown while adding support for
# --incompatible_disallow_empty_glob.
# load("//markdown:defs.bzl", "markdown_pkg")
# markdown_pkg(
# name = "markdown",
# doc_files_visibility = ["//:markdown_test_visibility"],
# )
# MARK: - Integration Tests
package_group(
name = "integration_test_visibility",
packages = [
"//examples/...",
"//tests/...",
],
)
# Provides the *.bazlerc files for the example workspace integration tests.
filegroup(
name = "shared_bazelrc_files",
srcs = glob(["*.bazelrc"]),
)
filegroup(
name = "all_files",
srcs = glob(
["*"],
exclude = [
".git",
".gitignore",
],
),
visibility = ["//:__subpackages__"],
)
# All of the packages that should be included in the release archive and made
# available to the child workspaces.
_RUNTIME_PKGS = [
"//",
"//bazeldoc",
"//bazeldoc/private",
"//build",
"//bzlformat",
"//bzlformat/private",
"//bzlformat/tools",
"//bzlformat/tools/missing_pkgs",
"//bzllib",
"//bzllib/private",
"//bzlmod",
"//bzlrelease",
"//bzlrelease/private",
"//bzlrelease/tools",
"//bzltidy",
"//bzltidy/private",
"//examples",
"//markdown",
"//markdown/private",
"//markdown/tools",
"//markdown/tools/markdown_toc/cmd/generate_toc",
"//markdown/tools/markdown_toc/mdtoc",
"//shlib/lib",
"//shlib/rules",
"//shlib/rules/private",
"//shlib/tools",
"//updatesrc",
"//updatesrc/private",
]
# The example workspaces use local_repository to reference this workspace.
# This target collects all of the files needed for rules_spm to work in the
# child workspaces.
filegroup(
name = "local_repository_files",
srcs = [
pkg + ":all_files"
for pkg in _RUNTIME_PKGS
],
visibility = [
":integration_test_visibility",
"//:__subpackages__",
],
)
filegroup(
name = "workspace_integration_test_files",
srcs = [
# The example workspaces reference the *.bazelrc files in the parent.
"//:shared_bazelrc_files",
# The example workspaces use local_repository to reference this
# workspace. This target collects all of the files needed for
# rules_spm to work in the child workspaces.
"//:local_repository_files",
],
visibility = [":integration_test_visibility"],
)
_INTEGRATION_TEST_PKGS = [
"//examples",
"//examples/bzlformat",
"//examples/markdown",
"//examples/updatesrc",
"//tests/bzlformat_tests/tools_tests/missing_pkgs_tests",
"//tests/bzlrelease_tests/rules_tests/generate_release_notes_tests",
"//tests/bzlrelease_tests/rules_tests/generate_workspace_snippet_tests",
"//tests/bzlrelease_tests/rules_tests/update_readme_tests",
"//tests/bzlrelease_tests/tools_tests",
"//tests/bzltidy_tests",
"//tests/shlib_tests/lib_tests/git_tests",
"//tests/shlib_tests/lib_tests/github_tests",
"//tests/updatesrc_tests",
]
test_suite(
name = "smoke_integration_tests",
tags = INTEGRATION_TEST_TAGS,
tests = [
"{}:smoke_integration_tests".format(pkg)
for pkg in _INTEGRATION_TEST_PKGS
],
visibility = ["//:__subpackages__"],
)
test_suite(
name = "all_integration_tests",
tags = INTEGRATION_TEST_TAGS,
tests = [
"{}:all_integration_tests".format(pkg)
for pkg in _INTEGRATION_TEST_PKGS
],
visibility = ["//:__subpackages__"],
)
ci_workflow(
name = "ci_workflow",
test_params = [
"{}:all_test_params".format(pkg)
for pkg in _INTEGRATION_TEST_PKGS
],
workflow_yml = ".github/workflows/ci.yml",
)
bzl_library(
name = "deps",
srcs = ["deps.bzl"],
visibility = ["//visibility:public"],
deps = [
"@bazel_tools//tools/build_defs/repo:http.bzl",
"@bazel_tools//tools/build_defs/repo:utils.bzl",
],
)
bzl_library(
name = "go_deps",
srcs = ["go_deps.bzl"],
visibility = ["//visibility:public"],
deps = ["@bazel_gazelle//:deps"],
)