common_library_tests.yaml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. name: Common Library Tests
  2. on:
  3. pull_request:
  4. paths:
  5. - library/common/**
  6. - library/common-test/**
  7. - .github/ct-install-config/common*.yaml
  8. - '!.github/ct-install-config/charts*'
  9. - .github/workflows/common_library_tests.yaml
  10. jobs:
  11. lint:
  12. name: Lint Common
  13. runs-on: ubuntu-22.04
  14. strategy:
  15. fail-fast: false
  16. matrix:
  17. helm-version:
  18. - v3.9.4
  19. - v3.10.3
  20. - v3.12.1
  21. steps:
  22. - name: Checkout
  23. uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
  24. with:
  25. # Depth 0 is required for chart-testing to work properly
  26. fetch-depth: 0
  27. - name: Install Helm
  28. uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # tag=v3
  29. with:
  30. version: ${{ matrix.helm-version }}
  31. - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # tag=v4
  32. with:
  33. python-version: "3.10"
  34. - name: Set up chart-testing
  35. uses: helm/chart-testing-action@b43128a8b25298e1e7b043b78ea6613844e079b1 # tag=v2.6.0
  36. - name: Run chart-testing (lint)
  37. id: lint
  38. run: |
  39. ct lint --config .github/ct-install-config/common-ct-lint.yaml
  40. unittest:
  41. needs:
  42. - lint
  43. name: Unit Tests
  44. runs-on: ubuntu-22.04
  45. env:
  46. helmUnitVersion: 0.3.0
  47. strategy:
  48. fail-fast: false
  49. matrix:
  50. helm-version:
  51. - v3.9.4
  52. - v3.10.3
  53. - v3.12.1
  54. steps:
  55. - name: Checkout
  56. uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
  57. with:
  58. # Depth 0 is required for chart-testing to work properly
  59. fetch-depth: 0
  60. - name: Install Helm
  61. uses: azure/setup-helm@f382f75448129b3be48f8121b9857be18d815a82 # tag=v3
  62. with:
  63. version: ${{ matrix.helm-version }}
  64. - name: Run Unit-tests
  65. shell: bash
  66. run: |
  67. # Retry helm plugin install
  68. helm plugin install https://github.com/helm-unittest/helm-unittest --version v${helmUnitVersion} || \
  69. helm plugin install https://github.com/helm-unittest/helm-unittest --version v${helmUnitVersion} || \
  70. helm plugin install https://github.com/helm-unittest/helm-unittest --version v${helmUnitVersion} || \
  71. helm plugin install https://github.com/helm-unittest/helm-unittest --version v${helmUnitVersion}
  72. # Run tests
  73. cd library/common-test/
  74. helm dependency update
  75. helm unittest -f "tests/*/*.yaml" .
  76. install:
  77. needs:
  78. - lint
  79. name: Install Charts
  80. runs-on: ubuntu-22.04
  81. strategy:
  82. fail-fast: false
  83. matrix:
  84. # We run tests on k3s version of latest SCALE release, SCALE nightly and manually defined "latest"
  85. k3s-version:
  86. - v1.26.6+k3s1
  87. # We run tests on Helm version of latest SCALE release, SCALE nightly and manually defined "latest"
  88. helm-version:
  89. - v3.12.1
  90. values:
  91. - basic-values.yaml
  92. - configmap-values.yaml
  93. - secrets-values.yaml
  94. - imagePullSecret-values.yaml
  95. - job-values.yaml
  96. - cron-values.yaml
  97. - persistence-values.yaml
  98. - rbac-values.yaml
  99. - init-values.yaml
  100. steps:
  101. - name: Checkout
  102. uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
  103. with:
  104. # Depth 0 is required for chart-testing to work properly
  105. fetch-depth: 0
  106. - name: Install Helm
  107. uses: azure/setup-helm@f382f75448129b3be48f8121b9857be18d815a82 # tag=v3
  108. with:
  109. version: ${{ matrix.helm-version }}
  110. - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # tag=v4
  111. with:
  112. python-version: "3.10"
  113. - name: Set up chart-testing
  114. uses: helm/chart-testing-action@b43128a8b25298e1e7b043b78ea6613844e079b1 # tag=v2.6.0
  115. - name: Create k3d cluster - Attempt 1/3
  116. continue-on-error: true
  117. id: createc1
  118. uses: nolar/setup-k3d-k3s@293b8e5822a20bc0d5bcdd4826f1a665e72aba96 # tag=v1.0.9
  119. with:
  120. github-token: ${{ secrets.GITHUB_TOKEN }}
  121. version: ${{ matrix.k3s-version }}
  122. # Flags found here https://github.com/k3d-io/k3d
  123. k3d-args: --k3s-arg --disable=metrics-server@server:*
  124. - name: Wait 10 second to retry
  125. if: steps.createc1.outcome=='failure'
  126. run: |
  127. sleep 10
  128. - name: Create k3d cluster - Attempt 2/3
  129. continue-on-error: true
  130. if: steps.createc1.outcome=='failure'
  131. id: createc2
  132. uses: nolar/setup-k3d-k3s@293b8e5822a20bc0d5bcdd4826f1a665e72aba96 # tag=v1.0.9
  133. with:
  134. github-token: ${{ secrets.GITHUB_TOKEN }}
  135. version: ${{ matrix.k3s-version }}
  136. # Flags found here https://github.com/k3d-io/k3d
  137. k3d-args: --k3s-arg --disable=metrics-server@server:*
  138. - name: Wait 10 second to retry
  139. if: steps.createc2.outcome=='failure'
  140. run: |
  141. sleep 10
  142. - name: Create k3d cluster - Attempt 3/3
  143. id: createc3
  144. if: steps.createc2.outcome=='failure'
  145. uses: nolar/setup-k3d-k3s@293b8e5822a20bc0d5bcdd4826f1a665e72aba96 # tag=v1.0.9
  146. with:
  147. github-token: ${{ secrets.GITHUB_TOKEN }}
  148. version: ${{ matrix.k3s-version }}
  149. # Flags found here https://github.com/k3d-io/k3d
  150. k3d-args: --k3s-arg --disable=metrics-server@server:*
  151. - name: Run chart-testing (install)
  152. run: |
  153. # This is done to improve speed of the tests, so we can run tests in parallel
  154. # Move all ci values on a temp location (or skip if already moved from another matrix job)
  155. mv library/common-test/ci library/common-test/runtests || echo "Nothing to move"
  156. # Move one values.yaml to the correct location to run the test
  157. mv -f library/common-test/runtests/${{ matrix.values }} library/common-test/values.yaml
  158. # Actually run the test
  159. ct install --config .github/ct-install-config/common-ct-install.yaml