Skip to content

Commit

Permalink
Update to latest ec-helm-charts and improve helm validation (#8)
Browse files Browse the repository at this point in the history
* improve helm chart validation in CI

* update helm charts to latest

* Swap helm commands

* Make strict chart linting

* Add fixes to gitlab version

---------

Co-authored-by: Marcell Nagy <[email protected]>
  • Loading branch information
gilesknap and marcelldls authored Nov 14, 2024
1 parent 95f5e75 commit 91eaa75
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 25 deletions.
4 changes: 2 additions & 2 deletions template/services/.ioc_template/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ type: application

dependencies:
- name: ioc-instance
version: 4.0.0
repository: "oci://ghcr.io/epics-containers"
version: 4.1.2
repository: "oci://ghcr.io/epics-containers"
2 changes: 1 addition & 1 deletion template/services/epics-opis/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ type: application

dependencies:
- name: epics-opis
version: 4.0.0
version: 4.1.2
repository: "oci://ghcr.io/epics-containers"
4 changes: 2 additions & 2 deletions template/services/epics-pvcs/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ type: application

dependencies:
- name: epics-pvcs
version: 4.0.0
repository: "oci://ghcr.io/epics-containers"
version: 4.1.2
repository: "oci://ghcr.io/epics-containers"
4 changes: 2 additions & 2 deletions template/services/{{ioc_group}}-ea-test-01/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ type: application

dependencies:
- name: ioc-instance
version: 4.0.0
repository: "oci://ghcr.io/epics-containers"
version: 4.1.2
repository: "oci://ghcr.io/epics-containers"
2 changes: 1 addition & 1 deletion template/services/{{ioc_group}}-ea-test-01/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://github.com/epics-containers/ec-helm-charts/releases/download/3.4.4/ioc-instance.schema.json#/$defs/service
ioc-instance:
image: ghcr.io/epics-containers/ioc-template-example-runtime:3.5.1
image: ghcr.io/epics-containers/ioc-template-example-runtime:4.0.0

# NOTE: the following are suggestions to help with debugging IOCs
# 1. replace the runtime container with the developer version
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
daq-nexus
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,43 @@
# other future services that don't use ibek, we will need to add a standard
# entrypoint for validating the config folder mounted at /config.

ROOT=$(realpath $(dirname ${0})/../..)
HERE=$(realpath $(dirname ${0}))
ROOT=$(realpath ${HERE}/../..)
set -xe
rm -rf ${ROOT}/.ci_work/
mkdir -p ${ROOT}/.ci_work

# use docker if available else use podman
if ! docker version &>/dev/null; then docker=podman; else docker=docker; fi

# copy the services to a temporary location to avoid dirtying the repo
cp -r ${ROOT}/services/* ${ROOT}/.ci_work/

for service in ${ROOT}/services/*/ # */ to skip files
do

### Lint each service chart and validate if schema given ###
service_name=$(basename $service)
cp -r $service ${ROOT}/.ci_work/$service_name

# skip services appearing in ci_skip_checks
checks=${HERE}/ci_skip_checks
if [[ -f ${checks} ]] && grep -q ${service_name} ${checks}; then
echo "Skipping ${service_name}"
continue
fi

schema=$(cat ${service}/values.yaml | sed -rn 's/^# yaml-language-server: \$schema=(.*)/\1/p')
if [ -n "${schema}" ]; then
echo "{\"\$ref\": \"$schema\"}" > ${ROOT}/.ci_work/$service_name/values.schema.json
fi

$docker run --rm --entrypoint bash \
-v ${ROOT}/.ci_work/$service_name:/services/$service_name \
alpine/helm:3.14.3 \
-c "helm dependency update /services/$service_name"
$docker run --rm --entrypoint bash \
-v ${ROOT}/.ci_work/$service_name:/services/$service_name \
-v ${ROOT}/services/values.yaml:/services/values.yaml \
-v ${ROOT}/.ci_work:/services \
alpine/helm:3.14.3 \
-c "helm lint /services/$service_name --values /services/values.yaml"
-c "
helm dependency update /services/$service_name &&
helm lint /services/$service_name --strict --values /services/values.yaml &&
rm -rf /services/$service_name/charts
"

### Valiate each ioc config ###
# Skip if subfolder has no config to validate
Expand Down Expand Up @@ -64,4 +74,4 @@ do

done

rm -r ${ROOT}/.ci_work
rm -r ${ROOT}/.ci_work
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,37 @@
# other future services that don't use ibek, we will need to add a standard
# entrypoint for validating the config folder mounted at /config.

ROOT=$(realpath $(dirname ${0})/..)
HERE=$(realpath $(dirname ${0}))
ROOT=$(realpath ${HERE}/../..)
ID="${CI_COMMIT_SHORT_SHA:-"local"}"
POD="bl01c-ci-${ID}-$(date +%s)"
POD="bl01c-ci-${ID}-$(date +%s)" # Fix name
set -xe
status=0
rm -rf ${ROOT}/.ci_work/
mkdir -p ${ROOT}/.ci_work

# use docker if available else use podman
if ! docker version &>/dev/null; then docker=podman; else docker=docker; fi
# copy the services to a temporary location to avoid dirtying the repo
cp -r ${ROOT}/services/* ${ROOT}/.ci_work/

for service in ${ROOT}/services/*/ # */ to skip files
do

### Lint each service chart and validate if schema given ###
service_name=$(basename $service)
cp -r $service ${ROOT}/.ci_work/$service_name

# skip services appearing in ci_skip_checks
checks=${HERE}/ci_skip_checks
if [[ -f ${checks} ]] && grep -q ${service_name} ${checks}; then
echo "Skipping ${service_name}"
continue
fi

schema=$(cat ${service}/values.yaml | sed -rn 's/^# yaml-language-server: \$schema=(.*)/\1/p')
if [ -n "${schema}" ]; then
echo "{\"\$ref\": \"$schema\"}" > ${ROOT}/.ci_work/$service_name/values.schema.json
fi
helm dependency update ${ROOT}/.ci_work/$service_name
helm lint ${ROOT}/.ci_work/$service_name --values ${ROOT}/services/values.yaml
helm lint ${ROOT}/.ci_work/$service_name --strict --values ${ROOT}/services/values.yaml

### Valiate each ioc config ###
# Skip if subfolder has no config to validate
Expand Down

0 comments on commit 91eaa75

Please sign in to comment.