Skip to content

bazel-contrib/setup-bazel

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

setup-bazel

This action allows to properly configure Bazelisk and Bazel on all operating systems and provides an advanced fine-grained caching to improve workflows performance.

Usage

- uses: bazel-contrib/[email protected]
  with:
    # Avoid downloading Bazel every time.
    bazelisk-cache: true
    # Store build cache per workflow.
    disk-cache: ${{ github.workflow }}
    # Share repository cache between workflows.
    repository-cache: true

Inputs

bazelisk-cache

Cache bazelisk downloads based on contents of a .bazelversion file.

Default false.

bazelisk-version

bazelisk version to download and use.

Supports semver specification and ranges. Leave empty to use pre-installed Bazelisk.

Default "".

Examples

Install Bazelisk 1.x

- uses: bazel-contrib/[email protected]
  with:
    bazelisk-version: 1.x

Install exact Bazelisk version

- uses: bazel-contrib/[email protected]
  with:
    bazelisk-version: 1.19.0

bazelrc

Extra contents to write to a user's bazelrc file.

You can use multiline YAML strings.

Default "".

Examples

Enable Bzlmod

- uses: bazel-contrib/[email protected]
  with:
    bazelrc: common --enable_bzlmod

Add colors and timestamps

- uses: bazel-contrib/[email protected]
  with:
    bazelrc: |
      build --color=yes
      build --show_timestamps

disk-cache

Enable disk_cache and store it on GitHub based on contents of BUILD files.

You can also pass a string to use as a cache key to separate caches from different workflows.

Default false.

Examples

Share a single disk cache

- uses: bazel-contrib/[email protected]
  with:
    disk-cache: true

Separate disk caches between workflows

- uses: bazel-contrib/[email protected]
  with:
    disk-cache: ${{ github.workflow }}}

external-cache

Cache external/ repositories based on contents of MODULE.bazel and WORKSPACE files. Only repositories exceeding 10MB are being cached. Each repository is stored in a separate cache.

You can also pass a manifest object where key is the name of the external repository and value is a file (or list of files) which contents are used to calculate cache key. If the value is false, the external repository won't be cached.

Default false.

Examples

Enable external repositories caches

- uses: bazel-contrib/[email protected]
  with:
    external-cache: true

Cache NPM repositories based on package-lock.json contents

- uses: bazel-contrib/[email protected]
  with:
    external-cache: |
      manifest:
        npm: package-lock.json

Do not cache Ruby on Windows

- uses: bazel-contrib/[email protected]
  with:
    external-cache: |
      manifest:
        ruby: ${{ runner.os == 'Windows' && 'false' || 'true' }}

google-credentials

Google Cloud account key to use for remote caching authentication.

Default "".

Examples

Authenticate via key

- uses: bazel-contrib/[email protected]
  with:
    google-credentials: ${{ secrets.GOOGLE_CLOUD_KEY }}

repository-cache

Enable repository_cache and store it on GitHub based on contents of MODULE.bazel and WORKSPACE files.

You can also pass a file (or list of files) which contents are used to calculate cache key.

Default false.

Examples

Store a single repository cache

- uses: bazel-contrib/[email protected]
  with:
    repository-cache: true

Store a repository cache from a custom location

- uses: bazel-contrib/[email protected]
  with:
    repository-cache: examples/gem/WORKSPACE

You can simply replace bazelbuild/setup-bazelisk action with bazel-contrib/setup-bazel. However, if you used a bazel-version input before, you will need to remove it in favor other ways to specify Bazel version.

Development

To build action, run the following command:

$ npm run build

Release

Use Release workflow to cut a new release.