Add better examples in README
This commit is contained in:
parent
299d048546
commit
8b3d6f9169
1 changed files with 134 additions and 62 deletions
194
README.md
194
README.md
|
|
@ -3,6 +3,19 @@
|
||||||
This action allows to properly configure Bazelisk and Bazel on all operating systems
|
This action allows to properly configure Bazelisk and Bazel on all operating systems
|
||||||
and provides an advanced fine-grained caching to improve workflows performance.
|
and provides an advanced fine-grained caching to improve workflows performance.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: p0deje/setup-bazel@0.6.0
|
||||||
|
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
|
## Inputs
|
||||||
|
|
||||||
### `bazelisk-cache`
|
### `bazelisk-cache`
|
||||||
|
|
@ -20,12 +33,56 @@ Leave empty to use [pre-installed Bazelisk][8].
|
||||||
|
|
||||||
Default `""`.
|
Default `""`.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
#### Install Bazelisk 1.x
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: p0deje/setup-bazel@0.6.0
|
||||||
|
with:
|
||||||
|
bazelisk-version: 1.x
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Install exact Bazelisk version
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: p0deje/setup-bazel@0.6.0
|
||||||
|
with:
|
||||||
|
bazelisk-version: 1.19.0
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
### `bazelrc`
|
### `bazelrc`
|
||||||
|
|
||||||
Extra contents to write to a user's [`bazelrc`][4] file.
|
Extra contents to write to a user's [`bazelrc`][4] file.
|
||||||
|
|
||||||
|
You can use multiline YAML strings.
|
||||||
|
|
||||||
Default `""`.
|
Default `""`.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
#### Enable Bzlmod
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: p0deje/setup-bazel@0.6.0
|
||||||
|
with:
|
||||||
|
bazelrc: common --enable_bzlmod
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Add colors and timestamps
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: p0deje/setup-bazel@0.6.0
|
||||||
|
with:
|
||||||
|
bazelrc: |
|
||||||
|
build --color=yes
|
||||||
|
build --show_timestamps
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
### `disk-cache`
|
### `disk-cache`
|
||||||
|
|
||||||
Enable [`disk_cache`][2] and store it on GitHub based on contents of `BUILD` files.
|
Enable [`disk_cache`][2] and store it on GitHub based on contents of `BUILD` files.
|
||||||
|
|
@ -34,81 +91,95 @@ You can also pass a string to use as a cache key to separate caches from differe
|
||||||
|
|
||||||
Default `false`.
|
Default `false`.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
#### Share a single disk cache
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: p0deje/setup-bazel@0.6.0
|
||||||
|
with:
|
||||||
|
disk-cache: true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Separate disk caches between workflows
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: p0deje/setup-bazel@0.6.0
|
||||||
|
with:
|
||||||
|
disk-cache: ${{ github.workflow }}}
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
### `external-cache`
|
### `external-cache`
|
||||||
|
|
||||||
Cache `external/` repositories based on contents of a `WORKSPACE` file.
|
Cache `external/` repositories based on contents of a `WORKSPACE` file.
|
||||||
Only repositories exceeding 10MB are being cached.
|
Only repositories exceeding 10MB are being cached.
|
||||||
|
Each repository is stored in a separate cache.
|
||||||
|
|
||||||
You can also pass a YAML object where key is the name of the external repository
|
You can also pass a `manifest` object where key is the name of the external repository
|
||||||
and value is the list of files which contents are used to calculate cache key.
|
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`.
|
Default `false`.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
#### Enable external repositories caches
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: p0deje/setup-bazel@0.6.0
|
||||||
|
with:
|
||||||
|
external-cache: true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Cache NPM repositories based on `package-lock.json` contents
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: p0deje/setup-bazel@0.6.0
|
||||||
|
with:
|
||||||
|
external-cache: |
|
||||||
|
manifest:
|
||||||
|
npm: package-lock.json
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Do not cache Ruby on Windows
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: p0deje/setup-bazel@0.6.0
|
||||||
|
with:
|
||||||
|
external-cache: |
|
||||||
|
manifest:
|
||||||
|
ruby: ${{ runner.os == 'Windows' && 'false' || 'true' }}
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
### `google-credentials`
|
||||||
|
|
||||||
|
Google Cloud account key to use for [remote caching authentication][9].
|
||||||
|
|
||||||
|
Default `""`.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
#### Authenticate via key
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: p0deje/setup-bazel@0.6.0
|
||||||
|
with:
|
||||||
|
google-credentials: ${{ secrets.GOOGLE_CLOUD_KEY }}
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
### `repository-cache`
|
### `repository-cache`
|
||||||
|
|
||||||
Enable [`repository_cache`][3] and store it on GitHub based on contents of a `WORKSPACE` file.
|
Enable [`repository_cache`][3] and store it on GitHub based on contents of a `WORKSPACE` file.
|
||||||
|
|
||||||
Default `false`.
|
Default `false`.
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
### Custom Bazelisk version
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: p0deje/setup-bazel@0.6.0
|
|
||||||
with:
|
|
||||||
bazelisk-version: 1.19.0
|
|
||||||
```
|
|
||||||
|
|
||||||
### Additional `.bazelrc` options
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: p0deje/setup-bazel@0.6.0
|
|
||||||
with:
|
|
||||||
bazelrc: |
|
|
||||||
common --color=yes
|
|
||||||
build --show_timestamps
|
|
||||||
```
|
|
||||||
|
|
||||||
### Full caching enabled
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: p0deje/setup-bazel@0.6.0
|
|
||||||
with:
|
|
||||||
bazelisk-cache: true
|
|
||||||
disk-cache: true
|
|
||||||
external-cache: true
|
|
||||||
repository-cache: true
|
|
||||||
```
|
|
||||||
|
|
||||||
### Separate disk cache between workflows
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: p0deje/setup-bazel@0.6.0
|
|
||||||
with:
|
|
||||||
disk-cache: ${{ github.workflow }}}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Cache external repository based on different files
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: p0deje/setup-bazel@0.6.0
|
|
||||||
with:
|
|
||||||
external-cache: |
|
|
||||||
manifest:
|
|
||||||
npm: package-lock.json
|
|
||||||
```
|
|
||||||
|
|
||||||
### Disable individual external repositories conditionally
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: p0deje/setup-bazel@0.6.0
|
|
||||||
with:
|
|
||||||
external-cache: |
|
|
||||||
manifest:
|
|
||||||
ruby: ${{ matrix.os == 'windows' && 'false' || '.ruby-version' }}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Migrating from [`bazelbuild/setup-bazelisk`][6]
|
## Migrating from [`bazelbuild/setup-bazelisk`][6]
|
||||||
|
|
||||||
You can simply replace `bazelbuild/setup-bazelisk` action with `p0deje/setup-bazel`.
|
You can simply replace `bazelbuild/setup-bazelisk` action with `p0deje/setup-bazel`.
|
||||||
|
|
@ -124,3 +195,4 @@ However, if you used a `bazel-version` input before, you will need to remove it
|
||||||
[6]: https://github.com/bazelbuild/setup-bazelisk
|
[6]: https://github.com/bazelbuild/setup-bazelisk
|
||||||
[7]: https://github.com/bazelbuild/bazelisk/blob/master/README.md#how-does-bazelisk-know-which-bazel-version-to-run
|
[7]: https://github.com/bazelbuild/bazelisk/blob/master/README.md#how-does-bazelisk-know-which-bazel-version-to-run
|
||||||
[8]: https://github.com/actions/runner-images/pull/490
|
[8]: https://github.com/actions/runner-images/pull/490
|
||||||
|
[9]: https://bazel.build/reference/command-line-reference#flag--google_credentials
|
||||||
Loading…
Add table
Add a link
Reference in a new issue