Skip to content
Draft
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
74 changes: 72 additions & 2 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
description: "Update Android Repo - Opens a PR updating the SDK in bitwarden/android"
type: boolean
default: false
test-android-repo:
description: "Test Android Repo Apps - Runs the SDK Test workflow in bitwarden/android"
type: boolean
default: false

defaults:
run:
Expand Down Expand Up @@ -135,10 +139,10 @@ jobs:
update:
name: Trigger SDK update in Android repo
runs-on: ubuntu-24.04
if: (github.ref == 'refs/heads/main' && github.event_name == 'push') || inputs.update-android-repo
needs: combine
permissions:
id-token: write
pull-requests: write

steps:
- name: Log in to Azure
Expand Down Expand Up @@ -168,11 +172,77 @@ jobs:
repositories: android
permission-actions: write

- name: Call SDLC SDK Update workflow in Android repo
- name: Trigger SDK Update in Android repo
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || inputs.update-android-repo
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
_SDK_PACKAGE: ${{ needs.combine.outputs.sdk-package-id }}
_SDK_VERSION: ${{ needs.combine.outputs.sdk-version }}
run: |
echo "๐Ÿš€ Triggering sdlc-sdk-update.yml workflow in bitwarden/android repo..."
gh workflow run sdlc-sdk-update.yml --repo bitwarden/android --ref main -f run-mode=Update -f sdk-package=$_SDK_PACKAGE -f sdk-version=$_SDK_VERSION

- name: Trigger SDK Test in Android repo and wait for completion
id: test-android
if: github.event_name == 'pull_request' || inputs.test-android-repo
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
_SDK_PACKAGE: "com.bitwarden:sdk-android" #${{ needs.combine.outputs.sdk-package-id
_SDK_VERSION: "1.0.0-2493-bceb681a" #${{ needs.combine.outputs.sdk-version
_MAX_RUN_LIST_RETRIES: 5
run: |
echo "๐Ÿš€ Triggering sdlc-sdk-update.yml workflow in bitwarden/android repo..."
json_params='{"run-mode": "Test", "sdk-package": "'"$_SDK_PACKAGE"'", "sdk-version": "'"$_SDK_VERSION"'", "pr-id": "'"$_PR_NUMBER"'"}'
echo $json_params | gh workflow run sdlc-sdk-update.yml --repo bitwarden/android --json

echo "๐Ÿ” Looking for workflow run with displayTitle containing 'Test' and '$_SDK_VERSION'..."
JQ_FILTER='.[] | select(.status != "completed" and (.displayTitle | contains("Test")) and (.displayTitle | contains("'"$_SDK_VERSION"'"))) | .databaseId'

RETRY_COUNT=0
WORKFLOW_RUN_ID=""
while
sleep 5
RETRY_COUNT=$((RETRY_COUNT + 1))
echo "๐Ÿ”„ Attempt $RETRY_COUNT of $_MAX_RUN_LIST_RETRIES to find workflow run..."
WORKFLOW_RUN_ID=$(gh run list --repo bitwarden/android --workflow=sdlc-sdk-update.yml --limit=10 --json databaseId,status,displayTitle --jq "$JQ_FILTER" | head -1)
[ -z "$WORKFLOW_RUN_ID" ] && [ $RETRY_COUNT -lt $_MAX_RUN_LIST_RETRIES ]
do true; done

if [ -z "$WORKFLOW_RUN_ID" ]; then
echo "::error::No workflow found after $_MAX_RUN_LIST_RETRIES attempts."
exit 1
fi

echo "๐Ÿ” Workflow run ID: $WORKFLOW_RUN_ID"

WORKFLOW_URL="https://github.com/bitwarden/android/actions/runs/$WORKFLOW_RUN_ID"
echo "## ๐Ÿ”— Android SDK Test Run: [$WORKFLOW_RUN_ID]($WORKFLOW_URL)" >> $GITHUB_STEP_SUMMARY

ERROR_CODE=0
if ! gh run watch $WORKFLOW_RUN_ID --repo bitwarden/android --compact --exit-status --interval 30; then
echo "โŒ Android SDK Test failed."
echo "โŒ **Status:** Failed - [View Details]($WORKFLOW_URL)" >> $GITHUB_STEP_SUMMARY
LABEL_ACTION="--add-label"
ERROR_CODE=1
else
echo "โœ… Android SDK Test passed."
echo "โœ… **Status:** Passed - [View Details]($WORKFLOW_URL)" >> $GITHUB_STEP_SUMMARY
LABEL_ACTION="--remove-label"
fi

echo "label-action=$LABEL_ACTION" >> $GITHUB_OUTPUT
echo "error-code=$ERROR_CODE" >> $GITHUB_OUTPUT

- name: Label PR and exit
if: github.event_name == 'pull_request' || inputs.test-android-repo
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
_LABEL_ACTION: ${{ steps.test-android.outputs.label-action }}
_ERROR_CODE: ${{ steps.test-android.outputs.error-code }}
_PR_NUMBER: ${{ github.event.pull_request.number }}
_BREAKING_CHANGE_LABEL: "breaking-change-android"
run: |
if [ -n "$_PR_NUMBER" ]; then
gh pr edit --repo bitwarden/sdk-internal $_PR_NUMBER $_LABEL_ACTION $_BREAKING_CHANGE_LABEL
fi
exit $_ERROR_CODE
Loading