From 063d2795d968a3feacc63098665e9787086c3675 Mon Sep 17 00:00:00 2001 From: ci-bot Date: Mon, 24 Nov 2025 10:03:33 +0000 Subject: [PATCH 1/4] Add .gitea/workflows/workflow.yml --- .gitea/workflows/workflow.yml | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .gitea/workflows/workflow.yml diff --git a/.gitea/workflows/workflow.yml b/.gitea/workflows/workflow.yml new file mode 100644 index 0000000..be6533d --- /dev/null +++ b/.gitea/workflows/workflow.yml @@ -0,0 +1,82 @@ +name: Android Test + +on: + pull_request: + branches: [ main ] + +jobs: + validate-and-test: + runs-on: android + steps: + - name: Check ANDROID_SERIAL is set + run: | + if [ -z "$ANDROID_SERIAL" ]; then + echo "❌ Ошибка: Переменная окружения ANDROID_SERIAL не установлена." + exit 1 + fi + echo "✅ Переменная ANDROID_SERIAL установлена: $ANDROID_SERIAL" + + - name: Check ADB device is connected + run: | + command -v adb >/dev/null 2>&1 || { echo "❌ Ошибка: adb не найден в PATH." >&2; exit 1; } + + connected_devices=$(adb devices | grep -c "$ANDROID_SERIAL.*device$") + + if [ "$connected_devices" -ne 1 ]; then + echo "❌ Ошибка: Устройство с серийным номером $ANDROID_SERIAL не подключено или не доступно." + echo "Доступные устройства:" + adb devices + exit 1 + fi + echo "✅ Устройство с серийным номером $ANDROID_SERIAL подключено и готово к использованию." + + - name: Checkout PR code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + + - name: Validate allowed changes + run: | + python3 /opt/scripts/validate-changes.py + env: + GITEA_REPOSITORY: ${{ gitea.repository }} + GITEA_BASE_REF: ${{ gitea.event.pull_request.base.ref }} + GITEA_HEAD_REF: ${{ gitea.event.pull_request.head.ref }} + + - name: Checkout tests + run: python3 /opt/scripts/copy-tests.py --repo-url "Olympic/NTO-2025-Android-TeamTask-tests" --branch "main" + + - name: Uninstall APK before tests (Gradle) + run: | + chmod +x ./gradlew + ./gradlew uninstallAll + + - name: Run tests + run: | + chmod +x ./gradlew + ./gradlew connectedDebugAndroidTest + + - name: Uninstall APK after tests (Gradle) + run: | + chmod +x ./gradlew + ./gradlew uninstallAll + if: always() + + - name: Upload test results + uses: christopherHX/gitea-upload-artifact@v4 + with: + name: test-results + path: app/build/outputs/androidTest-results/connected + if-no-files-found: ignore + retention-days: 30 + if: always() + + - name: Upload test reports + uses: christopherHX/gitea-upload-artifact@v4 + with: + name: test-reports + path: app/build/reports/androidTests/connected + if-no-files-found: ignore + retention-days: 30 + if: always() \ No newline at end of file From 307364b2bcc4713956b11f939cdda61b622f636c Mon Sep 17 00:00:00 2001 From: ci-bot Date: Mon, 24 Nov 2025 10:17:31 +0000 Subject: [PATCH 2/4] Add allowed_changes.yml --- allowed_changes.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 allowed_changes.yml diff --git a/allowed_changes.yml b/allowed_changes.yml new file mode 100644 index 0000000..183bb75 --- /dev/null +++ b/allowed_changes.yml @@ -0,0 +1,8 @@ +version: 1 +allowed_files: + - "app/src/main/java/ru/myitschool/work/*" + - "app/src/main/res/*" +forbidden_files: + - "app/src/main/java/ru/myitschool/work/App.kt" + - "app/src/main/java/ru/myitschool/work/core/Constants.kt" + - "app/src/main/java/ru/myitschool/work/core/TestIds.kt" \ No newline at end of file From 24aef2604a73c233b64675b539603aa2ddd12ab5 Mon Sep 17 00:00:00 2001 From: ci-bot Date: Mon, 24 Nov 2025 15:01:25 +0000 Subject: [PATCH 3/4] Update .gitea/workflows/workflow.yml --- .gitea/workflows/workflow.yml | 52 +++-------------------------------- 1 file changed, 4 insertions(+), 48 deletions(-) diff --git a/.gitea/workflows/workflow.yml b/.gitea/workflows/workflow.yml index be6533d..aefb752 100644 --- a/.gitea/workflows/workflow.yml +++ b/.gitea/workflows/workflow.yml @@ -6,30 +6,8 @@ on: jobs: validate-and-test: - runs-on: android + runs-on: generic steps: - - name: Check ANDROID_SERIAL is set - run: | - if [ -z "$ANDROID_SERIAL" ]; then - echo "❌ Ошибка: Переменная окружения ANDROID_SERIAL не установлена." - exit 1 - fi - echo "✅ Переменная ANDROID_SERIAL установлена: $ANDROID_SERIAL" - - - name: Check ADB device is connected - run: | - command -v adb >/dev/null 2>&1 || { echo "❌ Ошибка: adb не найден в PATH." >&2; exit 1; } - - connected_devices=$(adb devices | grep -c "$ANDROID_SERIAL.*device$") - - if [ "$connected_devices" -ne 1 ]; then - echo "❌ Ошибка: Устройство с серийным номером $ANDROID_SERIAL не подключено или не доступно." - echo "Доступные устройства:" - adb devices - exit 1 - fi - echo "✅ Устройство с серийным номером $ANDROID_SERIAL подключено и готово к использованию." - - name: Checkout PR code uses: actions/checkout@v4 with: @@ -45,38 +23,16 @@ jobs: GITEA_HEAD_REF: ${{ gitea.event.pull_request.head.ref }} - name: Checkout tests - run: python3 /opt/scripts/copy-tests.py --repo-url "Olympic/NTO-2025-Android-TeamTask-tests" --branch "main" - - - name: Uninstall APK before tests (Gradle) - run: | - chmod +x ./gradlew - ./gradlew uninstallAll + run: python3 /opt/scripts/copy-tests.py --repo-url "Olympic/NTO-2025-Android-TeamTask-tests" --branch "main" --task-type "spring" - name: Run tests - run: | - chmod +x ./gradlew - ./gradlew connectedDebugAndroidTest - - - name: Uninstall APK after tests (Gradle) - run: | - chmod +x ./gradlew - ./gradlew uninstallAll - if: always() + run: mvn test - name: Upload test results uses: christopherHX/gitea-upload-artifact@v4 with: name: test-results - path: app/build/outputs/androidTest-results/connected - if-no-files-found: ignore - retention-days: 30 - if: always() - - - name: Upload test reports - uses: christopherHX/gitea-upload-artifact@v4 - with: - name: test-reports - path: app/build/reports/androidTests/connected + path: target/surefire-reports if-no-files-found: ignore retention-days: 30 if: always() \ No newline at end of file From 945b9d347df8c8befc1046e13e1a9a2df80182b8 Mon Sep 17 00:00:00 2001 From: ci-bot Date: Mon, 24 Nov 2025 16:42:09 +0000 Subject: [PATCH 4/4] revert 24aef2604a73c233b64675b539603aa2ddd12ab5 revert Update .gitea/workflows/workflow.yml --- .gitea/workflows/workflow.yml | 52 ++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/workflow.yml b/.gitea/workflows/workflow.yml index aefb752..be6533d 100644 --- a/.gitea/workflows/workflow.yml +++ b/.gitea/workflows/workflow.yml @@ -6,8 +6,30 @@ on: jobs: validate-and-test: - runs-on: generic + runs-on: android steps: + - name: Check ANDROID_SERIAL is set + run: | + if [ -z "$ANDROID_SERIAL" ]; then + echo "❌ Ошибка: Переменная окружения ANDROID_SERIAL не установлена." + exit 1 + fi + echo "✅ Переменная ANDROID_SERIAL установлена: $ANDROID_SERIAL" + + - name: Check ADB device is connected + run: | + command -v adb >/dev/null 2>&1 || { echo "❌ Ошибка: adb не найден в PATH." >&2; exit 1; } + + connected_devices=$(adb devices | grep -c "$ANDROID_SERIAL.*device$") + + if [ "$connected_devices" -ne 1 ]; then + echo "❌ Ошибка: Устройство с серийным номером $ANDROID_SERIAL не подключено или не доступно." + echo "Доступные устройства:" + adb devices + exit 1 + fi + echo "✅ Устройство с серийным номером $ANDROID_SERIAL подключено и готово к использованию." + - name: Checkout PR code uses: actions/checkout@v4 with: @@ -23,16 +45,38 @@ jobs: GITEA_HEAD_REF: ${{ gitea.event.pull_request.head.ref }} - name: Checkout tests - run: python3 /opt/scripts/copy-tests.py --repo-url "Olympic/NTO-2025-Android-TeamTask-tests" --branch "main" --task-type "spring" + run: python3 /opt/scripts/copy-tests.py --repo-url "Olympic/NTO-2025-Android-TeamTask-tests" --branch "main" + + - name: Uninstall APK before tests (Gradle) + run: | + chmod +x ./gradlew + ./gradlew uninstallAll - name: Run tests - run: mvn test + run: | + chmod +x ./gradlew + ./gradlew connectedDebugAndroidTest + + - name: Uninstall APK after tests (Gradle) + run: | + chmod +x ./gradlew + ./gradlew uninstallAll + if: always() - name: Upload test results uses: christopherHX/gitea-upload-artifact@v4 with: name: test-results - path: target/surefire-reports + path: app/build/outputs/androidTest-results/connected + if-no-files-found: ignore + retention-days: 30 + if: always() + + - name: Upload test reports + uses: christopherHX/gitea-upload-artifact@v4 + with: + name: test-reports + path: app/build/reports/androidTests/connected if-no-files-found: ignore retention-days: 30 if: always() \ No newline at end of file