build_and_test_pr.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. name: Build & Test PR
  2. on:
  3. pull_request:
  4. branches:
  5. - master
  6. - major
  7. - minor
  8. env:
  9. CI: true
  10. concurrency:
  11. group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  12. cancel-in-progress: true
  13. jobs:
  14. codegen:
  15. uses: ./.github/workflows/codegen.yml
  16. build:
  17. name: build
  18. runs-on: ubuntu-latest
  19. strategy:
  20. matrix:
  21. node: [20.x, 22.x]
  22. steps:
  23. - uses: actions/checkout@v4
  24. - name: Use Node.js ${{ matrix.node }}
  25. uses: actions/setup-node@v4
  26. with:
  27. node-version: ${{ matrix.node }}
  28. - name: npm install
  29. run: |
  30. npm install
  31. npm install --os=linux --cpu=x64 sharp
  32. - name: Build
  33. run: npm run build
  34. unit-tests:
  35. name: unit tests
  36. runs-on: ubuntu-latest
  37. strategy:
  38. matrix:
  39. node: [20.x, 22.x]
  40. steps:
  41. - uses: actions/checkout@v4
  42. - name: Use Node.js ${{ matrix.node }}
  43. uses: actions/setup-node@v4
  44. with:
  45. node-version: ${{ matrix.node }}
  46. - name: npm install
  47. run: |
  48. npm install
  49. npm install --os=linux --cpu=x64 sharp
  50. - name: Build
  51. run: npx lerna run ci
  52. - name: Unit tests
  53. run: npm run test
  54. e2e-tests:
  55. name: e2e tests
  56. runs-on: ubuntu-latest
  57. services:
  58. mariadb:
  59. image: bitnami/mariadb:10.3
  60. env:
  61. MARIADB_ROOT_USER: vendure
  62. MARIADB_ROOT_PASSWORD: password
  63. ports:
  64. - 3306
  65. options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
  66. mysql:
  67. image: bitnami/mysql:8.0
  68. env:
  69. MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
  70. MYSQL_ROOT_USER: vendure
  71. MYSQL_ROOT_PASSWORD: password
  72. ports:
  73. - 3306
  74. options: --health-cmd="mysqladmin ping --silent" --health-interval=10s --health-timeout=20s --health-retries=10
  75. postgres:
  76. image: postgres:16
  77. env:
  78. POSTGRES_USER: vendure
  79. POSTGRES_PASSWORD: password
  80. ports:
  81. - 5432
  82. options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3
  83. elastic:
  84. image: docker.elastic.co/elasticsearch/elasticsearch:7.1.1
  85. env:
  86. discovery.type: single-node
  87. bootstrap.memory_lock: true
  88. ES_JAVA_OPTS: -Xms512m -Xmx512m
  89. # Elasticsearch will force read-only mode when total available disk space is less than 5%. Since we will
  90. # be running on a shared Azure instance with 84GB SSD, we easily go below 5% available even when there are still
  91. # > 3GB free. So we set this value to an absolute one rather than a percentage to prevent all the Elasticsearch
  92. # e2e tests from failing.
  93. cluster.routing.allocation.disk.watermark.low: 500mb
  94. cluster.routing.allocation.disk.watermark.high: 200mb
  95. cluster.routing.allocation.disk.watermark.flood_stage: 100mb
  96. ports:
  97. - 9200
  98. options: --health-cmd="curl --silent --fail localhost:9200/_cluster/health" --health-interval=10s --health-timeout=5s --health-retries=3
  99. redis:
  100. image: bitnami/redis:7.4.1
  101. env:
  102. ALLOW_EMPTY_PASSWORD: yes
  103. ports:
  104. - 6379
  105. strategy:
  106. fail-fast: false
  107. matrix:
  108. node: [20.x, 22.x]
  109. db: [sqljs, mariadb, mysql, postgres]
  110. steps:
  111. - uses: actions/checkout@v4
  112. - name: Use Node.js ${{ matrix.node }}
  113. uses: actions/setup-node@v4
  114. with:
  115. node-version: ${{ matrix.node }}
  116. - name: npm install
  117. run: |
  118. npm install
  119. npm install --os=linux --cpu=x64 sharp
  120. - name: Build
  121. run: npx lerna run ci
  122. - name: e2e tests
  123. env:
  124. E2E_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
  125. E2E_MARIADB_PORT: ${{ job.services.mariadb.ports['3306'] }}
  126. E2E_POSTGRES_PORT: ${{ job.services.postgres.ports['5432'] }}
  127. E2E_ELASTIC_PORT: ${{ job.services.elastic.ports['9200'] }}
  128. E2E_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
  129. DB: ${{ matrix.db }}
  130. run: npm run e2e