diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3aef7c3..691ed22 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 diff --git a/README.md b/README.md index c1f55ce..f74bf71 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 }} diff --git a/action.yml b/action.yml index 2edbf5c..d23dc8e 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 @@ -42,10 +42,11 @@ 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' }} + if: ${{ steps.avd-cache.outputs.cache-hit != 'true' && inputs.instrumented_test == 'true' }} uses: reactivecircus/android-emulator-runner@v2 with: api-level: 29 @@ -58,16 +59,26 @@ runs: if: ${{ inputs.unit_test == 'true' }} run: ./gradlew test shell: bash + 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 + 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 api-level: 29 - script: ./gradlew connectedCheck + # script: ./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 diff --git a/dist/index.js b/dist/index.js index 0f4181f..d4fcac5 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,26 +9566,11 @@ function convertTestCasesToJSON(testCases) { }) } -function getGrade(failures, requirementDescription) { - if (failures !== null && failures?.length > 0 ) { - return { grade: UNAPPROVED_GRADE, description: requirementDescription } - } - else 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) => { - 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 }}) + return { + description: testCase.name, + grade: testCase.failures.length > 0 ? UNAPPROVED_GRADE : APPROVED_GRADE } }) } @@ -9604,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 } @@ -9929,7 +9925,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 f229209..84ba64c 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 63f9bad..f9bf650 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,26 +75,11 @@ function convertTestCasesToJSON(testCases) { }) } -function getGrade(failures, requirementDescription) { - if (failures !== null && failures?.length > 0 ) { - return { grade: UNAPPROVED_GRADE, description: requirementDescription } - } - else 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) => { - 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 }}) + return { + description: testCase.name, + grade: testCase.failures.length > 0 ? UNAPPROVED_GRADE : APPROVED_GRADE } }) } @@ -113,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 }