build_and_test.yml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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:7.1.1
  104. env:
  105. discovery.type: single-node
  106. bootstrap.memory_lock: true
  107. ES_JAVA_OPTS: -Xms512m -Xmx512m
  108. # Elasticsearch will force read-only mode when total available disk space is less than 5%. Since we will
  109. # be running on a shared Azure instance with 84GB SSD, we easily go below 5% available even when there are still
  110. # > 3GB free. So we set this value to an absolute one rather than a percentage to prevent all the Elasticsearch
  111. # e2e tests from failing.
  112. cluster.routing.allocation.disk.watermark.low: 500mb
  113. cluster.routing.allocation.disk.watermark.high: 200mb
  114. cluster.routing.allocation.disk.watermark.flood_stage: 100mb
  115. ports:
  116. - 9200
  117. options: --health-cmd="curl --silent --fail localhost:9200/_cluster/health" --health-interval=10s --health-timeout=5s --health-retries=3
  118. redis:
  119. image: redis:7.4.1
  120. ports:
  121. - 6379
  122. strategy:
  123. fail-fast: false
  124. matrix:
  125. node: [20.x, 22.x, 24.x]
  126. db: [sqljs, mariadb, mysql, postgres]
  127. steps:
  128. - uses: actions/checkout@v4
  129. - name: Use Node.js ${{ matrix.node }}
  130. uses: actions/setup-node@v4
  131. with:
  132. node-version: ${{ matrix.node }}
  133. - name: npm install
  134. run: |
  135. npm install
  136. npm install --os=linux --cpu=x64 sharp
  137. - name: Build
  138. run: npx lerna run ci
  139. - name: e2e tests
  140. env:
  141. E2E_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
  142. E2E_MARIADB_PORT: ${{ job.services.mariadb.ports['3306'] }}
  143. E2E_POSTGRES_PORT: ${{ job.services.postgres.ports['5432'] }}
  144. E2E_ELASTIC_PORT: ${{ job.services.elastic.ports['9200'] }}
  145. E2E_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
  146. DB: ${{ matrix.db }}
  147. run: npm run e2e