2
0

ci.yml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. name: CI
  2. on:
  3. push:
  4. branches: [main]
  5. tags:
  6. - "*"
  7. pull_request:
  8. schedule:
  9. - cron: "0 0 * * *"
  10. workflow_dispatch:
  11. env:
  12. IMAGE_NAME: ${{ github.repository }}
  13. jobs:
  14. vendor:
  15. runs-on: ubuntu-latest
  16. steps:
  17. - uses: actions/checkout@v6
  18. - uses: DeterminateSystems/determinate-nix-action@v3.16.1
  19. - uses: DeterminateSystems/magic-nix-cache-action@v13
  20. - run: |
  21. go mod tidy
  22. go mod vendor
  23. git diff --exit-code
  24. build:
  25. runs-on: ubuntu-latest
  26. steps:
  27. - uses: actions/checkout@v6
  28. - uses: DeterminateSystems/determinate-nix-action@v3.16.1
  29. - uses: DeterminateSystems/magic-nix-cache-action@v13
  30. - run: nix build
  31. docs:
  32. runs-on: ubuntu-latest
  33. steps:
  34. - uses: actions/checkout@v6
  35. - uses: DeterminateSystems/determinate-nix-action@v3.16.1
  36. - uses: DeterminateSystems/magic-nix-cache-action@v13
  37. - name: Build docs
  38. run: |
  39. nix develop . --command make gen-docs
  40. git diff --exit-code
  41. linux:
  42. runs-on: ubuntu-latest
  43. steps:
  44. - uses: actions/checkout@v6
  45. - uses: DeterminateSystems/determinate-nix-action@v3.16.1
  46. - uses: DeterminateSystems/magic-nix-cache-action@v13
  47. - run: nix build .#kilo-cross-linux-amd64 .#kilo-cross-linux-arm64 .#kilo-cross-linux-arm
  48. darwin:
  49. runs-on: ubuntu-latest
  50. steps:
  51. - uses: actions/checkout@v6
  52. - uses: DeterminateSystems/determinate-nix-action@v3.16.1
  53. - uses: DeterminateSystems/magic-nix-cache-action@v13
  54. - run: nix build .#kgctl-cross-darwin-amd64 .#kgctl-cross-darwin-arm64
  55. windows:
  56. runs-on: ubuntu-latest
  57. steps:
  58. - uses: actions/checkout@v6
  59. - uses: DeterminateSystems/determinate-nix-action@v3.16.1
  60. - uses: DeterminateSystems/magic-nix-cache-action@v13
  61. - run: nix build .#kgctl-cross-windows-amd64
  62. unit:
  63. runs-on: ubuntu-latest
  64. steps:
  65. - uses: actions/checkout@v6
  66. - uses: DeterminateSystems/determinate-nix-action@v3.16.1
  67. - uses: DeterminateSystems/magic-nix-cache-action@v13
  68. - run: nix develop . --command go test -mod=vendor --race ./...
  69. e2e:
  70. runs-on:
  71. - nscloud-ubuntu-22.04-amd64-8x16-with-features
  72. - namespace-features:kernel.release-channel=bleeding-edge
  73. steps:
  74. - uses: actions/checkout@v6
  75. - name: Set up Docker Buildx
  76. uses: docker/setup-buildx-action@v3
  77. - name: Build
  78. uses: docker/build-push-action@v6
  79. with:
  80. context: .
  81. platforms: linux/amd64
  82. tags: squat/kilo:test
  83. cache-from: type=gha
  84. cache-to: type=gha,mode=max
  85. load: "true"
  86. build-args: |
  87. VERSION=${{ github.sha }}
  88. - uses: DeterminateSystems/determinate-nix-action@v3.16.1
  89. - uses: DeterminateSystems/magic-nix-cache-action@v13
  90. - env:
  91. E2E_SKIP_TEARDOWN_ON_FAILURE: "true"
  92. run: nix develop . --command make e2e
  93. - name: Breakpoint if tests failed
  94. if: failure()
  95. uses: namespacelabs/breakpoint-action@v0
  96. with:
  97. duration: 15m
  98. authorized-users: squat, leonnicolas
  99. lint:
  100. runs-on: ubuntu-latest
  101. steps:
  102. - uses: actions/checkout@v6
  103. - uses: DeterminateSystems/determinate-nix-action@v3.16.1
  104. - uses: DeterminateSystems/magic-nix-cache-action@v13
  105. - run: nix flake check -L --show-trace
  106. container:
  107. runs-on: ubuntu-latest
  108. steps:
  109. - uses: actions/checkout@v6
  110. - name: Set up Docker Buildx
  111. uses: docker/setup-buildx-action@v3
  112. - name: Extract Docker metadata
  113. id: meta
  114. uses: docker/metadata-action@v5
  115. with:
  116. images: ghcr.io/${{ env.IMAGE_NAME }},docker.io/${{ env.IMAGE_NAME }}
  117. tags: type=sha,prefix=
  118. flavor: latest=true
  119. - name: Build
  120. uses: docker/build-push-action@v6
  121. with:
  122. context: .
  123. platforms: linux/amd64, linux/arm64, linux/arm
  124. tags: ${{ steps.meta.outputs.tags }}
  125. labels: ${{ steps.meta.outputs.labels }}
  126. cache-from: type=gha
  127. cache-to: type=gha,mode=max
  128. build-args: |
  129. VERSION=${{ github.sha }}
  130. push:
  131. if: github.event_name != 'pull_request'
  132. needs:
  133. - vendor
  134. - build
  135. - linux
  136. - darwin
  137. - windows
  138. - unit
  139. - lint
  140. - container
  141. runs-on: ubuntu-latest
  142. steps:
  143. - uses: actions/checkout@v6
  144. - name: Set up Docker Buildx
  145. uses: docker/setup-buildx-action@v3
  146. - name: Login to GitHub Container Registry
  147. uses: docker/login-action@v3
  148. with:
  149. registry: ghcr.io
  150. username: ${{ github.repository_owner }}
  151. password: ${{ secrets.GITHUB_TOKEN }}
  152. - name: Login to Docker Hub
  153. uses: docker/login-action@v3
  154. with:
  155. username: ${{ secrets.DOCKER_USERNAME }}
  156. password: ${{ secrets.DOCKER_PASSWORD }}
  157. - name: Extract Docker metadata
  158. id: meta
  159. uses: docker/metadata-action@v5
  160. with:
  161. images: ghcr.io/${{ env.IMAGE_NAME }},docker.io/${{ env.IMAGE_NAME }}
  162. tags: type=sha,prefix=
  163. flavor: latest=true
  164. - name: Build and push
  165. id: push
  166. uses: docker/build-push-action@v6
  167. with:
  168. context: .
  169. push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
  170. platforms: linux/amd64, linux/arm64, linux/arm
  171. tags: ${{ steps.meta.outputs.tags }}
  172. labels: ${{ steps.meta.outputs.labels }}
  173. cache-from: type=gha
  174. cache-to: type=gha,mode=max
  175. build-args: |
  176. VERSION=${{ github.sha }}
  177. - name: Determine digest
  178. run: echo ${{ steps.push.outputs.digest }}