Skip to content

Commit

Permalink
Merge pull request #30 from mosip/0.9.0
Browse files Browse the repository at this point in the history
0.9.0
  • Loading branch information
ckm007 authored Jan 8, 2023
2 parents c9ba4fc + 660e49a commit f8b7312
Show file tree
Hide file tree
Showing 109 changed files with 34,392 additions and 106 deletions.
38 changes: 38 additions & 0 deletions .github/chart-schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# reference: https://github.com/helm/chart-testing/blob/main/etc/chart_schema.yaml
name: str()
home: str(required=False)
version: str()
apiVersion: str()
appVersion: any(str(), num(), required=False)
description: str(required=False)
keywords: list(str(), required=False)
sources: list(str(), required=False)
maintainers: list(include('maintainer'), required=False)
dependencies: list(include('dependency'), required=False)
icon: str(required=False)
engine: str(required=False)
condition: str(required=False)
tags: str(required=False)
deprecated: bool(required=False)
kubeVersion: str(required=False)
annotations: map(str(), str(), required=False)
type: str(required=False)
---
maintainer:
name: str()
email: str(required=False)
url: str(required=False)
---
dependency:
name: str()
version: str()
repository: str(required=False)
condition: str(required=False)
tags: list(str(), required=False)
enabled: bool(required=False)
import-values: any(list(str()), list(include('import-value')), required=False)
alias: str(required=False)
---
import-value:
child: str()
parent: str()
9 changes: 9 additions & 0 deletions .github/chart-testing-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# See https://github.com/helm/chart-testing#configuration
helm-extra-args: --timeout 600s
check-version-increment: true
debug: true
lint-conf: .github/lintconf.yaml
chart-yaml-schema: .github/chart-schema.yaml
chart-repos:
- bitnami=https://charts.bitnami.com/bitnami
- confluentinc=https://confluentinc.github.io/cp-helm-charts/
40 changes: 40 additions & 0 deletions .github/health-check-schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: str()
kind: str(matches='Deployment|StatefulSet')
metadata: any()
spec:
template:
spec:
containers: list(include('probes'))
---
probes:
startupProbe: any( include('httpget'), include('exec_command'), include('tcp_socket') )
livenessProbe: any( include('httpget'), include('exec_command'), include('tcp_socket') )
readinessProbe: any( include('httpget'), include('exec_command'), include('tcp_socket') )
---
httpget:
httpGet:
path: str(required=False)
port: any( str(), int())
initialDelaySeconds: int(required=False)
periodSeconds: int()
successThreshold: int(required=False)
timeoutSeconds: int()
failureThreshold: int()
---
exec_command:
exec:
command: list(str())
initialDelaySeconds: int(required=False)
periodSeconds: int()
successThreshold: int(required=False)
timeoutSeconds: int()
failureThreshold: int()
---
tcp_socket:
tcpSocket:
port: any( str(), int())
initialDelaySeconds: int(required=False)
periodSeconds: int()
successThreshold: int(required=False)
timeoutSeconds: int()
failureThreshold: int()
43 changes: 43 additions & 0 deletions .github/lintconf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# reference: https://raw.githubusercontent.com/helm/chart-testing/main/etc/lintconf.yaml
---
rules:
braces:
min-spaces-inside: 0
max-spaces-inside: 0
min-spaces-inside-empty: -1
max-spaces-inside-empty: -1
brackets:
min-spaces-inside: 0
max-spaces-inside: 0
min-spaces-inside-empty: -1
max-spaces-inside-empty: -1
colons:
max-spaces-before: 0
max-spaces-after: 1
commas:
max-spaces-before: 0
min-spaces-after: 1
max-spaces-after: 1
comments:
require-starting-space: true
min-spaces-from-content: 2
document-end: disable
document-start: disable # No --- to start a file
empty-lines:
max: 2
max-start: 0
max-end: 0
hyphens:
max-spaces-after: 1
indentation:
spaces: consistent
indent-sequences: whatever # - list indentation will handle both indentation and without
check-multi-line-strings: false
key-duplicates: enable
line-length: disable # Lines can be any length
new-line-at-end-of-file: enable
new-lines:
type: unix
trailing-spaces: enable
truthy:
level: warning
135 changes: 135 additions & 0 deletions .github/workflows/helm-lint-manual.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Run Lint and Test Charts manually

on:
workflow_dispatch:
inputs:
target_repo:
description: 'target repo'
required: true
default: 'https://github.com/mosip/mosip-helm'
type: string
target_branch:
description: 'target branch'
required: true
default: 'gh-pages'
type: string

jobs:
lint-chart:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
# ct needs history to compare
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.10.0

- name: Install python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
check-latest: true

- name: Install yamllint via pip3
run: |
pip3 install yamllint
- name: Set environment variables
run: |
# echo "TARGET BRANCH : ${{ github.event.inputs.target_branch }}"
echo "TARGET_BRANCH=$(echo ${{ github.event.inputs.target_branch }} )" >> $GITHUB_ENV
echo "COMMIT_ID=${GITHUB_SHA}" >> $GITHUB_ENV
echo "TARGET_REPO=$( echo ${{ github.event.inputs.target_repo }} )" >> $GITHUB_ENV
- name: Add Target repo to git remotes
run: |
git remote add target_repo $TARGET_REPO
git fetch target_repo
- name: Set up chart-testing
uses: helm/[email protected]

- name: Run chart-testing (lint)
run: |
ls -d charts/* > list.txt;
ct lint --config=.github/chart-testing-config.yaml --chart-dirs=charts --remote=target_repo --target-branch=$TARGET_BRANCH;
- name: Create yaml files for helm charts
run: |
while read -r chart; do
echo -e "\nCHART: $chart\n";
yaml_file='./chart-template.yaml'
chart_name=$( echo $chart | awk -F / '{print $2}' );
mkdir "$chart_name-yaml";
helm template $chart > $yaml_file
last_line=$( cat -n $yaml_file| tail -n 1 | awk '{print $1}' )
line_nos="$( awk '/^---/{print NR}' $yaml_file ) $last_line"
start_of_file=0
for line in $line_nos; do
if [[ $line -eq 1 ]]; then
start_of_file=$line;
continue;
fi
head_line=$(( line-1 ));
tail_line=$(( line-start_of_file ));
if [[ $line -eq $last_line ]]; then
head_line=$line;
tail_line=$(( line-start_of_file+1 ));
fi
start_of_file=$line;
# echo "HEAD LINE: $head_line, TAIL LINE: $tail_line";
yaml_type=$( head -n +$head_line $yaml_file | tail -n $tail_line | grep -c -E "kind\:\ Deployment|kind\:\ StatefulSet" || true ); # used "true" to return exit code as 0
# echo "YAML TYPE: $yaml_type";
if [[ "$yaml_type" -eq 0 ]]; then
# echo "if YAML TYPE: $yaml_type";
continue;
fi
filename=$( head -n +$head_line $yaml_file | tail -n $tail_line | awk -F '/' '/# Source/{print $3}' );
echo "$filename";
head -n +$head_line $yaml_file | tail -n $tail_line > "$chart_name-yaml/$filename";
done
done < ./list.txt
- name: Run Health Check Test
run: |
while read -r chart; do
echo -e "\n\nCHART: $chart\n";
chart_name=$( echo $chart | awk -F / '{print $2}' );
list=$( ls $chart_name-yaml || true );
echo -e "YAML LIST :";
echo -e "$list\n"
for yaml in $list; do
echo -e "YAML : $yaml";
yamale -s .github/health-check-schema.yaml "$chart_name-yaml/$yaml" --no-strict
done
done < ./list.txt
# Commented below tasks as it cannot test MOSIP helm/charts deployment due to dependencies issues
#- name: Create kind v1.21.1 cluster
# uses: helm/[email protected]
# with:
# node_image: kindest/node:v1.21.1
#
#- name: Run chart-testing (install)
# run: |
# while read -r chart; do
# echo -e "\nCHART: $chart\n";
# ct install --config=.github/chart-testing-config.yaml --charts=$chart --remote=target_repo --target-branch=$TARGET_BRANCH;
# done < ./list.txt
Loading

0 comments on commit f8b7312

Please sign in to comment.