test-cli.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. name: Test CLI
  2. on:
  3. pull_request:
  4. branches:
  5. - 'feat/v2'
  6. - 'feat/v2-ci'
  7. jobs:
  8. test-cli-yarn:
  9. name: "Test CLI (Yarn)"
  10. env:
  11. NODE_ENV: CI
  12. REDIS_URL: redis://localhost:6379
  13. DATABASE_URL: "postgres://postgres:postgres@localhost/cli-test"
  14. POSTGRES_URL: "postgres://postgres:postgres@localhost/cli-test"
  15. services:
  16. redis:
  17. image: redis
  18. options: >-
  19. --health-cmd "redis-cli ping"
  20. --health-interval 10s
  21. --health-timeout 5s
  22. --health-retries 5
  23. ports:
  24. - 6379:6379
  25. postgres:
  26. image: postgres
  27. env:
  28. POSTGRES_PASSWORD: postgres
  29. POSTGRES_USER: postgres
  30. POSTGRES_DB: cli-test
  31. options: >-
  32. --health-cmd pg_isready
  33. --health-interval 10s
  34. --health-timeout 5s
  35. --health-retries 5
  36. ports:
  37. - 5432:5432
  38. runs-on: ubuntu-latest
  39. steps:
  40. - name: Checkout
  41. uses: actions/checkout@v3
  42. with:
  43. fetch-depth: 0
  44. - name: Cancel Previous Runs
  45. uses: styfle/cancel-workflow-action@0.11.0
  46. with:
  47. access_token: ${{ github.token }}
  48. - name: Setup Node.js environment
  49. uses: actions/setup-node@v3
  50. with:
  51. node-version: 20
  52. - name: Install Dependencies
  53. run: yarn install
  54. - name: Check CLI tool is installed
  55. run: ./node_modules/.bin/medusa -v
  56. - name: run build
  57. run: yarn build
  58. - name: Run migrations
  59. run: npx medusa migrations run
  60. - name: Run seed
  61. run: yarn seed
  62. - name: Run development server
  63. run: yarn dev &
  64. - name: Wait for live server response
  65. shell: "bash"
  66. run: ./.github/scripts/wait-for-server-live.sh
  67. - name: Kill server
  68. shell: "bash"
  69. run: kill -9 $(lsof -t -i :9000)
  70. test-cli-npm:
  71. name: "Test CLI (npm)"
  72. env:
  73. NODE_ENV: CI
  74. REDIS_URL: redis://localhost:6379
  75. DATABASE_URL: "postgres://postgres:postgres@localhost/cli-test"
  76. POSTGRES_URL: "postgres://postgres:postgres@localhost/cli-test"
  77. services:
  78. postgres:
  79. image: postgres
  80. env:
  81. POSTGRES_PASSWORD: postgres
  82. POSTGRES_USER: postgres
  83. POSTGRES_DB: cli-test
  84. options: >-
  85. --health-cmd pg_isready
  86. --health-interval 10s
  87. --health-timeout 5s
  88. --health-retries 5
  89. ports:
  90. - 5432:5432
  91. runs-on: ubuntu-latest
  92. steps:
  93. - name: Checkout
  94. uses: actions/checkout@v3
  95. with:
  96. fetch-depth: 0
  97. - name: Cancel Previous Runs
  98. uses: styfle/cancel-workflow-action@0.11.0
  99. with:
  100. access_token: ${{ github.token }}
  101. - name: Setup Node.js environment
  102. uses: actions/setup-node@v3
  103. with:
  104. node-version: 20
  105. cache: "npm"
  106. - name: Install Dependencies
  107. run: npm install
  108. - name: Check CLI tool is installed
  109. run: ./node_modules/.bin/medusa -v
  110. - name: run medusa build
  111. run: npm run build
  112. - name: Run migrations
  113. run: npx medusa migrations run
  114. - name: Run seed
  115. run: npm run seed
  116. - name: Run development server
  117. run: npm run dev -- &
  118. - name: Wait for live server response
  119. shell: "bash"
  120. run: ./.github/scripts/wait-for-server-live.sh
  121. - name: Kill server
  122. shell: "bash"
  123. run: kill -9 $(lsof -t -i :9000)