From e6488ff5c1bfaed75fd65283ba84cc107fc4cba4 Mon Sep 17 00:00:00 2001 From: chgl Date: Tue, 9 Feb 2021 19:24:50 +0100 Subject: [PATCH 1/5] ci: added workflow for chart testing --- .github/ct/install.yaml | 7 +++++++ .github/workflows/ci.yaml | 15 +++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 .github/ct/install.yaml diff --git a/.github/ct/install.yaml b/.github/ct/install.yaml new file mode 100644 index 00000000..ee908bbb --- /dev/null +++ b/.github/ct/install.yaml @@ -0,0 +1,7 @@ +chart-dirs: + - charts +chart-repos: + - bitnami=https://charts.bitnami.com/bitnami + - chgl=https://chgl.github.io/charts +debug: true +remote: origin diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 90fe3990..daf5378d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -52,3 +52,18 @@ jobs: run: yamllint . - name: Run Powerlint run: bash scripts/chart-powerlint.sh + + test-in-cluster: + runs-on: ubuntu-20.04 + needs: + - ct-lint + - power-lint + steps: + - name: Create k8s Kind Cluster + uses: helm/kind-action@v1.1.0 + + - name: Run chart-testing (install) + uses: helm/chart-testing-action@v2.0.1 + with: + config: .github/ct/install.yaml + command: install From e5592ac09747c2049039f3b88016d0daa4f266e4 Mon Sep 17 00:00:00 2001 From: chgl Date: Tue, 9 Feb 2021 19:28:21 +0100 Subject: [PATCH 2/5] fix: test pod and probes --- charts/hapi-fhir-jpaserver/Chart.yaml | 2 +- charts/hapi-fhir-jpaserver/templates/deployment.yaml | 4 ++-- .../hapi-fhir-jpaserver/templates/tests/test-connection.yaml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/charts/hapi-fhir-jpaserver/Chart.yaml b/charts/hapi-fhir-jpaserver/Chart.yaml index 99f5fb6c..750a998a 100644 --- a/charts/hapi-fhir-jpaserver/Chart.yaml +++ b/charts/hapi-fhir-jpaserver/Chart.yaml @@ -13,4 +13,4 @@ dependencies: repository: https://charts.bitnami.com/bitnami condition: postgresql.enabled appVersion: 5.2.0 -version: 0.1.3 +version: 0.1.4 diff --git a/charts/hapi-fhir-jpaserver/templates/deployment.yaml b/charts/hapi-fhir-jpaserver/templates/deployment.yaml index bd87ff30..3958b2bf 100644 --- a/charts/hapi-fhir-jpaserver/templates/deployment.yaml +++ b/charts/hapi-fhir-jpaserver/templates/deployment.yaml @@ -53,7 +53,7 @@ spec: protocol: TCP readinessProbe: httpGet: - path: /fhir/metadata + path: /fhir/Patient?_count=1 port: http {{- with .Values.readinessProbe }} initialDelaySeconds: {{ .initialDelaySeconds }} @@ -64,7 +64,7 @@ spec: {{- end }} startupProbe: httpGet: - path: /fhir/metadata + path: /fhir/Patient?_count=1 port: http {{- with .Values.startupProbe }} initialDelaySeconds: {{ .initialDelaySeconds }} diff --git a/charts/hapi-fhir-jpaserver/templates/tests/test-connection.yaml b/charts/hapi-fhir-jpaserver/templates/tests/test-connection.yaml index f06be1b6..753f7ba4 100644 --- a/charts/hapi-fhir-jpaserver/templates/tests/test-connection.yaml +++ b/charts/hapi-fhir-jpaserver/templates/tests/test-connection.yaml @@ -11,8 +11,8 @@ spec: containers: - name: wget image: busybox:1 - command: ['wget'] - args: ['{{ include "hapi-fhir-jpaserver.fullname" . }}:{{ .Values.service.port }}/fhir/metadata'] + command: ['wget', '-O', '-'] + args: ['http://{{ include "hapi-fhir-jpaserver.fullname" . }}:{{ .Values.service.port }}/fhir/Patient?_count=1'] securityContext: readOnlyRootFilesystem: true runAsUser: 22222 From 4646ee00e28df555b0cfee84ee4f0856b6d87daf Mon Sep 17 00:00:00 2001 From: chgl Date: Tue, 9 Feb 2021 19:39:12 +0100 Subject: [PATCH 3/5] ci: refactored workflows --- .github/workflows/ci.yaml | 61 ++++++++++++++----------------- .github/workflows/pre-commit.yaml | 14 ------- 2 files changed, 28 insertions(+), 47 deletions(-) delete mode 100644 .github/workflows/pre-commit.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index daf5378d..8bb9c774 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -5,38 +5,16 @@ on: branches: [master] jobs: - ct-lint: + pre-commit: runs-on: ubuntu-20.04 steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Helm - uses: azure/setup-helm@v1 - with: - version: v3.4.0 - + - uses: actions/checkout@v2 - uses: actions/setup-python@v2 - with: - python-version: 3.7 + - uses: pre-commit/action@v2.0.0 - - name: Set up chart-testing - uses: helm/chart-testing-action@v2.0.1 - - - name: Run chart-testing (list-changed) - id: list-changed - run: | - changed=$(ct list-changed) - if [[ -n "$changed" ]]; then - echo "::set-output name=changed::true" - fi - - - name: Run chart-testing (lint) - run: ct lint --config .github/ct/ct.yaml - - power-lint: + lint: + needs: + - pre-commit runs-on: ubuntu-20.04 container: quay.io/chgl/kube-powertools:latest steps: @@ -50,20 +28,37 @@ jobs: run: find charts/ ! -path charts/ -maxdepth 1 -type d -exec helm dependency update {} \; - name: Run YAML lint run: yamllint . + - name: Run chart-testing (lint) + run: ct lint --config .github/ct/ct.yaml - name: Run Powerlint run: bash scripts/chart-powerlint.sh - test-in-cluster: + test: runs-on: ubuntu-20.04 needs: - ct-lint - power-lint steps: + - name: Set up Helm + uses: azure/setup-helm@v1 + with: + version: v3.5.2 + + - uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed) + if [[ -n "$changed" ]]; then + echo "::set-output name=changed::true" + fi + - name: Create k8s Kind Cluster uses: helm/kind-action@v1.1.0 + if: steps.list-changed.outputs.changed == 'true' - name: Run chart-testing (install) - uses: helm/chart-testing-action@v2.0.1 - with: - config: .github/ct/install.yaml - command: install + run: ct install --config .github/ct/install.yaml diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml deleted file mode 100644 index 5519ff33..00000000 --- a/.github/workflows/pre-commit.yaml +++ /dev/null @@ -1,14 +0,0 @@ -name: pre-commit - -on: - pull_request: - push: - branches: [master] - -jobs: - pre-commit: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - uses: pre-commit/action@v2.0.0 From 2622487f0d99d66733bae3a4b08ddfb30810999c Mon Sep 17 00:00:00 2001 From: chgl Date: Tue, 9 Feb 2021 19:40:02 +0100 Subject: [PATCH 4/5] ci: fixed lint job name --- .github/workflows/ci.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8bb9c774..7a9bf7f2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -36,8 +36,7 @@ jobs: test: runs-on: ubuntu-20.04 needs: - - ct-lint - - power-lint + - lint steps: - name: Set up Helm uses: azure/setup-helm@v1 From a483860592f00137a24719f785141fa4c27969b3 Mon Sep 17 00:00:00 2001 From: chgl Date: Tue, 9 Feb 2021 19:50:55 +0100 Subject: [PATCH 5/5] ci: fixed ct setup --- .github/workflows/ci.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7a9bf7f2..ab13830d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -38,6 +38,11 @@ jobs: needs: - lint steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Helm uses: azure/setup-helm@v1 with: @@ -47,6 +52,9 @@ jobs: with: python-version: 3.7 + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.0.1 + - name: Run chart-testing (list-changed) id: list-changed run: |