build_and_test_master.yml 4.8 KB

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