Skip to content

Commit

Permalink
Adds Android GitHub actions test.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 594085590
  • Loading branch information
google-ima-devrel-bot authored and IMA Developer Relations committed Dec 27, 2023
1 parent 9a51868 commit 73e22eb
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build Status

# Step 1: Build on pull-requests or pushes to main
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
# Step 2: Build Android sample
build-java:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
regex:
- "android"
steps:
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17

- name: Clone Repo
uses: actions/checkout@v1

- name: Set commit range (push to the main branch, for example, merge)
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: echo "COMMIT_RANGE="${{ github.event.before }}.."" >> $GITHUB_ENV

- name: Set commit range (pull request)
if: github.event_name == 'pull_request'
run: echo "COMMIT_RANGE="HEAD~.."" >> $GITHUB_ENV

- name: Build
run: .github/workflows/build/build.sh
shell: bash
env:
COMMIT_RANGE: ${{ env.COMMIT_RANGE }}
REGEX: ${{ matrix.regex }}
16 changes: 16 additions & 0 deletions .github/workflows/build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -eo pipefail
projects=("${REGEX}")

for PROJ_DIR in "${projects[@]}"
do
CHANGES="$(git --no-pager diff --name-only "${COMMIT_RANGE}")";
echo "Commit range: ${COMMIT_RANGE}; Project dir: ${PROJ_DIR};\n Changes: ${CHANGES}";
if [[ -n "$(grep -E "(${PROJ_DIR}|\.github\/workflows)" <<< "${CHANGES}")" ]]; then
echo "Building for ${PROJ_DIR}";
pushd "$PROJ_DIR";
./gradlew build;
popd;
fi
done

0 comments on commit 73e22eb

Please sign in to comment.