-
Notifications
You must be signed in to change notification settings - Fork 32
/
BUILD.bazel
227 lines (198 loc) · 6.06 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
load("@bazel_gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_missing_pkgs", "bzlformat_pkg")
load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy", "tidy_all")
load("@cgrindel_bazel_starlib//markdown:defs.bzl", "markdown_pkg")
load("@cgrindel_bazel_starlib//shlib/rules:execute_binary.bzl", "execute_binary")
load("@cgrindel_bazel_starlib//updatesrc:defs.bzl", "updatesrc_update_all")
load(
"@rules_bazel_integration_test//bazel_integration_test:defs.bzl",
"integration_test_utils",
)
load("//ci:defs.bzl", "ci_workflow")
# Allow docs to access the extensions.bzl
exports_files(["extensions.bzl"])
# MARK: - Bazel Starlark Lint and Formatting
bzlformat_pkg(name = "bzlformat")
bzlformat_missing_pkgs(
name = "bzlformat_missing_pkgs",
)
# MARK: - Tidy / 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 go_update_repos
":go_mod_tidy",
":go_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(
name = "upgrade_go_deps",
targets = [
":go_get_latest",
":go_mod_tidy",
":go_update_repos",
],
)
tidy_all(name = "tidy_all")
tidy_all(
name = "tidy_modified",
mode = "modified",
)
# MARK: - Gazelle
gazelle_binary(
name = "gazelle_bin",
languages = DEFAULT_LANGUAGES + [
"@bazel_skylib_gazelle_plugin//bzl",
],
)
# gazelle:prefix github.com/cgrindel/rules_swift_package_manager
# gazelle:go_naming_convention import
# gazelle:go_naming_convention_external go_default_library
# gazelle:resolve_regexp go ^github.com/bazelbuild/bazel-gazelle/(.*)$ @bazel_gazelle//$1:go_default_library
gazelle(
name = "update_build_files",
command = "fix",
gazelle = ":gazelle_bin",
)
execute_binary(
name = "go_update_repos",
arguments = [
"-gazelle_bin_target=//:gazelle_bin",
"-from_file=go.mod",
"-go_deps_file=go_deps.bzl",
"-macro_name=swift_bazel_go_dependencies",
"-build_external=external",
],
binary = "//tools/update_go_repos",
execute_in_workspace = True,
)
# MARK: - Golang
execute_binary(
name = "go_mod_tidy",
arguments = [
"mod",
"tidy",
],
binary = "@io_bazel_rules_go//go",
execute_in_workspace = True,
)
execute_binary(
name = "go_get_latest",
arguments = [
"get",
"-t",
"-u",
"./...",
],
binary = "@io_bazel_rules_go//go",
execute_in_workspace = True,
)
bzl_library(
name = "go_deps",
srcs = ["go_deps.bzl"],
visibility = ["//visibility:public"],
deps = ["@bazel_gazelle//:deps"],
)
# MARK: - Markdown
markdown_pkg(name = "markdown")
# MARK: - Integration Test
filegroup(
name = "all_files",
srcs = glob(
["*"],
exclude = [
".git",
".gitignore",
],
),
visibility = ["//:__subpackages__"],
)
# Files needed at runtime. Do not include any bzlmod e2e test files here. They
# should only be added to the release archive (//release:archive).
filegroup(
name = "runtime_files",
# Include every package that is required by the child workspaces.
srcs = [
":all_files",
"//ci:all_files",
"//ci/internal:all_files",
"//config_settings/bazel/apple_platform_type:all_files",
"//config_settings/bazel/compilation_mode:all_files",
"//config_settings/spm/configuration:all_files",
"//config_settings/spm/platform:all_files",
"//config_settings/spm/platform_configuration:all_files",
"//gazelle:all_files",
"//gazelle/internal/jsonutils:all_files",
"//gazelle/internal/pathdistance:all_files",
"//gazelle/internal/reslog:all_files",
"//gazelle/internal/spdesc:all_files",
"//gazelle/internal/spdump:all_files",
"//gazelle/internal/spreso:all_files",
"//gazelle/internal/stringslices:all_files",
"//gazelle/internal/swift:all_files",
"//gazelle/internal/swiftbin:all_files",
"//gazelle/internal/swiftcfg:all_files",
"//gazelle/internal/swiftpkg:all_files",
"//gazelle/internal/updmarker:all_files",
"//swiftpkg:all_files",
"//swiftpkg/bzlmod:all_files",
"//swiftpkg/internal:all_files",
"//swiftpkg/internal/modulemap_parser:all_files",
"//tools/swift_deps_index:all_files",
"//tools/swift_deps_index/cmd:all_files",
],
visibility = ["//:__subpackages__"],
)
test_suite(
name = "smoke_integration_tests",
tags = integration_test_utils.DEFAULT_INTEGRATION_TEST_TAGS,
tests = [
"//bzlmod:e2e_test",
"//examples:smoke_integration_tests",
"//release:archive_test",
],
visibility = ["//:__subpackages__"],
)
test_suite(
name = "all_integration_tests",
tags = integration_test_utils.DEFAULT_INTEGRATION_TEST_TAGS,
tests = [
":smoke_integration_tests",
"//examples:all_integration_tests",
],
visibility = ["//:__subpackages__"],
)
# MARK: - CI Workflow
ci_workflow(
name = "ci_workflow",
test_params = [
"//bzlmod:e2e_test_params",
"//release:archive_test_params",
"//examples:all_example_test_params",
],
workflow_yml = ".github/workflows/ci.yml",
)
bzl_library(
name = "extensions",
srcs = ["extensions.bzl"],
visibility = ["//visibility:public"],
deps = ["//swiftpkg/bzlmod:swift_deps"],
)