Skip to content
Closed
Show file tree
Hide file tree
Changes from 13 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
9 changes: 8 additions & 1 deletion .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ name: Build Android Registration-Client

on:
workflow_dispatch:
inputs:
defaultServerBaseURL:
description: 'Server Base URL'
required: true
default: 'api-internal.sandbox.xyz.net'
type: string
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- release*
- develop

jobs:
build:
runs-on: ubuntu-latest
Expand Down
89 changes: 74 additions & 15 deletions .github/workflows/push_trigger.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
name: Android Registration-Client Build


on:
workflow_dispatch:
inputs:
serverBaseURL:
description: "Enter the Server Base URL (e.g. api-internal.qacore.mosip.net)"
required: true
default: "api-internal.qacore.mosip.net"
Comment on lines +4 to +9

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

⚠️ Unresolved: serverBaseURL default still mismatches build configuration.

The workflow_dispatch input defaults to "api-internal.qacore.mosip.net" (line 9), but previous reviews flagged that android/build.gradle uses "https://api-internal.sandbox.xyz.net". This inconsistency remains unaddressed. Please either:

  • Align the default to match build.gradle: "https://api-internal.sandbox.xyz.net", or
  • Document which environment (QA vs sandbox) should be used and clarify in code comments.

🏁 Script executed:

#!/bin/bash
# Find build.gradle files in the repository
fd -t f 'build\.gradle' | head -20

Length of output: 221


🏁 Script executed:

#!/bin/bash
# Search for serverBaseURL references in the codebase
rg -n 'serverBaseURL' --type gradle --type yaml

Length of output: 308


🏁 Script executed:

#!/bin/bash
# Examine the full push_trigger.yml workflow file to understand context
cat .github/workflows/push_trigger.yml | head -150

Length of output: 3369


🔴 Critical: sed command breaks on push events; inputs unavailable outside workflow_dispatch.

The sed command at line 79 uses ${{ github.event.inputs.serverBaseURL }}, which is only populated by workflow_dispatch. However, the workflow also triggers on push (line 10) and pull_request (line 21), where inputs are empty. This causes sed to replace api-internal.sandbox.xyz.net with an empty string, corrupting the build.gradle file.

Fix: Either conditionally run the sed step only on workflow_dispatch, or restructure the workflow to avoid using inputs on push/pull_request triggers:

- name: Update serverBaseURL
  if: github.event_name == 'workflow_dispatch'
  run: find . -type f -name "*build.gradle" -print0 | xargs -0 sed -i "s/api-internal.sandbox.xyz.net/${{ github.event.inputs.serverBaseURL }}/g"

Alternatively, provide a fallback value for push events or remove the push trigger if only manual workflow_dispatch is intended.

🤖 Prompt for AI Agents
In .github/workflows/push_trigger.yml around lines 4-9 (and the sed step at
~line 79), the sed command uses ${{ github.event.inputs.serverBaseURL }} which
is only populated for workflow_dispatch and will be empty on push/pull_request,
causing an accidental replacement; fix by restricting the sed step to run only
for workflow_dispatch events (add an if: github.event_name ==
'workflow_dispatch' to that step) or alternatively provide a safe
fallback/default value or environment variable for serverBaseURL when the event
is not workflow_dispatch so the sed replacement never substitutes an empty
string.


push:
branches:
- '!release-branch'
Expand All @@ -12,60 +18,113 @@ on:
- sprint-*
- main

pull_request:
branches:
- '!release-branch'
- release-*
- master
- develop
- sprint-*
- main

jobs:

dco:
name: DCO Check
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: DCO Check
uses: DCOapp/action@v1.3.5

codeql:
name: CodeQL Analysis
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'java', 'javascript' ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

build-android:
name: Android Registration-Client Build
needs: [dco, codeql]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v3
- name: Install npm dependencies
run: |
npm install
- name: Updating serverBaseURL.
- name: Update serverBaseURL
run: |
find . -type f -name "*build.gradle" -print0 | xargs -0 sed -i "s/api-internal.sandbox.xyz.net/${{ github.event.inputs.defaultServerBaseURL }}/g"
find . -type f -name "*build.gradle" -print0 | xargs -0 sed -i "s/api-internal.sandbox.xyz.net/${{ github.event.inputs.serverBaseURL }}/g"
- name: Build Android Registration-Client
run: |
cd client
chmod +x gradlew
./gradlew assembleDebug
ls app/build/outputs/apk/debug
Comment on lines +77 to 85

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: serverBaseURL input is unavailable during push events.

Line 70's sed replacement uses ${{ github.event.inputs.serverBaseURL }}, but github.event.inputs is only populated for workflow_dispatch events. During push events, this variable is empty, causing the sed command to replace api-internal.sandbox.xyz.net with an empty string, which will break the build.

To fix this, either:

  1. Provide a default value in the sed command using bash parameter expansion: ${{ github.event.inputs.serverBaseURL || 'api-internal.sandbox.xyz.net' }}
  2. Or conditionally run this step only on workflow_dispatch events using if: github.event_name == 'workflow_dispatch'

Apply this diff to safely handle missing input:

      - name: Update serverBaseURL
         run: |
-          find . -type f -name "*build.gradle" -print0 | xargs -0 sed -i "s/api-internal.sandbox.xyz.net/${{ github.event.inputs.serverBaseURL }}/g"
+          find . -type f -name "*build.gradle" -print0 | xargs -0 sed -i "s/api-internal.sandbox.xyz.net/${{ github.event.inputs.serverBaseURL || 'api-internal.sandbox.xyz.net' }}/g"

Alternatively, make this step conditional:

+     - name: Update serverBaseURL
+       if: github.event_name == 'workflow_dispatch'
         run: |
           find . -type f -name "*build.gradle" -print0 | xargs -0 sed -i "s/api-internal.sandbox.xyz.net/${{ github.event.inputs.serverBaseURL }}/g"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Update serverBaseURL
run: |
find . -type f -name "*build.gradle" -print0 | xargs -0 sed -i "s/api-internal.sandbox.xyz.net/${{ github.event.inputs.defaultServerBaseURL }}/g"
find . -type f -name "*build.gradle" -print0 | xargs -0 sed -i "s/api-internal.sandbox.xyz.net/${{ github.event.inputs.serverBaseURL }}/g"
- name: Build Android Registration-Client
run: |
cd client
chmod +x gradlew
./gradlew assembleDebug
ls app/build/outputs/apk/debug
- name: Update serverBaseURL
run: |
find . -type f -name "*build.gradle" -print0 | xargs -0 sed -i "s/api-internal.sandbox.xyz.net/${{ github.event.inputs.serverBaseURL || 'api-internal.sandbox.xyz.net' }}/g"
- name: Build Android Registration-Client
run: |
cd client
chmod +x gradlew
./gradlew assembleDebug
ls app/build/outputs/apk/debug
🤖 Prompt for AI Agents
In .github/workflows/push_trigger.yml around lines 68-76 the sed replacement
uses `${{ github.event.inputs.serverBaseURL }}` which is empty on push events
and wipes out the host; change the step to either (A) keep it for all events but
use a safe default when the input is missing by using bash/GitHub expressions to
fall back to the original host (e.g. expand the variable with a default in the
sed command), or (B) restrict the step to only run on workflow_dispatch by
adding an if condition (`if: github.event_name == 'workflow_dispatch'`) so the
replacement never runs during push; implement one of these fixes and verify the
build step still finds a valid serverBaseURL.

find -name '*.apk'
- name: Upload Artifact
- name: Upload APK Artifact
uses: actions/upload-artifact@v4
with:
name: apk-output
path: ./client/app/build/outputs/apk/debug/app-debug.apk
retention-days: 5

build:
name: sonar-analysis
sonar-analysis:
name: SonarQube Analysis
needs: [build-android]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0

- name: Set up JDK 11
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 11
java-version: '11'

- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze

- name: Build and Sonar Analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
cd client
chmod +x gradlew
./gradlew build test testDebugUnitTestCoverage sonarqube --info --warning-mode all
./gradlew build sonarqube --info --warning-mode all
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ext {
clientmanagerLibVersionCode = 1
clientmanagerLibVersionName = "\"1.0.0\""

serverBaseURL = "\"https://api-internal.qa-base.mosip.net\""
serverBaseURL = "\"https://api-internal.sandbox.xyz.net\""
serverHealthCheckPath = "\"/v1/syncdata/actuator/health\""
serverActuatorInfoPath = "\"/v1/syncdata/actuator/info\""
debugPassword = "\"APTyKejHxACQyKBSRciR\""
Expand Down
Loading