ci.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. name: CI
  2. on:
  3. push:
  4. pull_request:
  5. concurrency:
  6. group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  7. cancel-in-progress: true
  8. jobs:
  9. run-tests:
  10. name: ${{ matrix.os }} ruby-${{ matrix.ruby }} ${{ matrix.database_adapter }}
  11. runs-on: ${{ matrix.os }}
  12. strategy:
  13. fail-fast: false
  14. matrix:
  15. os:
  16. - ubuntu-20.04
  17. database_adapter:
  18. - mysql2
  19. - postgresql
  20. ruby:
  21. - "3.2"
  22. env:
  23. DATABASE_ADAPTER: ${{ matrix.database_adapter }}
  24. DATABASE_HOST: "127.0.0.1"
  25. DATABASE_USERNAME: root
  26. DATABASE_PASSWORD: password
  27. services:
  28. mysql:
  29. image: mysql:latest
  30. env:
  31. MYSQL_ROOT_PASSWORD: password
  32. ports:
  33. - 3306:3306
  34. options: >-
  35. --health-cmd "mysqladmin ping"
  36. --health-interval 10s
  37. --health-timeout 5s
  38. --health-retries 3
  39. postgres:
  40. image: postgres:latest
  41. env:
  42. POSTGRES_USER: root
  43. POSTGRES_PASSWORD: password
  44. ports:
  45. - 5432:5432
  46. options: >-
  47. --health-cmd pg_isready
  48. --health-interval 10s
  49. --health-timeout 5s
  50. --health-retries 3
  51. steps:
  52. - uses: actions/checkout@v4
  53. - name: Set up Ruby
  54. uses: ruby/setup-ruby@v1
  55. with:
  56. ruby-version: ${{ matrix.ruby }}
  57. rubygems: latest
  58. bundler: latest
  59. bundler-cache: true
  60. - name: Set up database
  61. run: bundle exec rake db:create db:migrate
  62. - name: Run tests
  63. run: bundle exec rake
  64. - name: Coveralls
  65. uses: coverallsapp/github-action@v2
  66. with:
  67. fail-on-error: false
  68. ghcr-build-docker-images:
  69. name: ghcr-docker-build-${{ matrix.docker_image }}
  70. needs: run-tests
  71. runs-on: ubuntu-latest
  72. strategy:
  73. fail-fast: false
  74. matrix:
  75. docker_image:
  76. - huginn/huginn
  77. - huginn/huginn-single-process
  78. env:
  79. DOCKER_IMAGE: ghcr.io/${{ matrix.docker_image }}
  80. DOCKERFILE: docker/${{ contains(matrix.docker_image, 'single-process') && 'single-process' || 'multi-process' }}/Dockerfile
  81. DOCKER_USER: ${{ github.actor }}
  82. DOCKER_PASS: ${{ secrets.GITHUB_TOKEN }}
  83. REGISTRY: ghcr.io
  84. steps:
  85. - uses: actions/checkout@v4
  86. - name: Build a docker image
  87. run: |
  88. if [ "$GITHUB_EVENT_NAME" = push -a "$GITHUB_REF_NAME" = master ]; then
  89. ./build_docker_image.sh --push
  90. else
  91. ./build_docker_image.sh
  92. fi
  93. build-docker-images:
  94. name: docker-build-${{ matrix.docker_image }}
  95. needs: run-tests
  96. runs-on: ubuntu-latest
  97. strategy:
  98. fail-fast: false
  99. matrix:
  100. docker_image:
  101. - huginn/huginn
  102. - huginn/huginn-single-process
  103. env:
  104. DOCKER_IMAGE: ${{ matrix.docker_image }}
  105. DOCKERFILE: docker/${{ contains(matrix.docker_image, 'single-process') && 'single-process' || 'multi-process' }}/Dockerfile
  106. DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }}
  107. DOCKER_PASS: ${{ secrets.DOCKERHUB_TOKEN }}
  108. BUILD_ARGS: --build-arg OUTDATED_DOCKER_REGISTRY=true
  109. steps:
  110. - uses: actions/checkout@v4
  111. - name: Build a docker image
  112. run: |
  113. if [ "$GITHUB_EVENT_NAME" = push -a "$GITHUB_REF_NAME" = master ]; then
  114. ./build_docker_image.sh --push
  115. fi