Skip to content

Commit 1e32057

Browse files
author
Justin Poehnelt
authored
build: simplify bazel usage (#336)
This change includes @bazel/bazelisk as a dependency and runs all build/test execution through NPM removing dependency on a local Bazel installation. Also changes the following: - pre/post build hooks - uses rimraf for cross platform compatibility - removes bazel cache as it is not necessary
1 parent f9686f5 commit 1e32057

7 files changed

Lines changed: 7687 additions & 57 deletions

File tree

.github/workflows/release.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,9 @@ jobs:
2828
- uses: actions/checkout@v2
2929
with:
3030
token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }}
31-
- name: Setup Bazel Cache
32-
run: |
33-
BAZEL_CACHE_SERVICE_ACCOUNT_FILE=$(mktemp)
34-
echo "${BAZEL_CACHE_SERVICE_ACCOUNT}" > "${BAZEL_CACHE_SERVICE_ACCOUNT_FILE}"
35-
echo "build --google_credentials=${BAZEL_CACHE_SERVICE_ACCOUNT_FILE}" >> .bazelrc.user
36-
echo "build --remote_http_cache=https://storage.googleapis.com/${BAZEL_CACHE_BUCKET}" >> .bazelrc
37-
env:
38-
BAZEL_CACHE_BUCKET: ${{secrets.SYNCED_BAZEL_CACHE_BUCKET}}
39-
BAZEL_CACHE_SERVICE_ACCOUNT: ${{secrets.SYNCED_BAZEL_CACHE_SERVICE_ACCOUNT}}
40-
- run: bazel build --jobs 8 //...
41-
- run: bazel test --jobs 8 //...
31+
- run: npm ci
32+
- run: npm run build -- --jobs 8
33+
- run: npm test -- --jobs 8
4234
- name: Semantic Release
4335
uses: cycjimmy/semantic-release-action@v2
4436
with:

.github/workflows/test.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,9 @@ jobs:
2525
if: github.actor != 'dependabot[bot]'
2626
- uses: actions/checkout@v2
2727
if: github.actor == 'dependabot[bot]'
28-
- name: Setup Bazel Cache
29-
run: |
30-
BAZEL_CACHE_SERVICE_ACCOUNT_FILE=$(mktemp)
31-
echo "${BAZEL_CACHE_SERVICE_ACCOUNT}" > "${BAZEL_CACHE_SERVICE_ACCOUNT_FILE}"
32-
echo "build --google_credentials=${BAZEL_CACHE_SERVICE_ACCOUNT_FILE}" >> .bazelrc.user
33-
echo "build --remote_http_cache=https://storage.googleapis.com/${BAZEL_CACHE_BUCKET}" >> .bazelrc.user
34-
env:
35-
BAZEL_CACHE_BUCKET: ${{secrets.SYNCED_BAZEL_CACHE_BUCKET}}
36-
BAZEL_CACHE_SERVICE_ACCOUNT: ${{secrets.SYNCED_BAZEL_CACHE_SERVICE_ACCOUNT}}
37-
if: github.actor != 'dependabot[bot]'
38-
- run: bazel build --profile /tmp/bazel-profile-build.gz --jobs 8 //...
39-
- run: bazel test --jobs 8 //...
28+
- run: npm ci
29+
- run: npm run build -- --profile /tmp/bazel-profile-build.gz --jobs 8
30+
- run: npm test -- --jobs 8
4031
- name: Upload Bazel profiles
4132
uses: actions/upload-artifact@v2
4233
with:

.github/workflows/update-dist.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,7 @@ jobs:
2525
token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }}
2626
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
2727
ref: ${{ github.event.client_payload.pull_request.head.ref }}
28-
- name: Setup Bazel Cache
29-
run: |
30-
BAZEL_CACHE_SERVICE_ACCOUNT_FILE=$(mktemp)
31-
echo "${BAZEL_CACHE_SERVICE_ACCOUNT}" > "${BAZEL_CACHE_SERVICE_ACCOUNT_FILE}"
32-
echo "build --google_credentials=${BAZEL_CACHE_SERVICE_ACCOUNT_FILE}" >> .bazelrc.user
33-
echo "build --remote_http_cache=https://storage.googleapis.com/${BAZEL_CACHE_BUCKET}" >> .bazelrc
34-
env:
35-
BAZEL_CACHE_BUCKET: ${{secrets.SYNCED_BAZEL_CACHE_BUCKET}}
36-
BAZEL_CACHE_SERVICE_ACCOUNT: ${{secrets.SYNCED_BAZEL_CACHE_SERVICE_ACCOUNT}}
37-
- run: bazel build --jobs 8 //...
28+
- run: npm ci
3829
- name: Update dist
3930
run: |
4031
npm run build

BUILD.bazel

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ pkg_tar(
4343
],
4444
)
4545

46+
filegroup(
47+
name = "outputs",
48+
srcs = [
49+
":dist",
50+
":parameters",
51+
],
52+
)
53+
4654
# test diff
4755
filegroup(
4856
name = "dist_files",
@@ -127,6 +135,6 @@ genrule(
127135
"@npm//yargs",
128136
],
129137
outs = ["parameters.yml"],
138+
cmd = "$(location //rules:parameters) --output $@ $(locations //specification:openapi3)",
130139
tools = ["//rules:parameters"],
131-
cmd = "$(location //rules:parameters) --output $@ $(locations //specification:openapi3)"
132-
)
140+
)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ An OpenAPI specification for Google Maps Platform APIs.
3232
The repository makes use of [Bazel](https://bazel.build/) to generate outputs from the specification and sample requests.
3333

3434
### Build and test
35+
1. `npm i`
3536

3637
1. `npm run build`
3738

@@ -51,7 +52,7 @@ The repository makes use of [Bazel](https://bazel.build/) to generate outputs fr
5152

5253
1. `npm run build:responses` (optional)
5354

54-
> **Note**: This is an optional step requiring an API key. Set the `GOOGLE_MAPS_API_KEY` environmental variable before running. **Hint**: Use a `.bazelrc.user` file at the root of this project.
55+
> **Note**: This is an optional step requiring an API key. Set the `GOOGLE_MAPS_API_KEY` environmental variable before running.
5556
5657
> **Note**: This step only needs to run when the generation code or sample requests have been updated.
5758

0 commit comments

Comments
 (0)