build_and_test_master.yml 4.9 KB

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