Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/android-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Android CI

on:
workflow_call:
inputs:
api-check:
description: 'Whether to run API checks'
required: false
type: boolean
default: true

secrets:
BUILD_CACHE_AWS_REGION:
required: false
BUILD_CACHE_AWS_BUCKET:
required: false
BUILD_CACHE_AWS_ACCESS_KEY_ID:
required: false
BUILD_CACHE_AWS_SECRET_KEY:
required: false
SONAR_TOKEN:
required: false

env:
BUILD_CACHE_AWS_REGION: ${{ secrets.BUILD_CACHE_AWS_REGION }}
BUILD_CACHE_AWS_BUCKET: ${{ secrets.BUILD_CACHE_AWS_BUCKET }}
BUILD_CACHE_AWS_ACCESS_KEY_ID: ${{ secrets.BUILD_CACHE_AWS_ACCESS_KEY_ID }}
BUILD_CACHE_AWS_SECRET_KEY: ${{ secrets.BUILD_CACHE_AWS_SECRET_KEY }}

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: GetStream/stream-build-conventions-android/.github/actions/setup-gradle@main
- name: Build
run: ./gradlew assembleDebug --scan

static-checks:
name: Run static checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: GetStream/stream-build-conventions-android/.github/actions/setup-gradle@main
- name: Spotless
run: ./gradlew spotlessCheck
- name: Lint
if: always()
run: ./gradlew lint
- name: API check
if: always() && inputs.api-check
run: ./gradlew apiCheck

unit-test:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # For Sonar analysis
- uses: GetStream/stream-build-conventions-android/.github/actions/setup-gradle@main
- name: Run unit tests
run: ./gradlew testCoverage --scan --stacktrace
- name: Upload tests results
uses: actions/upload-artifact@v4
if: failure()
with:
name: unit-tests-results
path: ./**/build/reports/tests/**
- name: Sonar
if: github.event.pull_request.head.repo.full_name == github.repository
run: ./gradlew sonar
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Sonar skipped if PR from fork
if: github.event.pull_request.head.repo.full_name != github.repository
run: echo "⚠️ Sonar skipped because the PR comes from a fork."

validate-workflows:
name: Run actionlint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: raven-actions/actionlint@v2.1.0
28 changes: 12 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ concurrency:
cancel-in-progress: true

jobs:
format:
name: Check formatting
static-checks:
name: Run static checks
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -22,22 +22,11 @@ jobs:
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }}

- name: Check formatting
- name: Spotless
run: ./gradlew spotlessCheck

lint:
name: Run detekt
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Gradle
uses: ./.github/actions/setup-gradle
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }}

- name: Run detekt
- name: Detekt
if: always()
run: ./gradlew detekt

build:
Expand All @@ -54,3 +43,10 @@ jobs:

- name: Build and validate
run: ./gradlew build :plugin:validatePlugins

validate-workflows:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the chance to add a validation step for actions and workflows.

name: Run actionlint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: raven-actions/actionlint@v2.1.0
4 changes: 2 additions & 2 deletions .github/workflows/pr-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
IFS=',' read -ra LBL <<< "${LABELS_CSV}"
for l in "${LBL[@]}"; do
l="$(echo "$l" | xargs)"
[[ $l == pr:* ]] && return 0
[[ "$l" == pr:* ]] && return 0
done
return 1
}
Expand All @@ -63,7 +63,7 @@ jobs:
section_nonempty () {
local hdr="$1"
local section
section="$(printf "%s" "$BODY" | awk -v h="^###[[:space:]]*$hdr[[:space:]]*$" '
section="$(printf "%s" "$BODY" | awk -v h="^###[[:space:]]*${hdr}[[:space:]]*$" '
BEGIN { insec=0 }
$0 ~ h { insec=1; next }
insec && $0 ~ /^##[[:space:]]/ { insec=0 }
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/sdk-size-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
uses: GetStream/stream-build-conventions-android/.github/actions/setup-gradle@main

- name: Assemble release for metrics
run: ./gradlew :metrics:$METRICS_PROJECT:assembleRelease
run: ./gradlew :metrics:"$METRICS_PROJECT":assembleRelease
env:
BUILD_CACHE_AWS_REGION: ${{ secrets.BUILD_CACHE_AWS_REGION }}
BUILD_CACHE_AWS_BUCKET: ${{ secrets.BUILD_CACHE_AWS_BUCKET }}
Expand All @@ -54,8 +54,8 @@ jobs:
# Reads current SDK sizes from the metrics file
# and define to a variable using a compact JSON format
# so it can be exported for the next job step
CURRENT_SDK_SIZES=$(jq -c .release $METRICS_FILE)
echo "CURRENT_SDK_SIZES=$CURRENT_SDK_SIZES" >> $GITHUB_ENV
CURRENT_SDK_SIZES=$(jq -c .release "$METRICS_FILE")
echo "CURRENT_SDK_SIZES=$CURRENT_SDK_SIZES" >> "$GITHUB_ENV"

- name: Calculate PR branch SDK sizes
run: |
Expand All @@ -74,7 +74,7 @@ jobs:
jq -c --arg sdk "$module" --arg size "$size" '. + {($sdk): ($size | tonumber)}' pr_sdk_sizes.json > temp.json && mv temp.json pr_sdk_sizes.json
done

echo "PR_SDK_SIZES=$(cat pr_sdk_sizes.json)" >> $GITHUB_ENV
echo "PR_SDK_SIZES=$(cat pr_sdk_sizes.json)" >> "$GITHUB_ENV"

- name: Post a comment or print size comparison
uses: actions/github-script@v7
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/sdk-size-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
uses: GetStream/stream-build-conventions-android/.github/actions/setup-gradle@main

- name: Assemble release and debug for metrics
run: ./gradlew :metrics:$METRICS_PROJECT:assemble
run: ./gradlew :metrics:"$METRICS_PROJECT":assemble
env:
BUILD_CACHE_AWS_REGION: ${{ secrets.BUILD_CACHE_AWS_REGION }}
BUILD_CACHE_AWS_BUCKET: ${{ secrets.BUILD_CACHE_AWS_BUCKET }}
Expand Down Expand Up @@ -82,12 +82,12 @@ jobs:
jq . metrics.json

# Move temporary JSON file to the final file
mv metrics.json $METRICS_FILE
mv metrics.json "$METRICS_FILE"

- name: Update size badges
run: |
for module in $MODULES; do
size=$(jq --arg module "$module" ".release.\"$module\"" $METRICS_FILE)
size=$(jq --arg module "$module" ".release.\"$module\"" "$METRICS_FILE")
sizeInMb=$(echo "scale=2; $size / 1024" | bc)
badgeUrl="https://img.shields.io/badge/${module//-/--}-$sizeInMb%20MB-lightgreen"
sed -i "s|!\[$module\](.*)|![$module](${badgeUrl})|" README.md
Expand All @@ -97,13 +97,13 @@ jobs:
run: |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_PAT }}@github.com/${{ github.repository }}.git

git fetch origin $BRANCH_NAME
git checkout $BRANCH_NAME
git fetch origin "$BRANCH_NAME"
git checkout "$BRANCH_NAME"

git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

git add $METRICS_FILE README.md
git add "$METRICS_FILE" README.md
git commit -m "[skip ci] Update SDK sizes" || echo "No changes to commit"

- name: Push changes
Expand Down
Loading