Skip to content

Commit

Permalink
Add CI config and add bazel action.yml (#115)
Browse files Browse the repository at this point in the history
Fixes #115
  • Loading branch information
arunkumar9t2 committed Oct 19, 2023
1 parent fa25ce9 commit d5dd9cd
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 35 deletions.
5 changes: 4 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ build --experimental_android_databinding_v2
build --android_databinding_use_v3_4_args
build --android_databinding_use_androidx

# Flags to enable latest android providers in rules
build --experimental_google_legacy_api
query --experimental_google_legacy_api

Expand All @@ -17,4 +16,8 @@ test --build_tests_only

run --ui_event_filters=-info,-stdout --noshow_progress

# Ci Config
common:ci --noshow_progress
common:ci --color=no

try-import local.bazelrc
36 changes: 36 additions & 0 deletions .github/actions/bazel/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: 'Run Bazel Command'
description: 'Ensures bazelisk, mounts Bazel Cache from artifacts and runs Bazel command'
inputs:
bazel-config:
description: 'The bazel configuration to use.'
required: false
default: "--config=ci"
bazel-command:
description: 'The bazel command to run. Typically the arguments after bazelisk'
required: true
bazel-targets:
description: 'The bazel targets'
required: true
cache-key:
description: 'The cache key to uniquely identify this build'
required: true
runs:
using: "composite"
steps:
- name: Setup Bazelisk
uses: bazelbuild/setup-bazelisk@v2
- name: Install JDK 11
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "11"

- name: Mount bazel cache
uses: actions/cache@v3
with:
path: "bazel-cache"
key: ${{ inputs.cache-key }}

- name: Run bazel command
shell: bash
run: bazelisk ${{ inputs.bazel-command }} ${{ inputs.bazel-config }} ${{ inputs.bazel-targets }}
52 changes: 18 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,30 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: Install JDK 11
uses: actions/setup-java@v2
- uses: actions/checkout@v3
- name: Bazel build
uses: ./.github/actions/bazel
with:
distribution: "zulu"
java-version: "11"
- name: Lint
run: bazelisk run //:buildifier -- --mode=check -r $(pwd)
bazel-command: run
bazel-targets: //:buildifier -- --mode=check -r $(pwd)
cache-key: bazel-lint
build:
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: Install JDK 11
uses: actions/setup-java@v2
- uses: actions/checkout@v3
- name: Bazel build
uses: ./.github/actions/bazel
with:
distribution: "zulu"
java-version: "11"
- name: Mount bazel cache
uses: actions/cache@v3
with:
path: "bazel-cache"
key: bazel-common-build
- name: Build
run: bazelisk build //...
bazel-command: build
bazel-targets: //...
cache-key: bazel-build
test:
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: Install JDK 11
uses: actions/setup-java@v2
with:
distribution: "zulu"
java-version: "11"
- name: Mount bazel cache
uses: actions/cache@v3
- uses: actions/checkout@v3
- name: Bazel test
uses: ./.github/actions/bazel
with:
path: "bazel-cache"
key: bazel-common-test
- name: Test
run: bazelisk test //...
bazel-command: test
bazel-targets: //...
cache-key: bazel-test

0 comments on commit d5dd9cd

Please sign in to comment.