Skip to content

Commit

Permalink
ci: install nix together with Bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
malt3 committed Oct 12, 2023
1 parent e74dbda commit e80e607
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/actions/e2e_attestationconfigapi/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ runs:
using: "composite"
steps:
- name: Setup bazel
uses: ./.github/actions/setup_bazel
uses: ./.github/actions/setup_bazel_nix
with:
useCache: "true"
buildBuddyApiKey: ${{ inputs.buildBuddyApiKey }}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/e2e_mini/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ runs:
terraform_wrapper: false

- name: Setup bazel
uses: ./.github/actions/setup_bazel
uses: ./.github/actions/setup_bazel_nix
with:
useCache: "true"
buildBuddyApiKey: ${{ inputs.buildBuddyApiKey }}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/e2e_test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ runs:
echo "hostArch=$(go env GOARCH)" | tee -a "$GITHUB_OUTPUT"
- name: Setup bazel
uses: ./.github/actions/setup_bazel
uses: ./.github/actions/setup_bazel_nix
with:
useCache: ${{ inputs.buildBuddyApiKey != '' }}
buildBuddyApiKey: ${{ inputs.buildBuddyApiKey }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Setup bazel
description: Setup Bazel for CI builds and tests
name: Setup bazel and Nix
description: Setup Bazel and Nix for CI builds and tests

inputs:
useCache:
Expand All @@ -14,6 +14,7 @@ runs:
using: "composite"
steps:
- name: Check inputs
id: check_inputs
shell: bash
run: |
echo "::group::Check inputs"
Expand All @@ -25,6 +26,60 @@ runs:
echo "BuildBuddy API key is required when cache is enabled."
exit 1
fi
if command -v nix; then
echo "nixPreinstalled=true" | tee -a "$GITHUB_OUTPUT"
else
echo "nixPreinstalled=false" | tee -a "$GITHUB_OUTPUT"
fi
if command -v bazel; then
echo "bazelPreinstalled=true" | tee -a "$GITHUB_OUTPUT"
else
echo "bazelPreinstalled=false" | tee -a "$GITHUB_OUTPUT"
fi
if [[ -f /etc/NIXOS ]]; then
echo "nixOS=true" | tee -a "$GITHUB_OUTPUT"
else
echo "nixOS=false" | tee -a "$GITHUB_OUTPUT"
fi
if [[ "$RUNNER_OS" == "Linux" ]]; then
echo "os=linux" | tee -a "$GITHUB_OUTPUT"
elif [[ "$RUNNER_OS" == "Windows" ]]; then
echo "os=windows" | tee -a "$GITHUB_OUTPUT"
elif [[ "$RUNNER_OS" == "macOS" ]]; then
echo "os=darwin" | tee -a "$GITHUB_OUTPUT"
else
echo "$RUNNER_OS not supported"
exit 1
fi
if [[ "$RUNNER_ARCH" == "X64" ]]; then
echo "arch=amd64" | tee -a "$GITHUB_OUTPUT"
elif [[ "$RUNNER_ARCH" == "ARM64" ]]; then
echo "arch=arm64" | tee -a "$GITHUB_OUTPUT"
else
echo "$RUNNER_ARCH not supported"
exit 1
fi
echo "::endgroup::"
- name: Install nix
if: steps.check_inputs.outputs.nixPreinstalled == 'false'
uses: cachix/install-nix-action@6ed004b9ccb68dbc28e7c85bee15fa93dbd214ac # v22

# - uses: cachix/cachix-action@6a9a34cdd93d0ae4b4b59fd678660efb08109f2f # v12
# with:
# name: katexochen
# extraPullNames: nix-community

- name: Install Bazelisk
if: steps.check_inputs.outputs.bazelPreinstalled == 'false' && steps.check_inputs.outputs.nixOS == 'false'
shell: bash
env:
OS: ${{ steps.check_inputs.outputs.os }}
ARCH: ${{ steps.check_inputs.outputs.arch }}
run: |
echo "::group::Install Bazelisk"
curl -fsSLo /usr/local/bin/bazel "https://github.com/bazelbuild/bazelisk/releases/download/v1.18.0/bazelisk-${OS}-${ARCH}"
chmod +x /usr/local/bin/bazel
echo "::endgroup::"
- name: Free up space (Ubuntu)
Expand Down Expand Up @@ -65,8 +120,8 @@ runs:
echo "::endgroup::"
- name: Configure Bazel (rw)
shell: bash
if: inputs.useCache == 'true' || inputs.useCache == 'readonly'
shell: bash
env:
BUILDBUDDY_ORG_API_KEY: ${{ inputs.buildBuddyApiKey }}
WORKSPACE: ${{ github.workspace }}
Expand All @@ -87,8 +142,8 @@ runs:
echo "::endgroup::"
- name: Configure Bazel (readonly)
shell: bash
if: inputs.useCache == 'readonly'
shell: bash
env:
WORKSPACE: ${{ github.workspace }}
run: |
Expand All @@ -97,8 +152,8 @@ runs:
echo "::endgroup::"
- name: Configure Bazel (logs)
shell: bash
if: inputs.useCache == 'logs'
shell: bash
env:
BUILDBUDDY_ORG_API_KEY: ${{ inputs.buildBuddyApiKey }}
WORKSPACE: ${{ github.workspace }}
Expand All @@ -116,16 +171,12 @@ runs:
echo "::endgroup::"
- name: Disable disk cache on GitHub Actions runners
if: startsWith(runner.name , 'GitHub Actions')
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
2 changes: 1 addition & 1 deletion .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}

- name: Setup bazel
uses: ./.github/actions/setup_bazel
uses: ./.github/actions/setup_bazel_nix
with:
useCache: "true"
buildBuddyApiKey: ${{ secrets.BUILDBUDDY_ORG_API_KEY }}
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/build-os-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,9 @@ jobs:
with:
ref: ${{ inputs.ref || github.head_ref }}

- uses: cachix/install-nix-action@6ed004b9ccb68dbc28e7c85bee15fa93dbd214ac # v22

- uses: cachix/cachix-action@6a9a34cdd93d0ae4b4b59fd678660efb08109f2f # v12
- uses: ./.github/actions/setup_bazel_nix
with:
name: katexochen
extraPullNames: nix-community
useCache: "false"

- name: Build
id: build
Expand Down Expand Up @@ -231,6 +228,10 @@ jobs:
with:
ref: ${{ inputs.ref || github.head_ref }}

- uses: ./.github/actions/setup_bazel_nix
with:
useCache: "false"

- name: Download OS image artifact
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
Expand Down Expand Up @@ -385,6 +386,10 @@ jobs:
with:
name: image-${{ matrix.csp }}-${{ matrix.attestation_variant }}

- uses: ./.github/actions/setup_bazel_nix
with:
useCache: "false"

- name: Install dependencies
run: |
echo "::group::Install dependencies"
Expand Down Expand Up @@ -620,6 +625,10 @@ jobs:
with:
ref: ${{ inputs.ref || github.head_ref }}

- uses: ./.github/actions/setup_bazel_nix
with:
useCache: "false"

- name: Download image lookup table
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/e2e-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ jobs:
fetch-depth: 0
ref: ${{ inputs.gitRef }}

- uses: ./.github/actions/setup_bazel_nix
with:
useCache: "false"

- name: Login to AWS
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
ref: ${{ inputs.ref || github.head_ref }}

- name: Setup bazel
uses: ./.github/actions/setup_bazel
uses: ./.github/actions/setup_bazel_nix
with:
useCache: "false"

Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:
ref: ${{ inputs.ref || github.head_ref }}

- name: Setup bazel
uses: ./.github/actions/setup_bazel
uses: ./.github/actions/setup_bazel_nix
with:
useCache: "false"

Expand Down Expand Up @@ -209,7 +209,7 @@ jobs:
uses: ./.github/actions/install_syft_grype

- name: Setup bazel
uses: ./.github/actions/setup_bazel
uses: ./.github/actions/setup_bazel_nix
with:
useCache: "false"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reproducible-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}

- name: Setup bazel
uses: ./.github/actions/setup_bazel
uses: ./.github/actions/setup_bazel_nix
with:
useCache: "logs"
buildBuddyApiKey: ${{ secrets.BUILDBUDDY_ORG_API_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
echo "::endgroup::"
- name: Setup Bazel
uses: ./.github/actions/setup_bazel
uses: ./.github/actions/setup_bazel_nix
with:
useCache: "true"
buildBuddyApiKey: ${{ secrets.BUILDBUDDY_ORG_API_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
aws-region: eu-central-1

- name: Setup bazel
uses: ./.github/actions/setup_bazel
uses: ./.github/actions/setup_bazel_nix
with:
useCache: "true"
buildBuddyApiKey: ${{ secrets.BUILDBUDDY_ORG_API_KEY }}
Expand Down

0 comments on commit e80e607

Please sign in to comment.