build_and_test_master.yml 5.0 KB

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