You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

203 lines
6.4 KiB

3 years ago
3 years ago
  1. name: Continuous Integration
  2. on:
  3. pull_request:
  4. branches: ['*', series/*]
  5. push:
  6. branches: ['*', series/*]
  7. tags: [v*]
  8. jobs:
  9. # Label of the container job
  10. build:
  11. name: Build and Test
  12. # Containers must run in Linux based operating systems
  13. runs-on: ubuntu-latest
  14. # Docker Hub image that `container-job` executes in
  15. # container: node:12-buster
  16. env:
  17. # The hostname used to communicate with the PostgreSQL service container
  18. CODEGEN_DB_HOST: localhost
  19. # The default PostgreSQL port
  20. CODEGEN_DB_PORT: 5432
  21. CODEGEN_DB_USER: codegenuser
  22. CODEGEN_DB_PASSWORD: postgres
  23. CODEGEN_DB_NAME: codegendb
  24. # Service containers to run with `container-job`
  25. services:
  26. # Label used to access the service container
  27. postgres:
  28. # Docker Hub image
  29. image: postgres:12-alpine
  30. # Provide the password for postgres
  31. env:
  32. POSTGRES_PASSWORD: postgres
  33. POSTGRES_USER: codegenuser
  34. POSTGRES_DB: codegendb
  35. # Set health checks to wait until postgres has started
  36. options: >-
  37. --health-cmd pg_isready
  38. --health-interval 10s
  39. --health-timeout 5s
  40. --health-retries 5
  41. ports:
  42. - 5432:5432
  43. steps:
  44. # Downloads a copy of the code in your repository before running CI tests
  45. - name: Check out repository code
  46. uses: actions/checkout@v2
  47. - name: Coursier cache
  48. uses: coursier/cache-action@v6
  49. # with:
  50. # path: |
  51. # ~/.cache/blah
  52. # - name: Cache SBT
  53. # uses: actions/cache@v2
  54. # id: cache-sbt-dependencies
  55. # with:
  56. # path: |
  57. # $HOME/.sbt
  58. # $HOME/.ivy2/cache
  59. # $HOME/.coursier/cache/v1
  60. # $HOME/.cache/coursier/v1
  61. # key: ${{ runner.os }}-sbtnew-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
  62. # restore-keys: |
  63. # ${{ runner.os }}-sbtnew-
  64. - name: Setup
  65. uses: olafurpg/setup-scala@v10
  66. with:
  67. java-version: adopt@1.11
  68. # - name: Install docker
  69. # run: |
  70. # curl -fsSL https://get.docker.com -o get-docker.sh
  71. # sh get-docker.sh
  72. # docker login -p "${{ secrets.DOCKER_LOGIN_PASSWORD }}" -u rohansircar
  73. # - name: Migrate
  74. # run: csbt flyway/flywayMigrate
  75. - name: Compile
  76. run: |
  77. csbt flyway/flywayMigrate
  78. csbt compile
  79. csbt test:compile
  80. - name: Run Tests
  81. run: |
  82. echo $GITHUB_REF
  83. echo ${GITHUB_REF#refs/*/}
  84. # echo ${github.event_name}
  85. # csbt test
  86. # ls -alh ~/
  87. # - name: Package
  88. # run: csbt docker:publish
  89. # Label of the container job
  90. publish:
  91. name: Publish Release Docker Image
  92. needs: [build]
  93. if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
  94. # Containers must run in Linux based operating systems
  95. runs-on: ubuntu-latest
  96. # Docker Hub image that `container-job` executes in
  97. # container: node:12-buster
  98. env:
  99. # The hostname used to communicate with the PostgreSQL service container
  100. CODEGEN_DB_HOST: localhost
  101. # The default PostgreSQL port
  102. CODEGEN_DB_PORT: 5432
  103. CODEGEN_DB_USER: codegenuser
  104. CODEGEN_DB_PASSWORD: postgres
  105. CODEGEN_DB_NAME: codegendb
  106. # Service containers to run with `container-job`
  107. services:
  108. # Label used to access the service container
  109. postgres:
  110. # Docker Hub image
  111. image: postgres:12-alpine
  112. # Provide the password for postgres
  113. env:
  114. POSTGRES_PASSWORD: postgres
  115. POSTGRES_USER: codegenuser
  116. POSTGRES_DB: codegendb
  117. # Set health checks to wait until postgres has started
  118. options: >-
  119. --health-cmd pg_isready
  120. --health-interval 10s
  121. --health-timeout 5s
  122. --health-retries 5
  123. ports:
  124. - 5432:5432
  125. steps:
  126. # Downloads a copy of the code in your repository before running CI tests
  127. - name: Check out repository code
  128. uses: actions/checkout@v2
  129. - name: Coursier cache
  130. uses: coursier/cache-action@v6
  131. - name: Setup
  132. uses: olafurpg/setup-scala@v10
  133. with:
  134. java-version: adopt@1.11
  135. - name: Docker login
  136. run: |
  137. docker login -p "${{ secrets.DOCKER_LOGIN_PASSWORD }}" -u rohansircar
  138. - name: Publish
  139. run: |
  140. csbt flyway/flywayMigrate
  141. csbt compile
  142. echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
  143. csbt docker:stage
  144. publish-devel:
  145. name: Publish Devel Docker Image
  146. needs: [build]
  147. if: github.event_name != 'pull_request' && github.ref == 'refs/heads/devel'
  148. # Containers must run in Linux based operating systems
  149. runs-on: ubuntu-latest
  150. # Docker Hub image that `container-job` executes in
  151. # container: node:12-buster
  152. env:
  153. # The hostname used to communicate with the PostgreSQL service container
  154. CODEGEN_DB_HOST: localhost
  155. # The default PostgreSQL port
  156. CODEGEN_DB_PORT: 5432
  157. CODEGEN_DB_USER: codegenuser
  158. CODEGEN_DB_PASSWORD: postgres
  159. CODEGEN_DB_NAME: codegendb
  160. # Service containers to run with `container-job`
  161. services:
  162. # Label used to access the service container
  163. postgres:
  164. # Docker Hub image
  165. image: postgres:12-alpine
  166. # Provide the password for postgres
  167. env:
  168. POSTGRES_PASSWORD: postgres
  169. POSTGRES_USER: codegenuser
  170. POSTGRES_DB: codegendb
  171. # Set health checks to wait until postgres has started
  172. options: >-
  173. --health-cmd pg_isready
  174. --health-interval 10s
  175. --health-timeout 5s
  176. --health-retries 5
  177. ports:
  178. - 5432:5432
  179. steps:
  180. # Downloads a copy of the code in your repository before running CI tests
  181. - name: Check out repository code
  182. uses: actions/checkout@v2
  183. - name: Coursier cache
  184. uses: coursier/cache-action@v6
  185. - name: Setup
  186. uses: olafurpg/setup-scala@v10
  187. with:
  188. java-version: adopt@1.11
  189. - name: Docker login
  190. run: |
  191. docker login -p "${{ secrets.DOCKER_LOGIN_PASSWORD }}" -u rohansircar
  192. - name: Publish
  193. run: |
  194. csbt flyway/flywayMigrate
  195. csbt compile
  196. csbt docker:stage