Skip to content

Commit

Permalink
Merge pull request #9 from betrybe/v2
Browse files Browse the repository at this point in the history
teste pra usar com ubuntu
  • Loading branch information
antoniosb committed Feb 19, 2024
2 parents 6edb6b7 + 79102cd commit 39b9cc5
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 49 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- name: Fetch Repository
uses: actions/checkout@v3
Expand All @@ -25,4 +25,4 @@ jobs:
run: npm run lint

- name: Run Test
run: npm test
run: npm test
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ 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 }}
```
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 }}
Expand Down
23 changes: 17 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
36 changes: 16 additions & 20 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9555,37 +9555,22 @@ function getTestFiles(pathList) {
return pathFiles
}


function convertTestCasesToJSON(testCases) {
const username = getGithubUsernameData()
const repository = getGithubRepositoryNameData()

return JSON.stringify({
github_username: username,
github_repository: repository,
evaluations: generateEvaluations(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
}
})
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
34 changes: 15 additions & 19 deletions src/controller/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,37 +64,22 @@ function getTestFiles(pathList) {
return pathFiles
}


function convertTestCasesToJSON(testCases) {
const username = getGithubUsernameData()
const repository = getGithubRepositoryNameData()

return JSON.stringify({
github_username: username,
github_repository: repository,
evaluations: generateEvaluations(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
}
})
}
Expand All @@ -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
}

0 comments on commit 39b9cc5

Please sign in to comment.