build_and_test.yml 4.1 KB

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