test-cli.yml 3.4 KB

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