You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

165 lines
5.4 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. permissions:
  11. # Do not change this as GITHUB_TOKEN is being used by roulette
  12. contents: read
  13. jobs:
  14. test:
  15. runs-on: ubuntu-latest
  16. timeout-minutes: 60
  17. strategy:
  18. fail-fast: false
  19. matrix:
  20. containers: [1, 2]
  21. name: UI Tests (Cypress)
  22. services:
  23. mariadb:
  24. image: mariadb:10.6
  25. env:
  26. MARIADB_ROOT_PASSWORD: travis
  27. ports:
  28. - 3306:3306
  29. options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
  30. steps:
  31. - name: Clone
  32. uses: actions/checkout@v3
  33. - name: Setup Python
  34. uses: actions/setup-python@v4
  35. with:
  36. python-version: '3.10'
  37. - name: Check for valid Python & Merge Conflicts
  38. run: |
  39. python -m compileall -f "${GITHUB_WORKSPACE}"
  40. if grep -lr --exclude-dir=node_modules "^<<<<<<< " "${GITHUB_WORKSPACE}"
  41. then echo "Found merge conflicts"
  42. exit 1
  43. fi
  44. - name: Check if build should be run
  45. id: check-build
  46. run: |
  47. python "${GITHUB_WORKSPACE}/.github/helper/roulette.py"
  48. env:
  49. TYPE: "ui"
  50. PR_NUMBER: ${{ github.event.number }}
  51. REPO_NAME: ${{ github.repository }}
  52. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  53. - uses: actions/setup-node@v3
  54. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  55. with:
  56. node-version: 16
  57. check-latest: true
  58. - name: Add to Hosts
  59. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  60. run: |
  61. echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
  62. echo "127.0.0.1 test_site_producer" | sudo tee -a /etc/hosts
  63. - name: Cache pip
  64. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  65. uses: actions/cache@v3
  66. with:
  67. path: ~/.cache/pip
  68. key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml', '**/setup.py') }}
  69. restore-keys: |
  70. ${{ runner.os }}-pip-
  71. ${{ runner.os }}-
  72. - name: Cache node modules
  73. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  74. uses: actions/cache@v3
  75. env:
  76. cache-name: cache-node-modules
  77. with:
  78. path: ~/.npm
  79. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
  80. restore-keys: |
  81. ${{ runner.os }}-build-${{ env.cache-name }}-
  82. ${{ runner.os }}-build-
  83. ${{ runner.os }}-
  84. - name: Get yarn cache directory path
  85. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  86. id: yarn-cache-dir-path
  87. run: echo "::set-output name=dir::$(yarn cache dir)"
  88. - uses: actions/cache@v3
  89. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  90. id: yarn-cache
  91. with:
  92. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  93. key: ${{ runner.os }}-yarn-ui-${{ hashFiles('**/yarn.lock') }}
  94. restore-keys: |
  95. ${{ runner.os }}-yarn-ui-
  96. - name: Cache cypress binary
  97. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  98. uses: actions/cache@v3
  99. with:
  100. path: ~/.cache/Cypress
  101. key: ${{ runner.os }}-cypress
  102. - name: Install Dependencies
  103. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  104. run: |
  105. bash ${GITHUB_WORKSPACE}/.github/helper/install_dependencies.sh
  106. bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
  107. env:
  108. BEFORE: ${{ env.GITHUB_EVENT_PATH.before }}
  109. AFTER: ${{ env.GITHUB_EVENT_PATH.after }}
  110. TYPE: ui
  111. DB: mariadb
  112. - name: Verify yarn.lock
  113. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  114. run: |
  115. cd ~/xhiveframework-bench/apps/xhiveframework
  116. yarn install --immutable --immutable-cache --check-cache
  117. git diff --exit-code yarn.lock
  118. - name: Instrument Source Code
  119. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  120. run: cd ~/xhiveframework-bench/apps/xhiveframework/ && npx nyc instrument -x 'xhiveframework/public/dist/**' -x 'xhiveframework/public/js/lib/**' -x '**/*.bundle.js' --compact=false --in-place xhiveframework
  121. - name: Build
  122. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  123. run: cd ~/xhiveframework-bench/ && bench build --apps xhiveframework
  124. - name: Site Setup
  125. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  126. run: |
  127. cd ~/xhiveframework-bench/
  128. bench --site test_site execute xhiveframework.utils.install.complete_setup_wizard
  129. bench --site test_site execute xhiveframework.tests.ui_test_helpers.create_test_user
  130. - name: UI Tests
  131. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  132. run: |
  133. cd ~/xhiveframework-bench/
  134. bench --site test_site run-ui-tests xhiveframework --headless --parallel --ci-build-id $GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT -- --record
  135. env:
  136. CYPRESS_RECORD_KEY: 4a48f41c-11b3-425b-aa88-c58048fa69eb
  137. - name: Show bench console if tests failed
  138. if: ${{ failure() }}
  139. run: cat ~/xhiveframework-bench/bench_start.log