build_and_test.yml 4.6 KB

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