From ba60e31877501b3399aa1c2a8d7e5b8fbe632e83 Mon Sep 17 00:00:00 2001 From: Renan Date: Wed, 9 Aug 2023 14:05:31 -0300 Subject: [PATCH 01/15] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c1f55ce5..f74bf71a 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ jobs: path: .github/actions/junit-android-evaluator-action - name: Run JUnit Android Evaluator - id: android-evaluator + id: evaluator uses: ./.github/actions/junit-android-evaluator-action with: pr_author_username: ${{ github.event.pull_request.user.login }} @@ -45,6 +45,7 @@ jobs: Para habilitar ou desabilitar a execução de um tipo de teste, basta passar via parâmetro no passo da execução do avaliador. ```yml - name: Run JUnit Android Evaluator + id: evaluator uses: ./.github/actions/junit-android-evaluator-action with: pr_author_username: ${{ github.event.pull_request.user.login }} From 57ea53e4ac30c2a14f153f75584ad4fc79ac9637 Mon Sep 17 00:00:00 2001 From: Renan Carneiro Date: Wed, 9 Aug 2023 20:01:07 -0300 Subject: [PATCH 02/15] =?UTF-8?q?Continua=20a=20executar=20as=20actions=20?= =?UTF-8?q?caso=20aconte=C3=A7a=20algum=20erro=20na=20execu=C3=A7=C3=A3o?= =?UTF-8?q?=20dos=20testes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 2edbf5c7..227d419d 100644 --- a/action.yml +++ b/action.yml @@ -45,7 +45,7 @@ runs: key: avd-29 - name: create AVD and generate snapshot for caching - if: ${{ steps.avd-cache.outputs.cache-hit != 'true' }} + if: ${{ steps.avd-cache.outputs.cache-hit != 'true' && inputs.instrumented_test == 'true' }} uses: reactivecircus/android-emulator-runner@v2 with: api-level: 29 @@ -58,10 +58,12 @@ runs: if: ${{ inputs.unit_test == 'true' }} run: ./gradlew test shell: bash + continue-on-error: true - name: Run Instrumented tests uses: reactivecircus/android-emulator-runner@v2 if: ${{ inputs.instrumented_test == 'true' }} + continue-on-error: true with: force-avd-creation: false emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none From 561eb5f9b43da9707879337a88ad9f31cc6f3311 Mon Sep 17 00:00:00 2001 From: Renan Carneiro Date: Wed, 9 Aug 2023 20:02:14 -0300 Subject: [PATCH 03/15] Corrige bug ao definir um requisito como errado quando o teste falha * Quando um teste falha o requisito estava sendo considerado como aprovado --- dist/index.js | 13 +++++++++---- index.js | 2 +- src/controller/evaluator.js | 11 ++++++++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/dist/index.js b/dist/index.js index 0f4181ff..83aabed3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9567,10 +9567,11 @@ function convertTestCasesToJSON(testCases) { } function getGrade(failures, requirementDescription) { - if (failures !== null && failures?.length > 0 ) { + if (failures && failures.length > 0) { return { grade: UNAPPROVED_GRADE, description: requirementDescription } } - else return { grade: APPROVED_GRADE, description: requirementDescription } + + return { grade: APPROVED_GRADE, description: requirementDescription } } function generateEvaluations(testCases) { @@ -9581,11 +9582,15 @@ function generateEvaluations(testCases) { function mapTestCase(testCase) { return testCase.map((item) => { + const failures = item.failure || [] + return { name: item.$.name, classname: item.$.classname, time: item.$.time, - failures: item.failure === undefined || item.failure?.length > 0 ? null : item.failure.map((fail) => { return { message: fail.$.message, type: fail.$.type }}) + failures: failures.map((fail) => { + return { message: fail.$.message, type: fail.$.type } + }) } }) } @@ -9929,7 +9934,7 @@ var __webpack_exports__ = {}; (() => { const { runStepsEvaluator } = __nccwpck_require__(8309) const core = __nccwpck_require__(6442) -const unitPath = 'app/build/test-results/testReleaseUnitTest/' +const unitPath = 'app/build/test-results/testDebugUnitTest/' const instrumentedPath = 'app/build/outputs/androidTest-results/connected/' core.info('\u001b[38;5;6m[info] 🏃‍♂️ Rodando avaliador') diff --git a/index.js b/index.js index f229209b..84ba64c1 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ const { runStepsEvaluator } = require('./src/controller/evaluator') const core = require('@actions/core') -const unitPath = 'app/build/test-results/testReleaseUnitTest/' +const unitPath = 'app/build/test-results/testDebugUnitTest/' const instrumentedPath = 'app/build/outputs/androidTest-results/connected/' core.info('\u001b[38;5;6m[info] 🏃‍♂️ Rodando avaliador') diff --git a/src/controller/evaluator.js b/src/controller/evaluator.js index 63f9bad9..972481cc 100644 --- a/src/controller/evaluator.js +++ b/src/controller/evaluator.js @@ -76,10 +76,11 @@ function convertTestCasesToJSON(testCases) { } function getGrade(failures, requirementDescription) { - if (failures !== null && failures?.length > 0 ) { + if (failures && failures.length > 0) { return { grade: UNAPPROVED_GRADE, description: requirementDescription } } - else return { grade: APPROVED_GRADE, description: requirementDescription } + + return { grade: APPROVED_GRADE, description: requirementDescription } } function generateEvaluations(testCases) { @@ -90,11 +91,15 @@ function generateEvaluations(testCases) { function mapTestCase(testCase) { return testCase.map((item) => { + const failures = item.failure || [] + return { name: item.$.name, classname: item.$.classname, time: item.$.time, - failures: item.failure === undefined || item.failure?.length > 0 ? null : item.failure.map((fail) => { return { message: fail.$.message, type: fail.$.type }}) + failures: failures.map((fail) => { + return { message: fail.$.message, type: fail.$.type } + }) } }) } From 4cb8dcea3c71895a2033bab54c289a21f8cf40d6 Mon Sep 17 00:00:00 2001 From: Renan Carneiro Date: Thu, 10 Aug 2023 00:16:28 -0300 Subject: [PATCH 04/15] Ajuste o step para cachear o emulador --- action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 227d419d..1a4a3063 100644 --- a/action.yml +++ b/action.yml @@ -42,7 +42,8 @@ runs: path: | ~/.android/avd/* ~/.android/adb* - key: avd-29 + key: avd-29-${{ runner.os }} + restore-keys: avd-29- - name: create AVD and generate snapshot for caching if: ${{ steps.avd-cache.outputs.cache-hit != 'true' && inputs.instrumented_test == 'true' }} From b8c028c171e44dea0f1ea78728db26b715611aae Mon Sep 17 00:00:00 2001 From: Renan Carneiro Date: Thu, 24 Aug 2023 16:56:18 -0300 Subject: [PATCH 05/15] Corrige o mapeamento dos requisitos aprovados/reprovados --- dist/index.js | 39 ++++++++++++++----------------------- src/controller/evaluator.js | 39 ++++++++++++++----------------------- 2 files changed, 30 insertions(+), 48 deletions(-) diff --git a/dist/index.js b/dist/index.js index 83aabed3..d4fcac5f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9555,10 +9555,10 @@ function getTestFiles(pathList) { return pathFiles } - function convertTestCasesToJSON(testCases) { const username = getGithubUsernameData() const repository = getGithubRepositoryNameData() + return JSON.stringify({ github_username: username, github_repository: repository, @@ -9566,31 +9566,11 @@ function convertTestCasesToJSON(testCases) { }) } -function getGrade(failures, requirementDescription) { - if (failures && failures.length > 0) { - return { grade: UNAPPROVED_GRADE, description: requirementDescription } - } - - return { grade: APPROVED_GRADE, description: requirementDescription } -} - function generateEvaluations(testCases) { return testCases.map((testCase) => { - return getGrade(testCase.failures, testCase.name) - }) -} - -function mapTestCase(testCase) { - return testCase.map((item) => { - const failures = item.failure || [] - - return { - name: item.$.name, - classname: item.$.classname, - time: item.$.time, - failures: failures.map((fail) => { - return { message: fail.$.message, type: fail.$.type } - }) + return { + description: testCase.name, + grade: testCase.failures.length > 0 ? UNAPPROVED_GRADE : APPROVED_GRADE } }) } @@ -9609,6 +9589,17 @@ function mapValuesTestSuite(obj) { } } +function mapTestCase(testCase) { + return testCase.map((item) => { + return { + name: item.$.name, + classname: item.$.classname, + time: item.$.time, + failures: item.failure || [] + } + }) +} + module.exports = { runStepsEvaluator } diff --git a/src/controller/evaluator.js b/src/controller/evaluator.js index 972481cc..f9bf6502 100644 --- a/src/controller/evaluator.js +++ b/src/controller/evaluator.js @@ -64,10 +64,10 @@ function getTestFiles(pathList) { return pathFiles } - function convertTestCasesToJSON(testCases) { const username = getGithubUsernameData() const repository = getGithubRepositoryNameData() + return JSON.stringify({ github_username: username, github_repository: repository, @@ -75,31 +75,11 @@ function convertTestCasesToJSON(testCases) { }) } -function getGrade(failures, requirementDescription) { - if (failures && failures.length > 0) { - return { grade: UNAPPROVED_GRADE, description: requirementDescription } - } - - return { grade: APPROVED_GRADE, description: requirementDescription } -} - function generateEvaluations(testCases) { return testCases.map((testCase) => { - return getGrade(testCase.failures, testCase.name) - }) -} - -function mapTestCase(testCase) { - return testCase.map((item) => { - const failures = item.failure || [] - - return { - name: item.$.name, - classname: item.$.classname, - time: item.$.time, - failures: failures.map((fail) => { - return { message: fail.$.message, type: fail.$.type } - }) + return { + description: testCase.name, + grade: testCase.failures.length > 0 ? UNAPPROVED_GRADE : APPROVED_GRADE } }) } @@ -118,6 +98,17 @@ function mapValuesTestSuite(obj) { } } +function mapTestCase(testCase) { + return testCase.map((item) => { + return { + name: item.$.name, + classname: item.$.classname, + time: item.$.time, + failures: item.failure || [] + } + }) +} + module.exports = { runStepsEvaluator } From 812d89c851616912f11b5c38d28f14f699282958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rcio=20Vasconcelos?= <109628673+mfvjr@users.noreply.github.com> Date: Fri, 19 Jan 2024 13:28:40 -0300 Subject: [PATCH 06/15] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3aef7c3a..691ed22b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: self-hosted steps: - name: Fetch Repository uses: actions/checkout@v3 @@ -25,4 +25,4 @@ jobs: run: npm run lint - name: Run Test - run: npm test \ No newline at end of file + run: npm test From 970c55d92c5d8b9c262c458faf4b1ec34405ed1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20Augusto?= Date: Tue, 23 Jan 2024 17:13:26 -0300 Subject: [PATCH 07/15] Update action.yml --- action.yml | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/action.yml b/action.yml index 1a4a3063..0ab94756 100644 --- a/action.yml +++ b/action.yml @@ -21,10 +21,10 @@ outputs: runs: using: "composite" steps: - - name: Set up Nodejs 16 - uses: actions/setup-node@v3 + - name: Set up Nodejs 18 + uses: actions/setup-node@v4 with: - node-version: "16" + node-version: "18" - name: Set up JDK 17 uses: actions/setup-java@v3 @@ -35,40 +35,24 @@ runs: - name: Gradle cache uses: gradle/gradle-build-action@v2 - - name: AVD cache - uses: actions/cache@v3 - id: avd-cache - with: - path: | - ~/.android/avd/* - ~/.android/adb* - key: avd-29-${{ runner.os }} - restore-keys: avd-29- - - - name: create AVD and generate snapshot for caching - if: ${{ steps.avd-cache.outputs.cache-hit != 'true' && inputs.instrumented_test == 'true' }} - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 29 - force-avd-creation: false - emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - disable-animations: false - script: echo "Generated AVD snapshot for caching." - - name: Run Unit tests if: ${{ inputs.unit_test == 'true' }} run: ./gradlew test shell: bash continue-on-error: true + - name: Enable KVM group perms + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + - name: Run Instrumented tests uses: reactivecircus/android-emulator-runner@v2 if: ${{ inputs.instrumented_test == 'true' }} continue-on-error: true with: - force-avd-creation: false - emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - disable-animations: true + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none api-level: 29 script: ./gradlew connectedCheck From 202f2e1fa71a5ae397e74a4dc84aceffb55676f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20Augusto?= Date: Tue, 23 Jan 2024 18:14:41 -0300 Subject: [PATCH 08/15] Update action.yml --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index 0ab94756..be4758af 100644 --- a/action.yml +++ b/action.yml @@ -42,6 +42,7 @@ runs: continue-on-error: true - name: Enable KVM group perms + shell: bash run: | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules sudo udevadm control --reload-rules From 8234f3a3242130c82cc86892b2ed15d2149e3c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20Augusto?= Date: Tue, 23 Jan 2024 18:27:48 -0300 Subject: [PATCH 09/15] Update action.yml --- action.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/action.yml b/action.yml index be4758af..c42b1f06 100644 --- a/action.yml +++ b/action.yml @@ -32,9 +32,6 @@ runs: distribution: "zulu" java-version: "17" - - name: Gradle cache - uses: gradle/gradle-build-action@v2 - - name: Run Unit tests if: ${{ inputs.unit_test == 'true' }} run: ./gradlew test @@ -51,9 +48,7 @@ runs: - name: Run Instrumented tests uses: reactivecircus/android-emulator-runner@v2 if: ${{ inputs.instrumented_test == 'true' }} - continue-on-error: true with: - emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none api-level: 29 script: ./gradlew connectedCheck From 4db3e7bfe6fc7d6463ff3d499c841517367c6cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20Augusto?= Date: Wed, 24 Jan 2024 08:55:34 -0300 Subject: [PATCH 10/15] Update action.yml --- action.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/action.yml b/action.yml index c42b1f06..49dc8cc9 100644 --- a/action.yml +++ b/action.yml @@ -31,6 +31,28 @@ runs: with: distribution: "zulu" java-version: "17" + - name: Gradle cache + uses: gradle/gradle-build-action@v2 + + - name: AVD cache + uses: actions/cache@v3 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-29-${{ runner.os }} + restore-keys: avd-29- + + - name: create AVD and generate snapshot for caching + if: ${{ steps.avd-cache.outputs.cache-hit != 'true' && inputs.instrumented_test == 'true' }} + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + force-avd-creation: false + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: false + script: echo "Generated AVD snapshot for caching." - name: Run Unit tests if: ${{ inputs.unit_test == 'true' }} From 917d41a771a3bce4f5acde3fcceccf7be5d0643f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20Augusto?= Date: Wed, 24 Jan 2024 08:55:56 -0300 Subject: [PATCH 11/15] Update action.yml --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index 49dc8cc9..3b584745 100644 --- a/action.yml +++ b/action.yml @@ -31,6 +31,7 @@ runs: with: distribution: "zulu" java-version: "17" + - name: Gradle cache uses: gradle/gradle-build-action@v2 From 3cf964bf31cd4de6eb83b8461bb2ba77dc4ce362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20Augusto?= Date: Wed, 24 Jan 2024 08:56:42 -0300 Subject: [PATCH 12/15] Update action.yml --- action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/action.yml b/action.yml index 3b584745..a37a7bf3 100644 --- a/action.yml +++ b/action.yml @@ -71,7 +71,11 @@ runs: - name: Run Instrumented tests uses: reactivecircus/android-emulator-runner@v2 if: ${{ inputs.instrumented_test == 'true' }} + continue-on-error: true with: + force-avd-creation: false + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: true api-level: 29 script: ./gradlew connectedCheck From f8bb76fd9331b4e41c9d37c862bb23db913b03ce Mon Sep 17 00:00:00 2001 From: Antonio Britto Date: Wed, 24 Jan 2024 11:32:55 -0300 Subject: [PATCH 13/15] try uninstall the apk before running tests again --- action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index a37a7bf3..1d1d9822 100644 --- a/action.yml +++ b/action.yml @@ -77,7 +77,8 @@ runs: emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true api-level: 29 - script: ./gradlew connectedCheck + # script: ./gradlew connectedCheck + script: adb uninstall com.betrybe.sociallogin.test && ./gradlew connectedCheck - name: Get JUnit results id: get_junit_results From 0b195460112a329d2d467fc90f70fd773fd841e9 Mon Sep 17 00:00:00 2001 From: Antonio Britto Date: Wed, 24 Jan 2024 11:50:05 -0300 Subject: [PATCH 14/15] try uninstall com.betrybe apks before running tests again --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 1d1d9822..98094c2d 100644 --- a/action.yml +++ b/action.yml @@ -78,7 +78,7 @@ runs: disable-animations: true api-level: 29 # script: ./gradlew connectedCheck - script: adb uninstall com.betrybe.sociallogin.test && ./gradlew connectedCheck + script: adb shell pm list packages com.betrybe | cut -d ':' -f 2 | tr -d '\r' | xargs -L1 -t adb uninstall && ./gradlew connectedCheck - name: Get JUnit results id: get_junit_results From 79102cd450e42aa71ec80981830a0d150c89ad3e Mon Sep 17 00:00:00 2001 From: Antonio Britto Date: Wed, 24 Jan 2024 12:41:47 -0300 Subject: [PATCH 15/15] ignore uninstall if empty --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 98094c2d..d23dc8ed 100644 --- a/action.yml +++ b/action.yml @@ -78,7 +78,7 @@ runs: disable-animations: true api-level: 29 # script: ./gradlew connectedCheck - script: adb shell pm list packages com.betrybe | cut -d ':' -f 2 | tr -d '\r' | xargs -L1 -t adb uninstall && ./gradlew connectedCheck + script: adb shell pm list packages com.betrybe | cut -d ':' -f 2 | tr -d '\r' | xargs -L1 -t -r adb uninstall && ./gradlew connectedCheck - name: Get JUnit results id: get_junit_results