build_and_test.yml 5.6 KB

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