From 5f452e81d8125127c32ff9552d1c61b055797b74 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Mon, 25 Oct 2021 15:54:30 +0530 Subject: [PATCH 1/8] introduce action --- .github/workflow/bazel_build.yml | 38 ++++++++++++++++++++++++++++++++ .gitignore | 1 + 2 files changed, 39 insertions(+) create mode 100644 .github/workflow/bazel_build.yml create mode 100644 .gitignore diff --git a/.github/workflow/bazel_build.yml b/.github/workflow/bazel_build.yml new file mode 100644 index 0000000..ac99c1d --- /dev/null +++ b/.github/workflow/bazel_build.yml @@ -0,0 +1,38 @@ +# Contains job corresponding to bazel build. + +name: Bazel Build + +on: + workflow_dispatch: + pull_request: + push: + branches: + # Push events on develop branch + - develop + +jobs: + bazel_build_app: + name: Build Binary with Bazel + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04] + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up JDK 9 + uses: actions/setup-java@v1 + with: + java-version: 9 + + - name: Set up Bazel + uses: abhinavsingh/setup-bazel@v3 + with: + version: 4.0.0 + + # Note that caching only works on non-forks. + - name: Build Oppia Proto API + run: | + bazel build -- //:android_protos diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ac51a05 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bazel-* From 1920a332176a3b5bb6c1f49156edc58ee9ec846a Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Mon, 25 Oct 2021 15:59:53 +0530 Subject: [PATCH 2/8] nit fix --- .github/{workflow => workflows}/bazel_build.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflow => workflows}/bazel_build.yml (100%) diff --git a/.github/workflow/bazel_build.yml b/.github/workflows/bazel_build.yml similarity index 100% rename from .github/workflow/bazel_build.yml rename to .github/workflows/bazel_build.yml From 91d29dc89fdc708eabca4ebc074b3ee2a95ab256 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Mon, 25 Oct 2021 16:19:56 +0530 Subject: [PATCH 3/8] added buildifier --- BUILD | 11 +++- WORKSPACE | 46 +++++++++++++ proto/v1/api/BUILD | 8 +-- proto/v1/structure/BUILD | 4 +- proto/v1/versions/BUILD.bazel | 4 +- repo/deps.bzl | 117 ++++++++++++++++++---------------- repo/toolchains.bzl | 27 ++++---- 7 files changed, 137 insertions(+), 80 deletions(-) diff --git a/BUILD b/BUILD index 993d07a..7a10cc0 100644 --- a/BUILD +++ b/BUILD @@ -4,9 +4,14 @@ public, importable API should be defined here (and all such libraries should be nowhere else). """ +load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier") load("@rules_proto//proto:defs.bzl", "proto_library") load("@rules_java//java:defs.bzl", "java_lite_proto_library", "java_proto_library") +buildifier( + name = "buildifier", +) + package_group( name = "api_visibility", packages = [ @@ -30,9 +35,9 @@ proto_library( name = "android_protos", visibility = ["//visibility:public"], deps = [ - "//proto/v1/api:android_proto", - "//proto/v1/structure:structure_proto", - "//proto/v1/versions:versions_proto", + "//proto/v1/api:android_proto", + "//proto/v1/structure:structure_proto", + "//proto/v1/versions:versions_proto", ], ) diff --git a/WORKSPACE b/WORKSPACE index b7156f6..de62766 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -2,6 +2,7 @@ The top-level WORKSPACE definition for the Oppia proto API Bazel workspace. """ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("//repo:deps.bzl", "initializeDepsForWorkspace") initializeDepsForWorkspace() @@ -9,3 +10,48 @@ initializeDepsForWorkspace() load("//repo:toolchains.bzl", "initializeToolchainsForWorkspace") initializeToolchainsForWorkspace() + +# 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 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip", + ], +) + +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") + +go_rules_dependencies() + +go_register_toolchains(version = "1.17.2") + +http_archive( + name = "bazel_gazelle", + sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.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() + +load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") + +protobuf_deps() + +http_archive( + name = "com_github_bazelbuild_buildtools", + sha256 = "ae34c344514e08c23e90da0e2d6cb700fcd28e80c02e23e4d5715dddcb42f7b3", + strip_prefix = "buildtools-4.2.2", + urls = [ + "https://github.com/bazelbuild/buildtools/archive/refs/tags/4.2.2.tar.gz", + ], +) diff --git a/proto/v1/api/BUILD b/proto/v1/api/BUILD index 2e4da12..a344059 100644 --- a/proto/v1/api/BUILD +++ b/proto/v1/api/BUILD @@ -7,11 +7,11 @@ load("@rules_proto//proto:defs.bzl", "proto_library") proto_library( name = "android_proto", srcs = ["android.proto"], - visibility = ["//:api_visibility"], - strip_import_prefix = "", # Strip the default file prefix so that it may be redefined. import_prefix = "org/oppia/proto/v1/api", # Make directory prefix match declared package. + strip_import_prefix = "", # Strip the default file prefix so that it may be redefined. + visibility = ["//:api_visibility"], deps = [ - "//proto/v1/structure:structure_proto", - "//proto/v1/versions:versions_proto", + "//proto/v1/structure:structure_proto", + "//proto/v1/versions:versions_proto", ], ) diff --git a/proto/v1/structure/BUILD b/proto/v1/structure/BUILD index 44cdea0..3dd66be 100644 --- a/proto/v1/structure/BUILD +++ b/proto/v1/structure/BUILD @@ -17,13 +17,13 @@ proto_library( "state.proto", "topic_summary.proto", ], - strip_import_prefix = "", # Strip the default file prefix so that it may be redefined. import_prefix = "org/oppia/proto/v1/structure", # Make directory prefix match declared package. + strip_import_prefix = "", # Strip the default file prefix so that it may be redefined. visibility = [ "//:api_visibility", "//:proto_impl_visibility", ], deps = [ - "//proto/v1/versions:versions_proto", + "//proto/v1/versions:versions_proto", ], ) diff --git a/proto/v1/versions/BUILD.bazel b/proto/v1/versions/BUILD.bazel index 102377e..51978ac 100644 --- a/proto/v1/versions/BUILD.bazel +++ b/proto/v1/versions/BUILD.bazel @@ -11,13 +11,13 @@ proto_library( "api_versions.proto", "structure_versions.proto", ], - strip_import_prefix = "", # Strip the default file prefix so that it may be redefined. import_prefix = "org/oppia/proto/v1/versions", # Make directory prefix match declared package. + strip_import_prefix = "", # Strip the default file prefix so that it may be redefined. visibility = [ "//:api_visibility", "//:proto_impl_visibility", ], deps = [ - "@com_google_protobuf//:descriptor_proto", + "@com_google_protobuf//:descriptor_proto", ], ) diff --git a/repo/deps.bzl b/repo/deps.bzl index e65d5a8..1e284d0 100644 --- a/repo/deps.bzl +++ b/repo/deps.bzl @@ -8,80 +8,85 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # Note to developers: Please keep this dict sorted by key to make it easier to find dependencies. _DEPENDENCY_VERSIONS = { - "rules_python": { - "sha": "934c9ceb552e84577b0faf1e5a2f0450314985b4d8712b2b70717dc679fdc01b", - "url": "https://github.com/bazelbuild/rules_python/releases/download/{0}/rules_python-{0}.tar.gz", - "version": "0.3.0", - }, - "com_google_protobuf": { - "sha": "c6003e1d2e7fefa78a3039f19f383b4f3a61e81be8c19356f85b6461998ad3db", - "strip_prefix": "protobuf-{0}", - "url": "https://github.com/protocolbuffers/protobuf/archive/v{0}.tar.gz", - "version": "3.17.3", - }, - "rules_proto": { - # Note that rules_proto doesn't have any shipped versions, so the workspace needs to pin to a - # specific commit hash. - "sha": "602e7161d9195e50246177e7c55b2f39950a9cf7366f74ed5f22fd45750cd208", - "strip_prefix": "rules_proto-{0}", - "url": "https://github.com/bazelbuild/rules_proto/archive/{0}.tar.gz", - "version": "97d8af4dc474595af3900dd85cb3a29ad28cc313", - }, - "rules_java": { - "sha": "220b87d8cfabd22d1c6d8e3cdb4249abd4c93dcc152e0667db061fb1b957ee68", - "url": "https://github.com/bazelbuild/rules_java/releases/download/{0}/rules_java-{0}.tar.gz", - "version": "0.1.1", - }, + "rules_python": { + "sha": "934c9ceb552e84577b0faf1e5a2f0450314985b4d8712b2b70717dc679fdc01b", + "url": "https://github.com/bazelbuild/rules_python/releases/download/{0}/rules_python-{0}.tar.gz", + "version": "0.3.0", + }, + "com_google_protobuf": { + "sha": "c6003e1d2e7fefa78a3039f19f383b4f3a61e81be8c19356f85b6461998ad3db", + "strip_prefix": "protobuf-{0}", + "url": "https://github.com/protocolbuffers/protobuf/archive/v{0}.tar.gz", + "version": "3.17.3", + }, + "rules_proto": { + # Note that rules_proto doesn't have any shipped versions, so the workspace needs to pin to a + # specific commit hash. + "sha": "602e7161d9195e50246177e7c55b2f39950a9cf7366f74ed5f22fd45750cd208", + "strip_prefix": "rules_proto-{0}", + "url": "https://github.com/bazelbuild/rules_proto/archive/{0}.tar.gz", + "version": "97d8af4dc474595af3900dd85cb3a29ad28cc313", + }, + "rules_java": { + "sha": "220b87d8cfabd22d1c6d8e3cdb4249abd4c93dcc152e0667db061fb1b957ee68", + "url": "https://github.com/bazelbuild/rules_java/releases/download/{0}/rules_java-{0}.tar.gz", + "version": "0.1.1", + }, + "io_bazel_rules_go": { + "sha": "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f", + "url": "", + }, } def _setUpHttpArchiveDependency(name): - metadata = _DEPENDENCY_VERSIONS[name] - sha = metadata["sha"] - strip_prefix = metadata.get("strip_prefix") - url = metadata["url"] - version = metadata["version"] + metadata = _DEPENDENCY_VERSIONS[name] + sha = metadata["sha"] + strip_prefix = metadata.get("strip_prefix") + url = metadata["url"] + version = metadata["version"] - formatted_strip_prefix = strip_prefix.format(version) if not (strip_prefix == None) else None + formatted_strip_prefix = strip_prefix.format(version) if not (strip_prefix == None) else None - http_archive( - name = name, - urls = [url.format(version)], - sha256 = sha, - strip_prefix = formatted_strip_prefix, - ) + http_archive( + name = name, + urls = [url.format(version)], + sha256 = sha, + strip_prefix = formatted_strip_prefix, + ) def _setUpPython(): - _setUpHttpArchiveDependency(name = "rules_python") + _setUpHttpArchiveDependency(name = "rules_python") def _setUpProtobuf(): - _setUpHttpArchiveDependency(name = "com_google_protobuf") + _setUpHttpArchiveDependency(name = "com_google_protobuf") def _setUpRulesProto(): - _setUpHttpArchiveDependency(name = "rules_proto") + _setUpHttpArchiveDependency(name = "rules_proto") def _setUpRulesJava(): - _setUpHttpArchiveDependency(name = "rules_java") + _setUpHttpArchiveDependency(name = "rules_java") def initializeDepsForWorkspace(): - """ - Loads the dependencies needed to be able to build the Oppia proto API project. + """ + Loads the dependencies needed to be able to build the Oppia proto API project. - Note that this must be called after loading in this deps file, for example: + Note that this must be called after loading in this deps file, for example: - load("//repo:deps.bzl", "initializeDepsForWorkspace") - initializeDepsForWorkspace() + load("//repo:deps.bzl", "initializeDepsForWorkspace") + initializeDepsForWorkspace() - Note also that toolchains may need to be set up after loading this dependencies (see - toolchains.bzl). - """ - # Set up Python (as a prerequisite dependency for Protobuf). - _setUpPython() + Note also that toolchains may need to be set up after loading this dependencies (see + toolchains.bzl). + """ - # Set up proto & its toolchain. - _setUpProtobuf() + # Set up Python (as a prerequisite dependency for Protobuf). + _setUpPython() - # Set up rules_proto to allow defining proto libraries. - _setUpRulesProto() + # Set up proto & its toolchain. + _setUpProtobuf() - # Set up rules_java to enable the Java proto & Java proto lite rules. - _setUpRulesJava() + # Set up rules_proto to allow defining proto libraries. + _setUpRulesProto() + + # Set up rules_java to enable the Java proto & Java proto lite rules. + _setUpRulesJava() diff --git a/repo/toolchains.bzl b/repo/toolchains.bzl index 0d818cf..70ad1bd 100644 --- a/repo/toolchains.bzl +++ b/repo/toolchains.bzl @@ -8,20 +8,21 @@ load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_ load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains") def initializeToolchainsForWorkspace(): - """ - Initializes the toolchains needed to be able to build the Oppia proto API project. + """ + Initializes the toolchains needed to be able to build the Oppia proto API project. - Note that this must be called after loading in this toolchains file, for example: + Note that this must be called after loading in this toolchains file, for example: - load("//repo:toolchains.bzl", "initializeToolchainsForWorkspace") - initializeToolchainsForWorkspace() + load("//repo:toolchains.bzl", "initializeToolchainsForWorkspace") + initializeToolchainsForWorkspace() - Note also that this can't be called until the dependencies themselves are loaded (see deps.bzl). - """ - # Set up the toolchains for rules_proto. - rules_proto_dependencies() - rules_proto_toolchains() + Note also that this can't be called until the dependencies themselves are loaded (see deps.bzl). + """ - # Set up the toolchains for rules_java. - rules_java_dependencies() - rules_java_toolchains() + # Set up the toolchains for rules_proto. + rules_proto_dependencies() + rules_proto_toolchains() + + # Set up the toolchains for rules_java. + rules_java_dependencies() + rules_java_toolchains() From bb7987c5b76ccf11b60694c1d4b49c00b1c58469 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Mon, 25 Oct 2021 16:20:48 +0530 Subject: [PATCH 4/8] nit fix --- repo/deps.bzl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/repo/deps.bzl b/repo/deps.bzl index 1e284d0..2aac8aa 100644 --- a/repo/deps.bzl +++ b/repo/deps.bzl @@ -32,10 +32,6 @@ _DEPENDENCY_VERSIONS = { "url": "https://github.com/bazelbuild/rules_java/releases/download/{0}/rules_java-{0}.tar.gz", "version": "0.1.1", }, - "io_bazel_rules_go": { - "sha": "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f", - "url": "", - }, } def _setUpHttpArchiveDependency(name): From 0856bd5b6f0fcd415f2559da1b3ecd57e1e60b09 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Mon, 25 Oct 2021 16:26:17 +0530 Subject: [PATCH 5/8] checking if 4.2 bazel works --- .github/workflows/bazel_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bazel_build.yml b/.github/workflows/bazel_build.yml index ac99c1d..e4f6a6a 100644 --- a/.github/workflows/bazel_build.yml +++ b/.github/workflows/bazel_build.yml @@ -30,7 +30,7 @@ jobs: - name: Set up Bazel uses: abhinavsingh/setup-bazel@v3 with: - version: 4.0.0 + version: 4.2.0 # Note that caching only works on non-forks. - name: Build Oppia Proto API From 2e1b58ddb3ccb17f62182e6060bf0c30a5c24f34 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Mon, 25 Oct 2021 21:41:37 +0530 Subject: [PATCH 6/8] added lint check --- .github/workflows/bazel_build.yml | 1 - .github/workflows/lint.yml | 37 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/bazel_build.yml b/.github/workflows/bazel_build.yml index e4f6a6a..c2469e3 100644 --- a/.github/workflows/bazel_build.yml +++ b/.github/workflows/bazel_build.yml @@ -32,7 +32,6 @@ jobs: with: version: 4.2.0 - # Note that caching only works on non-forks. - name: Build Oppia Proto API run: | bazel build -- //:android_protos diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..f895d56 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,37 @@ +# Contains job corresponding to lint check of Bazel files. + +name: Lint check + +on: + workflow_dispatch: + pull_request: + push: + branches: + # Push events on develop branch + - develop + +jobs: + bazel_build_app: + name: Build Binary with Bazel + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04] + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up JDK 9 + uses: actions/setup-java@v1 + with: + java-version: 9 + + - name: Set up Bazel + uses: abhinavsingh/setup-bazel@v3 + with: + version: 4.2.0 + + - name: Lint check using Buildifier + run: | + bazel run -- //:buildifier From 66e8e3fa301b62d4475d3491156ab734ad0abcd4 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Mon, 25 Oct 2021 21:43:49 +0530 Subject: [PATCH 7/8] nit fix --- .github/workflows/lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f895d56..3752701 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,8 +11,8 @@ on: - develop jobs: - bazel_build_app: - name: Build Binary with Bazel + lint_check: + name: Lint check runs-on: ${{ matrix.os }} strategy: matrix: From d1d14e040058978a03c46d622c6b40efec2ae2f9 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Thu, 28 Oct 2021 14:23:30 +0530 Subject: [PATCH 8/8] using deps unsuccessfull --- WORKSPACE | 58 +++++++++++---------------------------------------- repo/deps.bzl | 45 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 47 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index de62766..1193649 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -2,56 +2,22 @@ The top-level WORKSPACE definition for the Oppia proto API Bazel workspace. """ -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("//repo:deps.bzl", "initializeDepsForWorkspace") initializeDepsForWorkspace() +load("//repo:deps.bzl", "initializeGoDeps") +initializeGoDeps() + +load("//repo:deps.bzl", "initializeBazelGazell") +initializeBazelGazell() + +load("//repo:deps.bzl", "initializeProtobuf") +initializeProtobuf() + +load("//repo:deps.bzl", "initializeBazelBuildTools") +initializeBazelBuildTools() + load("//repo:toolchains.bzl", "initializeToolchainsForWorkspace") initializeToolchainsForWorkspace() - -# 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 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip", - "https://github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip", - ], -) - -load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") - -go_rules_dependencies() - -go_register_toolchains(version = "1.17.2") - -http_archive( - name = "bazel_gazelle", - sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.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() - -load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") - -protobuf_deps() - -http_archive( - name = "com_github_bazelbuild_buildtools", - sha256 = "ae34c344514e08c23e90da0e2d6cb700fcd28e80c02e23e4d5715dddcb42f7b3", - strip_prefix = "buildtools-4.2.2", - urls = [ - "https://github.com/bazelbuild/buildtools/archive/refs/tags/4.2.2.tar.gz", - ], -) diff --git a/repo/deps.bzl b/repo/deps.bzl index 2aac8aa..fe22222 100644 --- a/repo/deps.bzl +++ b/repo/deps.bzl @@ -5,6 +5,9 @@ instructions in the README for more details. """ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") +load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") # Note to developers: Please keep this dict sorted by key to make it easier to find dependencies. _DEPENDENCY_VERSIONS = { @@ -32,6 +35,22 @@ _DEPENDENCY_VERSIONS = { "url": "https://github.com/bazelbuild/rules_java/releases/download/{0}/rules_java-{0}.tar.gz", "version": "0.1.1", }, + "io_bazel_rules_go": { + "sha": "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f", + "url": "https://github.com/bazelbuild/rules_go/releases/download/{0}/rules_go-{0}.zip", + "version": "v0.29.0", + }, + "bazel_gazelle": { + "sha": "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb", + "url": "https://github.com/bazelbuild/bazel-gazelle/releases/download/{0}/bazel-gazelle-{0}.tar.gz", + "version": "v0.24.0", + }, + "com_github_bazelbuild_buildtools": { + "sha": "ae34c344514e08c23e90da0e2d6cb700fcd28e80c02e23e4d5715dddcb42f7b3", + "strip_prefix": "buildtools-{0}", + "url": "https://github.com/bazelbuild/buildtools/archive/refs/tags/{0}.tar.gz", + "version": "4.2.2", + }, } def _setUpHttpArchiveDependency(name): @@ -62,6 +81,15 @@ def _setUpRulesProto(): def _setUpRulesJava(): _setUpHttpArchiveDependency(name = "rules_java") +def _setUpIoBazelRulesGo(): + _setUpHttpArchiveDependency(name ="io_bazel_rules_go") + +def _setUpBazelGazell(): + _setUpHttpArchiveDependency(name ="bazel_gazelle") + +def _setUpBazelBuildTools(): + _setUpHttpArchiveDependency(name ="com_github_bazelbuild_buildtools") + def initializeDepsForWorkspace(): """ Loads the dependencies needed to be able to build the Oppia proto API project. @@ -78,7 +106,6 @@ def initializeDepsForWorkspace(): # Set up Python (as a prerequisite dependency for Protobuf). _setUpPython() - # Set up proto & its toolchain. _setUpProtobuf() # Set up rules_proto to allow defining proto libraries. @@ -86,3 +113,19 @@ def initializeDepsForWorkspace(): # Set up rules_java to enable the Java proto & Java proto lite rules. _setUpRulesJava() + + _setUpIoBazelRulesGo() + +def initializeGoDeps(): + go_rules_dependencies() + go_register_toolchains(version = "1.17.2") + +def initializeBazelGazell(): + _setUpBazelGazell() + gazelle_dependencies() + +def initializeProtobuf(): + protobuf_deps() + +def initializeBazelBuildTools(): + _setUpBazelBuildTools()