From c649d44c21c2bca5648a4d384e145b04434444ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=E1=B4=87=CA=80=C9=B4=E1=B4=85=20S=E1=B4=84=CA=9C?= =?UTF-8?q?=E1=B4=8F=CA=80=C9=A2=E1=B4=87=CA=80s?= Date: Wed, 27 Jul 2022 17:17:38 +0200 Subject: [PATCH] =?UTF-8?q?ci:=20=F0=9F=A7=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/charts-lint.yaml | 8 +-- .github/workflows/charts-release.yaml | 17 +++-- .github/workflows/charts-test.yaml | 100 ++++++++++++++------------ 3 files changed, 71 insertions(+), 54 deletions(-) diff --git a/.github/workflows/charts-lint.yaml b/.github/workflows/charts-lint.yaml index 106cceff..9047a5a9 100644 --- a/.github/workflows/charts-lint.yaml +++ b/.github/workflows/charts-lint.yaml @@ -10,6 +10,9 @@ on: required: true type: string +env: + HELM_VERSION: 3.9.2 + jobs: lint: name: Lint charts @@ -26,10 +29,7 @@ jobs: with: setup-tools: | helmv3 - helm: "3.8.0" - - - name: Install Helm - uses: Azure/setup-helm@v3.3 + helm: "${{ env.HELM_VERSION }}" - name: Set up chart-testing uses: helm/chart-testing-action@v2.2.1 diff --git a/.github/workflows/charts-release.yaml b/.github/workflows/charts-release.yaml index 80e29805..9200542a 100644 --- a/.github/workflows/charts-release.yaml +++ b/.github/workflows/charts-release.yaml @@ -15,6 +15,9 @@ on: paths: - "charts/**" +env: + HELM_VERSION: 3.9.2 + jobs: release-charts: name: Release charts @@ -31,7 +34,7 @@ jobs: uses: actions/checkout@v3 with: token: ${{ steps.get-app-token.outputs.token }} - path: 'src' + path: "src" fetch-depth: 0 - name: Collect changes @@ -61,14 +64,16 @@ jobs: uses: actions/checkout@v3 with: token: ${{ steps.get-app-token.outputs.token }} - path: 'dest' - ref: 'gh-pages' + path: "dest" + ref: "gh-pages" fetch-depth: 0 - - name: Install Helm - uses: Azure/setup-helm@v3.3 + - name: Install Kubernetes tools + uses: yokawasa/action-setup-kube-tools@v0.8.2 with: - token: ${{ steps.get-app-token.outputs.token }} + setup-tools: | + helmv3 + helm: "${{ env.HELM_VERSION }}" - name: Package Helm Charts shell: bash diff --git a/.github/workflows/charts-test.yaml b/.github/workflows/charts-test.yaml index eddc5292..24ae76d2 100644 --- a/.github/workflows/charts-test.yaml +++ b/.github/workflows/charts-test.yaml @@ -10,44 +10,13 @@ on: required: true type: string +env: + HELM_VERSION: 3.9.2 + jobs: - # unit-test: - # name: Run unit tests - # runs-on: ubuntu-latest - # steps: - # - name: Checkout - # uses: actions/checkout@v3 - # with: - # fetch-depth: 0 - # ref: ${{ inputs.checkoutCommit }} - - # - name: Install Kubernetes tools - # uses: yokawasa/action-setup-kube-tools@v0.8.2 - # with: - # setup-tools: | - # helmv3 - # helm: "3.8.0" - - # - name: Install Ruby - # uses: ruby/setup-ruby@v1 - # with: - # ruby-version: 2.7 - - # - name: Install dependencies - # env: - # RUBYJQ_USE_SYSTEM_LIBRARIES: 1 - # run: | - # sudo apt-get update - # sudo apt-get install libjq-dev - # bundle install - - # - name: Run tests - # run: | - # bundle exec m -r ./test/ - - generate-install-matrix: + generate-test-matrix: name: Generate matrix for install - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 outputs: matrix: | { @@ -79,13 +48,13 @@ jobs: install-charts: needs: - - generate-install-matrix - if: needs.generate-install-matrix.outputs.detected == 'true' + - generate-test-matrix + if: needs.generate-test-matrix.outputs.detected == 'true' name: Install charts strategy: - matrix: ${{ fromJson(needs.generate-install-matrix.outputs.matrix) }} + matrix: ${{ fromJson(needs.generate-test-matrix.outputs.matrix) }} fail-fast: false - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v3 @@ -99,7 +68,7 @@ jobs: setup-tools: | helmv3 kubectl - helm: "3.6.3" + helm: "${{ env.HELM_VERSION }}" kubectl: "${{ matrix.k8s_version }}" - uses: actions/setup-python@v4 @@ -124,13 +93,56 @@ jobs: # Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7 install_success: needs: - - generate-install-matrix + - generate-test-matrix - install-charts if: | always() name: Install successful - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Check install matrix status - if: ${{ (needs.generate-install-matrix.outputs.detected == 'true') && (needs.install-charts.result != 'success') }} + if: ${{ (needs.generate-test-matrix.outputs.detected == 'true') && (needs.install-charts.result != 'success') }} + run: exit 1 + + unittest: + name: Run unit tests + runs-on: ubuntu-20.04 + needs: + - generate-test-matrix + if: needs.generate-test-matrix.outputs.detected == 'true' + strategy: + matrix: ${{ fromJson(needs.generate-test-matrix.outputs.matrix) }} + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ inputs.checkoutCommit }} + + - name: Install Kubernetes tools + uses: yokawasa/action-setup-kube-tools@v0.8.2 + with: + setup-tools: | + helmv3 + helm: "${{ env.HELM_VERSION }}" + + - name: Run tests + run: | + helm plugin install https://github.com/vbehar/helm3-unittest --version v1.0.16 + cd ${{ matrix.chart }} + helm unittest -f "tests/**/*_test.yaml" . + + # Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7 + unittest_success: + needs: + - generate-test-matrix + - unittest + if: | + always() + name: Unittest successful + runs-on: ubuntu-22.04 + steps: + - name: Check unittest matrix status + if: ${{ (needs.generate-test-matrix.outputs.detected == 'true') && (needs.unittest.result != 'success') }} run: exit 1