From cd328247a6be4945ebbe4a727475f1e50cb32d9c Mon Sep 17 00:00:00 2001 From: json Date: Wed, 6 Nov 2024 20:17:19 +0800 Subject: [PATCH] [22321] Added support for github action workflow file to run unit tests --- .github/workflows/android_ci.yml | 83 ++++++++++++++++++++++++++++++++ tripkit-android | 2 +- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/android_ci.yml diff --git a/.github/workflows/android_ci.yml b/.github/workflows/android_ci.yml new file mode 100644 index 000000000..eb112b3e5 --- /dev/null +++ b/.github/workflows/android_ci.yml @@ -0,0 +1,83 @@ +name: CI + +on: + pull_request: + branches: + - develop + - feature/** +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + submodules: true # This ensures submodules are also checked out + + - name: Update submodules + run: git submodule update --init --recursive + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: "temurin" + + - name: Cache Gradle packages + uses: actions/cache@v3 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Run unit tests + id: unit_tests + run: ./gradlew test -x tripkituisample:test + + - name: Archive test results + if: always() + uses: actions/upload-artifact@v3 + with: + name: test-results + path: ./*/build/test-results/**/test*UnitTest + + - name: Comment on Pull Request for Unit Test Failures + if: failure() && github.event_name == 'pull_request' && steps.unit_tests.outcome == 'failure' + uses: thollander/actions-comment-pull-request@v2.5.0 + with: + message: | + :x: Unit tests failed! + + @${{ github.event.pull_request.assignee.login || github.event.pull_request.user.login }}, please review and fix the issues in the unit tests. Let us know if you need any help. + - name: Comment on Pull Request for General Workflow Failures + if: failure() && github.event_name == 'pull_request' && steps.unit_tests.outcome != 'failure' + uses: thollander/actions-comment-pull-request@v2.5.0 + with: + message: | + :x: Workflow execution failed! + + @${{ github.event.pull_request.assignee.login || github.event.pull_request.user.login }}, there was an issue with the workflow execution. Please check the logs and resolve the issue. + - name: Comment on Pull Request (With Reviewers) + if: success() && github.event_name == 'pull_request' + uses: thollander/actions-comment-pull-request@v2.5.0 + with: + message: | + :white_check_mark: Unit tests passed successfully! + + Please ensure the code is reviewed before proceeding with the merge. +# - name: Comment on Pull Request +# run: | +# if [[ "${{ github.event.pull_request.requested_reviewers[2].login }}" != "" ]]; then +# REVIEWERS="@${{ github.event.pull_request.requested_reviewers[0].login }}, @${{ github.event.pull_request.requested_reviewers[1].login }}, @${{ github.event.pull_request.requested_reviewers[2].login }}" +# elif [[ "${{ github.event.pull_request.requested_reviewers[1].login }}" != "" ]]; then +# REVIEWERS="@${{ github.event.pull_request.requested_reviewers[0].login }}, @${{ github.event.pull_request.requested_reviewers[1].login }}" +# else +# REVIEWERS="@${{ github.event.pull_request.requested_reviewers[0].login || github.event.pull_request.user.login }}" +# fi +# +# echo "The code is ready for review." | gh pr comment ${{ github.event.pull_request.number }} --body "${REVIEWERS}, the tests have passed. The code is ready for review." \ No newline at end of file diff --git a/tripkit-android b/tripkit-android index 2cd6c5f60..316493b9f 160000 --- a/tripkit-android +++ b/tripkit-android @@ -1 +1 @@ -Subproject commit 2cd6c5f60db62ce6541d858115eb61c29bb83c36 +Subproject commit 316493b9fafced1d8b6087d454062d8f0736b44a