Skip to content

Conversation

grablack
Copy link
Contributor

@grablack grablack commented Aug 9, 2024

Description

Check messages for inline XML, programmatic XML, and Jetpack against testing plan.

Screenshots

Testing instructions

Copy link
Contributor

github-actions bot commented Aug 9, 2024

Code Coverage

Total Project Coverage 100.00%

@grablack grablack changed the title fea: testing tool feat: testing tool Aug 12, 2024
@grablack grablack marked this pull request as ready for review August 28, 2024 17:36
Comment on lines 13 to 92
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'

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

- name: Add Client ID
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
run: ./gradlew updateLocalsXmlFile

- name: Build APKs
run: |
./gradlew :demo:assembleDebug :demo:assembleAndroidTest

- name: Upload App to BrowserStack
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
run: |
APP_APK_PATH=./demo/build/outputs/apk/debug/demo-debug.apk
TEST_APK_PATH=./demo/build/outputs/apk/androidTest/debug/demo-debug-androidTest.apk

echo "App APK path: $APP_APK_PATH"
echo "Test APK path: $TEST_APK_PATH"

if [[ -z "$APP_APK_PATH" || -z "$TEST_APK_PATH" ]]; then
echo "Error: APK file not found."
exit 1
fi

# Upload app APK and capture response
APP_UPLOAD_RESPONSE=$(curl -s -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/app" \
-F "file=@$APP_APK_PATH")

echo "App upload response: $APP_UPLOAD_RESPONSE"

APP_URL=$(echo $APP_UPLOAD_RESPONSE | jq -r '.app_url')

if [[ -z "$APP_URL" ]]; then
echo "Error: App URL not found in response."
exit 1
fi

# Upload test suite APK and capture response
TEST_SUITE_UPLOAD_RESPONSE=$(curl -s -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/test-suite" \
-F "file=@$TEST_APK_PATH")

echo "Test suite upload response: $TEST_SUITE_UPLOAD_RESPONSE"

TEST_SUITE_URL=$(echo $TEST_SUITE_UPLOAD_RESPONSE | jq -r '.test_suite_url')

if [[ -z "$TEST_SUITE_URL" ]]; then
echo "Error: Test suite URL not found in response."
exit 1
fi

# Use the app_url and test_suite_url in another cURL request
FINAL_RESPONSE=$(curl -s -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/build" \
-d "{\"app\": \"$APP_URL\", \"testSuite\": \"$TEST_SUITE_URL\", \"devices\": [\"Samsung Galaxy S23-13.0\"], \"project\": \"Paypal_Messages_Android\"}" \
-H "Content-Type: application/json")

echo "Final response: $FINAL_RESPONSE"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 3 months ago

To fix the issue, we will add a permissions block at the root level of the workflow. This block will specify the least privileges required for the workflow to function. Since the workflow does not interact with the repository (e.g., no code pushes or pull request updates), we will set contents: read to limit the GITHUB_TOKEN to read-only access. This ensures the workflow adheres to the principle of least privilege.


Suggested changeset 1
.github/workflows/espresso-test.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/espresso-test.yml b/.github/workflows/espresso-test.yml
--- a/.github/workflows/espresso-test.yml
+++ b/.github/workflows/espresso-test.yml
@@ -10,2 +10,5 @@
 
+permissions:
+  contents: read
+
 jobs:
EOF
@@ -10,2 +10,5 @@

permissions:
contents: read

jobs:
Copilot is powered by AI and may make mistakes. Always verify output.
package com.paypal.messagesdemo

// @RunWith(AndroidJUnit4ClassRunner::class)
// public class JetPackTest {

Choose a reason for hiding this comment

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

Hi @grablack, I noticed that all of the code in JetPackTest.kt is currently commented out.

Is this intentional? If it's meant for future work, it might be cleaner to:

  • Push an empty test class with a @Test method marked @Ignore and a TODO note explaining what will be added in the next PR, or
  • Remove this file for now and add it back once it's ready.

This keeps the repo clean and avoids confusion for others pulling the branch 🙂

Let me know if I can help clarify!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants