1
0

build_and_test.yml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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: mariadb:11.5
  82. env:
  83. MARIADB_ROOT_PASSWORD: password
  84. ports:
  85. - 3306
  86. options: --health-cmd="mariadb-admin ping -h localhost -u vendure -ppassword" --health-interval=10s --health-timeout=5s --health-retries=3
  87. mysql:
  88. image: vendure/mysql-8-native-auth:latest
  89. env:
  90. MYSQL_ROOT_PASSWORD: password
  91. ports:
  92. - 3306
  93. options: --health-cmd="mysqladmin ping --silent" --health-interval=10s --health-timeout=20s --health-retries=10
  94. postgres:
  95. image: postgres:16
  96. env:
  97. POSTGRES_USER: vendure
  98. POSTGRES_PASSWORD: password
  99. ports:
  100. - 5432
  101. options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3
  102. elastic:
  103. image: docker.elastic.co/elasticsearch/elasticsearch:9.1.0
  104. env:
  105. node.name: es
  106. cluster.name: es-docker-cluster
  107. xpack.security.enabled: false
  108. xpack.security.http.ssl.enabled: false
  109. xpack.security.transport.ssl.enabled: false
  110. xpack.license.self_generated.type: basic
  111. discovery.type: single-node
  112. bootstrap.memory_lock: true
  113. ES_JAVA_OPTS: -Xms512m -Xmx512m
  114. # Elasticsearch will force read-only mode when total available disk space is less than 5%. Since we will
  115. # be running on a shared Azure instance with 84GB SSD, we easily go below 5% available even when there are still
  116. # > 3GB free. So we set this value to an absolute one rather than a percentage to prevent all the Elasticsearch
  117. # e2e tests from failing.
  118. cluster.routing.allocation.disk.watermark.low: 500mb
  119. cluster.routing.allocation.disk.watermark.high: 200mb
  120. cluster.routing.allocation.disk.watermark.flood_stage: 100mb
  121. ports:
  122. - 9200
  123. options: --health-cmd="curl --silent --fail localhost:9200/_cluster/health" --health-interval=10s --health-timeout=5s --health-retries=3
  124. redis:
  125. image: redis:7.4.1
  126. ports:
  127. - 6379
  128. strategy:
  129. fail-fast: false
  130. matrix:
  131. node: [20.x, 22.x, 24.x]
  132. db: [sqljs, mariadb, mysql, postgres]
  133. steps:
  134. - uses: actions/checkout@v4
  135. - name: Use Node.js ${{ matrix.node }}
  136. uses: actions/setup-node@v4
  137. with:
  138. node-version: ${{ matrix.node }}
  139. - name: npm install
  140. run: |
  141. npm install
  142. npm install --os=linux --cpu=x64 sharp
  143. - name: Build
  144. run: npx lerna run ci
  145. - name: e2e tests
  146. env:
  147. E2E_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
  148. E2E_MARIADB_PORT: ${{ job.services.mariadb.ports['3306'] }}
  149. E2E_POSTGRES_PORT: ${{ job.services.postgres.ports['5432'] }}
  150. E2E_ELASTIC_PORT: ${{ job.services.elastic.ports['9200'] }}
  151. E2E_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
  152. DB: ${{ matrix.db }}
  153. run: npm run e2e