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.
 
 
 
 
 
 

129 lines
3.8 KiB

  1. name: Server (Postgres)
  2. on:
  3. pull_request:
  4. workflow_dispatch:
  5. push:
  6. branches: [ develop ]
  7. concurrency:
  8. group: server-postgres-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. name: Unit Tests
  16. runs-on: ubuntu-latest
  17. timeout-minutes: 60
  18. strategy:
  19. fail-fast: false
  20. services:
  21. postgres:
  22. image: postgres:12.4
  23. env:
  24. POSTGRES_PASSWORD: travis
  25. options: >-
  26. --health-cmd pg_isready
  27. --health-interval 10s
  28. --health-timeout 5s
  29. --health-retries 5
  30. ports:
  31. - 5432:5432
  32. steps:
  33. - name: Clone
  34. uses: actions/checkout@v3
  35. - name: Setup Python
  36. uses: actions/setup-python@v4
  37. with:
  38. python-version: '3.10'
  39. - name: Check for valid Python & Merge Conflicts
  40. run: |
  41. python -m compileall -f "${GITHUB_WORKSPACE}"
  42. if grep -lr --exclude-dir=node_modules "^<<<<<<< " "${GITHUB_WORKSPACE}"
  43. then echo "Found merge conflicts"
  44. exit 1
  45. fi
  46. - name: Check if build should be run
  47. id: check-build
  48. run: |
  49. python "${GITHUB_WORKSPACE}/.github/helper/roulette.py"
  50. env:
  51. TYPE: "server"
  52. PR_NUMBER: ${{ github.event.number }}
  53. REPO_NAME: ${{ github.repository }}
  54. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  55. - uses: actions/setup-node@v3
  56. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  57. with:
  58. node-version: '16'
  59. check-latest: true
  60. - name: Add to Hosts
  61. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  62. run: |
  63. echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
  64. echo "127.0.0.1 test_site_producer" | sudo tee -a /etc/hosts
  65. - name: Cache pip
  66. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  67. uses: actions/cache@v3
  68. with:
  69. path: ~/.cache/pip
  70. key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml', '**/setup.py') }}
  71. restore-keys: |
  72. ${{ runner.os }}-pip-
  73. ${{ runner.os }}-
  74. - name: Cache node modules
  75. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  76. uses: actions/cache@v3
  77. env:
  78. cache-name: cache-node-modules
  79. with:
  80. path: ~/.npm
  81. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
  82. restore-keys: |
  83. ${{ runner.os }}-build-${{ env.cache-name }}-
  84. ${{ runner.os }}-build-
  85. ${{ runner.os }}-
  86. - name: Get yarn cache directory path
  87. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  88. id: yarn-cache-dir-path
  89. run: echo "::set-output name=dir::$(yarn cache dir)"
  90. - uses: actions/cache@v3
  91. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  92. id: yarn-cache
  93. with:
  94. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  95. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  96. restore-keys: |
  97. ${{ runner.os }}-yarn-
  98. - name: Install Dependencies
  99. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  100. run: |
  101. bash ${GITHUB_WORKSPACE}/.github/helper/install_dependencies.sh
  102. bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
  103. env:
  104. BEFORE: ${{ env.GITHUB_EVENT_PATH.before }}
  105. AFTER: ${{ env.GITHUB_EVENT_PATH.after }}
  106. TYPE: server
  107. DB: postgres
  108. - name: Run Tests
  109. if: ${{ steps.check-build.outputs.build == 'strawberry' }}
  110. run: cd ~/xhiveframework-bench/ && bench --site test_site run-parallel-tests