Skip to content

Commit 905c0fe

Browse files
authored
chore: add bazel caching to integration tests (#1058)
The integration test CI takes ~8 minutes to run, most of which is installing bazel and setting up tool dependencies. It is a massive time optimization to cache this work and prevent its re-creation on subsequent builds.
1 parent d3556d7 commit 905c0fe

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

.github/workflows/tests.yaml

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -312,32 +312,36 @@ jobs:
312312
run: nox -s fragment-${{ matrix.python }}
313313
integration:
314314
runs-on: ubuntu-latest
315+
container: gcr.io/gapic-images/googleapis-bazel:20210105
315316
steps:
316317
- name: Cancel Previous Runs
317318
uses: styfle/cancel-workflow-action@0.7.0
318319
with:
319320
access_token: ${{ github.token }}
320321
- uses: actions/checkout@v2
321-
- name: Set up Python 3.8
322-
uses: actions/setup-python@v2
322+
- name: Cache Bazel files
323+
id: cache-bazel
324+
uses: actions/cache@v2
323325
with:
324-
python-version: 3.8
325-
- name: Install system dependencies.
326+
path: ~/.cache/bazel
327+
# Note: if the container is updated, the key needs to be updated as well.
328+
key: ${{ runner.os }}-bazel-20210105-${{ secrets.CACHE_VERSION }}
329+
- name: Cache not found
330+
if: steps.cache-bazel.outputs.cache-hit != 'true'
326331
run: |
327-
sudo apt-get update
328-
sudo apt-get install -y curl pandoc unzip gcc
329-
- name: Install Bazel
332+
echo "No cache found."
333+
- name: Cache found
334+
if: steps.cache-bazel.outputs.cache-hit == 'true'
330335
run: |
331-
wget -q "https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/$BAZEL_BINARY"
332-
wget -q "https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/$BAZEL_BINARY.sha256"
333-
sha256sum -c "$BAZEL_BINARY.sha256"
334-
sudo dpkg -i "$BAZEL_BINARY"
335-
env:
336-
BAZEL_VERSION: 3.5.0
337-
BAZEL_BINARY: bazel_3.5.0-linux-x86_64.deb
336+
echo -n "Cache found. Cache size: "
337+
du -sh ~/.cache/bazel
338+
echo "If the cache seems broken, update the CACHE_VERSION secret in"
339+
echo "https://github.com/googleapis/gapic-generator-python/settings/secrets/actions"
340+
echo "(use any random string, any GUID will work)"
341+
echo "and it will start over with a clean cache."
342+
echo "The old one will disappear after 7 days."
338343
- name: Integration Tests
339344
run: bazel test tests/integration:asset tests/integration:credentials tests/integration:logging tests/integration:redis
340-
341345
style-check:
342346
runs-on: ubuntu-latest
343347
steps:

0 commit comments

Comments
 (0)