mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-12 17:34:28 -05:00
106 lines
3.7 KiB
YAML
106 lines
3.7 KiB
YAML
name: Setup bazel
|
|
description: Setup Bazel for CI builds and tests
|
|
|
|
inputs:
|
|
useCache:
|
|
description: "Cache Bazel artifacts. Use 'true' to enable with rw, 'readonly' to download, 'log' to disable cache but upload logs, and 'false' to disable."
|
|
default: "false"
|
|
required: true
|
|
buildBuddyApiKey:
|
|
description: "BuildBuddy API key for caching Bazel artifacts"
|
|
required: false
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Check inputs
|
|
shell: bash
|
|
run: |
|
|
echo "::group::Check inputs"
|
|
if [[ "${{ inputs.useCache }}" != "true" && "${{ inputs.useCache }}" != "readonly" && "${{ inputs.useCache }}" != "logs" && "${{ inputs.useCache }}" != "false" ]]; then
|
|
echo "Invalid value for 'useCache' input: '${{ inputs.useCache }}'. Must be 'true', 'readonly', or 'false'."
|
|
exit 1
|
|
fi
|
|
if [[ "${{ inputs.useCache }}" == "true" || "${{ inputs.useCache }}" == "readonly" || "${{ inputs.useCache }}" == "logs" ]] && [[ -z "${{ inputs.buildBuddyApiKey }}" ]]; then
|
|
echo "BuildBuddy API key is required when cache is enabled."
|
|
exit 1
|
|
fi
|
|
echo "::endgroup::"
|
|
|
|
- name: Configure Bazel (general)
|
|
shell: bash
|
|
env:
|
|
WORKSPACE: ${{ github.workspace }}
|
|
run: |
|
|
echo "::group::Configure Bazel"
|
|
cat <<EOF >> "${WORKSPACE}/.bazeloverwriterc"
|
|
import %workspace%/bazel/bazelrc/ci.bazelrc
|
|
EOF
|
|
echo "::endgroup::"
|
|
|
|
- name: Configure Bazel (rw)
|
|
shell: bash
|
|
if: inputs.useCache == 'true' || inputs.useCache == 'readonly'
|
|
env:
|
|
BUILDBUDDY_ORG_API_KEY: ${{ inputs.buildBuddyApiKey }}
|
|
WORKSPACE: ${{ github.workspace }}
|
|
run: |
|
|
echo "::group::Configure Bazel"
|
|
cat <<EOF >> "${WORKSPACE}/.bazeloverwriterc"
|
|
common --bes_results_url=https://app.buildbuddy.io/invocation/
|
|
common --bes_backend=grpcs://remote.buildbuddy.io
|
|
common --remote_cache=grpcs://remote.buildbuddy.io
|
|
common --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_ORG_API_KEY}
|
|
cquery --bes_results_url=
|
|
cquery --bes_backend=
|
|
cquery --remote_cache=
|
|
query --bes_results_url=
|
|
query --bes_backend=
|
|
query --remote_cache=
|
|
EOF
|
|
echo "::endgroup::"
|
|
|
|
- name: Configure Bazel (readonly)
|
|
shell: bash
|
|
if: inputs.useCache == 'readonly'
|
|
env:
|
|
WORKSPACE: ${{ github.workspace }}
|
|
run: |
|
|
echo "::group::Configure Bazel (readonly)"
|
|
echo "common --remote_upload_local_results=false" >> "${WORKSPACE}/.bazeloverwriterc"
|
|
echo "::endgroup::"
|
|
|
|
- name: Configure Bazel (logs)
|
|
shell: bash
|
|
if: inputs.useCache == 'logs'
|
|
env:
|
|
BUILDBUDDY_ORG_API_KEY: ${{ inputs.buildBuddyApiKey }}
|
|
WORKSPACE: ${{ github.workspace }}
|
|
run: |
|
|
echo "::group::Configure Bazel"
|
|
cat <<EOF >> "${WORKSPACE}/.bazeloverwriterc"
|
|
common --bes_results_url=https://app.buildbuddy.io/invocation/
|
|
common --bes_backend=grpcs://remote.buildbuddy.io
|
|
common --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_ORG_API_KEY}
|
|
cquery --bes_results_url=
|
|
cquery --bes_backend=
|
|
query --bes_results_url=
|
|
query --bes_backend=
|
|
EOF
|
|
echo "::endgroup::"
|
|
|
|
- name: Disable disk cache on GitHub Actions runners
|
|
shell: bash
|
|
env:
|
|
WORKSPACE: ${{ github.workspace }}
|
|
if: startsWith(runner.name , 'GitHub Actions')
|
|
run: |
|
|
echo "::group::Configure Bazel (disk cache)"
|
|
echo "common --disk_cache=" >> "${WORKSPACE}/.bazeloverwriterc"
|
|
echo "common --repository_cache=" >> "${WORKSPACE}/.bazeloverwriterc"
|
|
echo "::endgroup::"
|
|
|
|
- name: Check bazel version
|
|
shell: bash
|
|
run: bazel version
|