build_and_test.yml 5.5 KB

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