name: 'Docker Bazel Run' description: 'Run a Bazel-based docker image for Protobuf CI testing' inputs: credentials: required: true description: The GCP credentials to use for reading the docker image type: string bazel-cache: required: true description: > A unique path for the Bazel cache. This will trigger the generation of a BAZEL_CACHE environment variable inside the container that provides the appropriate flags for any bazel command. type: string version: required: false description: A pinned Bazel version to use default: '5.1.1' type: string bazel: required: false description: The Bazel command to run type: string bash: required: false description: > A bash command to run. $BAZEL_FLAGS and $BAZEL_STARTUP_FLAGS will be available to use for bazel runs. type: string runs: using: 'composite' steps: - name: Authenticate id: auth uses: ./.github/actions/internal/gcloud-auth with: credentials: ${{ inputs.credentials }} - name: Setup Runner uses: ./.github/actions/internal/setup-runner - name: Setup Bazel id: bazel uses: ./.github/actions/internal/bazel-setup with: credentials-file: ${{ steps.auth.outputs.credentials-file }} bazel-cache: ${{ inputs.bazel-cache }} - name: Get Linux bazelisk path if: runner.os == 'Linux' shell: bash run: echo "BAZELISK_PATH=~/.cache/bazelisk" >> $GITHUB_ENV - name: Get MacOS bazelisk path if: runner.os == 'macOS' shell: bash run: echo "BAZELISK_PATH=~/Library/Caches/bazelisk" >> $GITHUB_ENV - name: Get Windows bazelisk path if: runner.os == 'Windows' shell: bash run: echo "BAZELISK_PATH=$LOCALAPPDATA\bazelisk" >> $GITHUB_ENV - name: Cache Bazelisk uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4 with: path: ${{ env.BAZELISK_PATH }} key: bazel-${{ runner.os }}-${{ inputs.version }} - name: Validate inputs if: ${{ (inputs.bash && inputs.bazel) || (!inputs.bash && !inputs.bazel) }} shell: bash run: echo "Invalid specification of both non-Bazel and Bazel command"; exit 1 - name: Pin Bazel version shell: bash run: echo "USE_BAZEL_VERSION=${{ inputs.version }}" >> $GITHUB_ENV - name: Output Bazel version shell: bash run: bazelisk version - name: Run Bash if: ${{ inputs.bash }} run: ${{ inputs.bash }} shell: bash - name: Run Bazel if: ${{ !inputs.bash }} run: >- bazelisk ${{ steps.bazel.outputs.bazel-startup-flags }} ${{ inputs.bazel }} ${{ steps.bazel.outputs.bazel-flags }} shell: bash