common_library_tests.yaml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. name: Common Library Tests
  2. on:
  3. pull_request:
  4. paths:
  5. - library/**
  6. - .github/workflows/common_library_tests.yaml
  7. jobs:
  8. lint:
  9. name: Lint Common
  10. runs-on: ubuntu-22.04
  11. strategy:
  12. fail-fast: false
  13. matrix:
  14. helm-version:
  15. - v3.9.4
  16. - v3.10.3
  17. - v3.11.1
  18. steps:
  19. - name: Checkout
  20. uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
  21. with:
  22. fetch-depth: 1
  23. - name: Install Helm
  24. uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # tag=v3
  25. with:
  26. version: ${{ matrix.helm-version }}
  27. - uses: actions/setup-python@2c3dd9e7e29afd70cc0950079bde6c979d1f69f9 # tag=v4
  28. with:
  29. python-version: "3.10"
  30. - name: Set up chart-testing
  31. uses: helm/chart-testing-action@afea100a513515fbd68b0e72a7bb0ae34cb62aec # tag=v2.3.1
  32. - name: Run chart-testing (lint)
  33. id: lint
  34. run: |
  35. ct lint --config .github/ct-install-config/ct-lint.yaml \
  36. --lint-conf .github/ct-install-config/lint-conf.yaml \
  37. --charts library/common-test \
  38. --debug
  39. unittest:
  40. needs:
  41. - lint
  42. name: Unit Tests
  43. runs-on: ubuntu-22.04
  44. env:
  45. helmUnitVersion: 0.2.11
  46. strategy:
  47. fail-fast: false
  48. matrix:
  49. helm-version:
  50. - v3.9.4
  51. - v3.10.3
  52. - v3.11.1
  53. steps:
  54. - name: Checkout
  55. uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
  56. with:
  57. fetch-depth: 1
  58. - name: Install Helm
  59. uses: azure/setup-helm@f382f75448129b3be48f8121b9857be18d815a82 # tag=v3
  60. with:
  61. version: ${{ matrix.helm-version }}
  62. - name: Run Unit-tests
  63. shell: bash
  64. run: |
  65. # Retry helm plugin install
  66. helm plugin install https://github.com/quintush/helm-unittest --version v${helmUnitVersion} || \
  67. helm plugin install https://github.com/quintush/helm-unittest --version v${helmUnitVersion} || \
  68. helm plugin install https://github.com/quintush/helm-unittest --version v${helmUnitVersion} || \
  69. helm plugin install https://github.com/quintush/helm-unittest --version v${helmUnitVersion}
  70. # Run tests
  71. cd library/common-test/
  72. helm dependency update
  73. helm unittest --helm3 -f "tests/*/*.yaml" .
  74. install:
  75. needs:
  76. - lint
  77. name: Install Charts
  78. runs-on: ubuntu-22.04
  79. strategy:
  80. fail-fast: false
  81. matrix:
  82. # We run tests on k3s version of latest SCALE release, SCALE nightly and manually defined "latest"
  83. k3s-version:
  84. - v1.25.3+k3s1
  85. # We run tests on Helm version of latest SCALE release, SCALE nightly and manually defined "latest"
  86. helm-version:
  87. - v3.11.1
  88. values:
  89. - basic-values.yaml
  90. - configmap-values.yaml
  91. - secrets-values.yaml
  92. - imagePullSecret-values.yaml
  93. - job-values.yaml
  94. - cron-values.yaml
  95. - persistence-values.yaml
  96. - rbac-values.yaml
  97. - init-values.yaml
  98. steps:
  99. - name: Checkout
  100. uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
  101. with:
  102. fetch-depth: 1
  103. - name: Install Helm
  104. uses: azure/setup-helm@f382f75448129b3be48f8121b9857be18d815a82 # tag=v3
  105. with:
  106. version: ${{ matrix.helm-version }}
  107. - uses: actions/setup-python@2c3dd9e7e29afd70cc0950079bde6c979d1f69f9 # tag=v4
  108. with:
  109. python-version: "3.10"
  110. - name: Set up chart-testing
  111. uses: helm/chart-testing-action@afea100a513515fbd68b0e72a7bb0ae34cb62aec # tag=v2.3.1
  112. - name: Create k3d cluster - Attempt 1/3
  113. continue-on-error: true
  114. id: createc1
  115. uses: nolar/setup-k3d-k3s@293b8e5822a20bc0d5bcdd4826f1a665e72aba96 # tag=v1.0.9
  116. with:
  117. github-token: ${{ secrets.GITHUB_TOKEN }}
  118. version: ${{ matrix.k3s-version }}
  119. # Flags found here https://github.com/k3d-io/k3d
  120. k3d-args: --k3s-arg --disable=metrics-server@server:*
  121. - name: Wait 10 second to retry
  122. if: steps.createc1.outcome=='failure'
  123. run: |
  124. sleep 10
  125. - name: Create k3d cluster - Attempt 2/3
  126. continue-on-error: true
  127. if: steps.createc1.outcome=='failure'
  128. id: createc2
  129. uses: nolar/setup-k3d-k3s@293b8e5822a20bc0d5bcdd4826f1a665e72aba96 # tag=v1.0.9
  130. with:
  131. github-token: ${{ secrets.GITHUB_TOKEN }}
  132. version: ${{ matrix.k3s-version }}
  133. # Flags found here https://github.com/k3d-io/k3d
  134. k3d-args: --k3s-arg --disable=metrics-server@server:*
  135. - name: Wait 10 second to retry
  136. if: steps.createc2.outcome=='failure'
  137. run: |
  138. sleep 10
  139. - name: Create k3d cluster - Attempt 3/3
  140. id: createc3
  141. if: steps.createc2.outcome=='failure'
  142. uses: nolar/setup-k3d-k3s@293b8e5822a20bc0d5bcdd4826f1a665e72aba96 # tag=v1.0.9
  143. with:
  144. github-token: ${{ secrets.GITHUB_TOKEN }}
  145. version: ${{ matrix.k3s-version }}
  146. # Flags found here https://github.com/k3d-io/k3d
  147. k3d-args: --k3s-arg --disable=metrics-server@server:*
  148. # Install Kail to grab logs from tests, as there are cases ct-install fail to output logs
  149. - name: Install Kail
  150. run: |
  151. export KAIL_VERSION=v0.16.1
  152. wget https://github.com/boz/kail/releases/download/${KAIL_VERSION}/kail_${KAIL_VERSION}_linux_amd64.tar.gz
  153. tar -xvzf kail_${KAIL_VERSION}_linux_amd64.tar.gz
  154. chmod +x kail
  155. - name: Run chart-testing (install)
  156. run: |
  157. # Move all ci values on a temp location (or skip if already moved from another matrix job)
  158. mv library/common-test/ci library/common-test/runtests || echo "Nothing to move"
  159. # Move one values.yaml to the correct location to run the test
  160. mv -f library/common-test/runtests/${{ matrix.values }} library/common-test/values.yaml
  161. # Stat kail on the background to grab logs from tests
  162. ./kail --ignore-ns kube-system >> /tmp/output.log &
  163. # Actually run the test
  164. ct install --config .github/ct-install-config/ct-install.yaml \
  165. --charts library/common-test \
  166. --debug || (echo -e "\n\n--===PODLOGS===--\n\n" && \
  167. cat /tmp/output.log && \
  168. rm -f /tmp/output.log && exit 1)
  169. kill $!
  170. echo -e "\n\n--===PODLOGS===--\n\n"
  171. cat /tmp/output.log
  172. rm -f /tmp/output.log