ci.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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.15.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.15.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.15.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.15.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.15.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.15.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.15.1
  67. - uses: DeterminateSystems/magic-nix-cache-action@v13
  68. - run: nix develop . --command go test -mod=vendor --race ./...
  69. e2e:
  70. runs-on: ubuntu-latest
  71. steps:
  72. - uses: actions/checkout@v6
  73. - name: Set up Docker Buildx
  74. uses: docker/setup-buildx-action@v3
  75. - name: Build
  76. uses: docker/build-push-action@v6
  77. with:
  78. context: .
  79. platforms: linux/amd64
  80. tags: squat/kilo:test
  81. cache-from: type=gha
  82. cache-to: type=gha,mode=max
  83. load: "true"
  84. build-args: |
  85. VERSION=${{ github.sha }}
  86. - uses: DeterminateSystems/determinate-nix-action@v3.15.1
  87. - uses: DeterminateSystems/magic-nix-cache-action@v13
  88. - run: nix develop . --command make e2e
  89. lint:
  90. runs-on: ubuntu-latest
  91. steps:
  92. - uses: actions/checkout@v6
  93. - uses: DeterminateSystems/determinate-nix-action@v3.15.1
  94. - uses: DeterminateSystems/magic-nix-cache-action@v13
  95. - run: nix flake check -L --show-trace
  96. container:
  97. runs-on: ubuntu-latest
  98. steps:
  99. - uses: actions/checkout@v6
  100. - name: Set up Docker Buildx
  101. uses: docker/setup-buildx-action@v3
  102. - name: Extract Docker metadata
  103. id: meta
  104. uses: docker/metadata-action@v5
  105. with:
  106. images: ghcr.io/${{ env.IMAGE_NAME }},docker.io/${{ env.IMAGE_NAME }}
  107. tags: type=sha,prefix=
  108. flavor: latest=true
  109. - name: Build
  110. uses: docker/build-push-action@v6
  111. with:
  112. context: .
  113. platforms: linux/amd64, linux/arm64, linux/arm
  114. tags: ${{ steps.meta.outputs.tags }}
  115. labels: ${{ steps.meta.outputs.labels }}
  116. cache-from: type=gha
  117. cache-to: type=gha,mode=max
  118. build-args: |
  119. VERSION=${{ github.sha }}
  120. push:
  121. if: github.event_name != 'pull_request'
  122. needs:
  123. - vendor
  124. - build
  125. - linux
  126. - darwin
  127. - windows
  128. - unit
  129. - lint
  130. - container
  131. runs-on: ubuntu-latest
  132. steps:
  133. - uses: actions/checkout@v6
  134. - name: Set up Docker Buildx
  135. uses: docker/setup-buildx-action@v3
  136. - name: Login to GitHub Container Registry
  137. uses: docker/login-action@v3
  138. with:
  139. registry: ghcr.io
  140. username: ${{ github.repository_owner }}
  141. password: ${{ secrets.GITHUB_TOKEN }}
  142. - name: Login to Docker Hub
  143. uses: docker/login-action@v3
  144. with:
  145. username: ${{ secrets.DOCKER_USERNAME }}
  146. password: ${{ secrets.DOCKER_PASSWORD }}
  147. - name: Extract Docker metadata
  148. id: meta
  149. uses: docker/metadata-action@v5
  150. with:
  151. images: ghcr.io/${{ env.IMAGE_NAME }},docker.io/${{ env.IMAGE_NAME }}
  152. tags: type=sha,prefix=
  153. flavor: latest=true
  154. - name: Build and push
  155. id: push
  156. uses: docker/build-push-action@v6
  157. with:
  158. context: .
  159. push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
  160. platforms: linux/amd64, linux/arm64, linux/arm
  161. tags: ${{ steps.meta.outputs.tags }}
  162. labels: ${{ steps.meta.outputs.labels }}
  163. cache-from: type=gha
  164. cache-to: type=gha,mode=max
  165. build-args: |
  166. VERSION=${{ github.sha }}
  167. - name: Determine digest
  168. run: echo ${{ steps.push.outputs.digest }}