Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

175 linhas
5.7 KiB

  1. name: UI
  2. on:
  3. pull_request:
  4. workflow_dispatch:
  5. push:
  6. branches: [ develop ]
  7. concurrency:
  8. group: ui-develop-${{ github.event.number }}
  9. cancel-in-progress: true
  10. jobs:
  11. test:
  12. runs-on: ubuntu-latest
  13. timeout-minutes: 60
  14. strategy:
  15. fail-fast: false
  16. matrix:
  17. containers: [1, 2]
  18. name: UI Tests (Cypress)
  19. services:
  20. mysql:
  21. image: mariadb:10.3
  22. env:
  23. MYSQL_ALLOW_EMPTY_PASSWORD: YES
  24. ports:
  25. - 3306:3306
  26. options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
  27. steps:
  28. - name: Clone
  29. uses: actions/checkout@v2
  30. - name: Setup Python
  31. uses: actions/setup-python@v2
  32. with:
  33. python-version: '3.9'
  34. - name: Check if build should be run
  35. id: check-build
  36. run: |
  37. python "${GITHUB_WORKSPACE}/.github/helper/roulette.py"
  38. env:
  39. TYPE: "ui"
  40. PR_NUMBER: ${{ github.event.number }}
  41. REPO_NAME: ${{ github.repository }}
  42. - uses: actions/setup-node@v2
  43. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  44. with:
  45. node-version: 14
  46. check-latest: true
  47. - name: Add to Hosts
  48. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  49. run: |
  50. echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
  51. echo "127.0.0.1 test_site_producer" | sudo tee -a /etc/hosts
  52. - name: Cache pip
  53. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  54. uses: actions/cache@v2
  55. with:
  56. path: ~/.cache/pip
  57. key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
  58. restore-keys: |
  59. ${{ runner.os }}-pip-
  60. ${{ runner.os }}-
  61. - name: Cache node modules
  62. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  63. uses: actions/cache@v2
  64. env:
  65. cache-name: cache-node-modules
  66. with:
  67. path: ~/.npm
  68. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
  69. restore-keys: |
  70. ${{ runner.os }}-build-${{ env.cache-name }}-
  71. ${{ runner.os }}-build-
  72. ${{ runner.os }}-
  73. - name: Get yarn cache directory path
  74. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  75. id: yarn-cache-dir-path
  76. run: echo "::set-output name=dir::$(yarn cache dir)"
  77. - uses: actions/cache@v2
  78. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  79. id: yarn-cache
  80. with:
  81. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  82. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  83. restore-keys: |
  84. ${{ runner.os }}-yarn-
  85. - name: Cache cypress binary
  86. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  87. uses: actions/cache@v2
  88. with:
  89. path: ~/.cache
  90. key: ${{ runner.os }}-cypress-
  91. restore-keys: |
  92. ${{ runner.os }}-cypress-
  93. ${{ runner.os }}-
  94. - name: Install Dependencies
  95. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  96. run: bash ${GITHUB_WORKSPACE}/.github/helper/install_dependencies.sh
  97. env:
  98. BEFORE: ${{ env.GITHUB_EVENT_PATH.before }}
  99. AFTER: ${{ env.GITHUB_EVENT_PATH.after }}
  100. TYPE: ui
  101. - name: Install
  102. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  103. run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
  104. env:
  105. DB: mariadb
  106. TYPE: ui
  107. - name: Instrument Source Code
  108. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  109. run: cd ~/frappe-bench/apps/frappe/ && npx nyc instrument -x 'frappe/public/dist/**' -x 'frappe/public/js/lib/**' -x '**/*.bundle.js' --compact=false --in-place frappe
  110. - name: Build
  111. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  112. run: cd ~/frappe-bench/ && bench build --apps frappe
  113. - name: Site Setup
  114. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  115. run: cd ~/frappe-bench/ && bench --site test_site execute frappe.utils.install.complete_setup_wizard
  116. - name: UI Tests
  117. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  118. run: cd ~/frappe-bench/ && bench --site test_site run-ui-tests frappe --with-coverage --headless --parallel --ci-build-id $GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT
  119. env:
  120. CYPRESS_RECORD_KEY: 4a48f41c-11b3-425b-aa88-c58048fa69eb
  121. - name: Stop server
  122. if: ${{ steps.check-build.outputs.build-server == 'strawberry' }}
  123. run: |
  124. ps -ef | grep "frappe serve" | awk '{print $2}' | xargs kill -s SIGINT 2> /dev/null || true
  125. sleep 5
  126. - name: Check If Coverage Report Exists
  127. id: check_coverage
  128. uses: andstor/file-existence-action@v1
  129. with:
  130. files: "/home/runner/frappe-bench/apps/frappe/.cypress-coverage/clover.xml"
  131. - name: Upload Coverage Data
  132. if: ${{ steps.check-build.outputs.build == 'strawberry' && steps.check_coverage.outputs.files_exists == 'true' }}
  133. uses: codecov/codecov-action@v2
  134. with:
  135. name: Cypress
  136. fail_ci_if_error: true
  137. directory: /home/runner/frappe-bench/apps/frappe/.cypress-coverage/
  138. verbose: true
  139. flags: ui-tests
  140. - name: Upload Server Coverage Data
  141. if: ${{ steps.check-build.outputs.build-server == 'strawberry' }}
  142. uses: codecov/codecov-action@v2
  143. with:
  144. name: MariaDB
  145. fail_ci_if_error: true
  146. files: /home/runner/frappe-bench/sites/coverage.xml
  147. verbose: true
  148. flags: server