ci.yml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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.17.2
  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.17.2
  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.17.2
  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.17.2
  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.17.2
  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.17.2
  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.17.2
  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@v4
  77. - name: Build
  78. uses: docker/build-push-action@v7
  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.17.2
  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, kvaps
  99. lint:
  100. runs-on: ubuntu-latest
  101. steps:
  102. - uses: actions/checkout@v6
  103. - uses: DeterminateSystems/determinate-nix-action@v3.17.2
  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@v4
  112. - name: Build
  113. uses: docker/build-push-action@v7
  114. with:
  115. context: .
  116. platforms: linux/amd64, linux/arm64, linux/arm
  117. cache-from: type=gha
  118. cache-to: type=gha,mode=max
  119. build-args: |
  120. VERSION=${{ github.sha }}
  121. push:
  122. if: github.event_name != 'pull_request'
  123. needs:
  124. - vendor
  125. - build
  126. - linux
  127. - darwin
  128. - windows
  129. - unit
  130. - lint
  131. - container
  132. runs-on: ubuntu-latest
  133. steps:
  134. - uses: actions/checkout@v6
  135. - name: Set up Docker Buildx
  136. uses: docker/setup-buildx-action@v4
  137. - name: Login to GitHub Container Registry
  138. uses: docker/login-action@v4
  139. with:
  140. registry: ghcr.io
  141. username: ${{ github.repository_owner }}
  142. password: ${{ secrets.GITHUB_TOKEN }}
  143. - name: Login to Docker Hub
  144. uses: docker/login-action@v4
  145. with:
  146. username: ${{ secrets.DOCKER_USERNAME }}
  147. password: ${{ secrets.DOCKER_PASSWORD }}
  148. - name: Extract Docker metadata
  149. id: meta
  150. uses: docker/metadata-action@v6
  151. with:
  152. images: ghcr.io/${{ env.IMAGE_NAME }},docker.io/${{ env.IMAGE_NAME }}
  153. tags: |
  154. type=sha,prefix=
  155. type=ref,event=tag
  156. type=raw,value=latest,enable={{is_default_branch}}
  157. flavor: latest=false
  158. - name: Build and push
  159. id: push
  160. uses: docker/build-push-action@v7
  161. with:
  162. context: .
  163. push: ${{ github.event_name != 'pull_request' }}
  164. platforms: linux/amd64, linux/arm64, linux/arm
  165. tags: ${{ steps.meta.outputs.tags }}
  166. labels: ${{ steps.meta.outputs.labels }}
  167. cache-from: type=gha
  168. cache-to: type=gha,mode=max
  169. build-args: |
  170. VERSION=${{ github.sha }}
  171. - name: Determine digest
  172. run: echo ${{ steps.push.outputs.digest }}