Skip to content

Commit

Permalink
added helm lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaser committed Feb 5, 2024
1 parent aac7b65 commit 1a6c121
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 17 deletions.
1 change: 1 addition & 0 deletions .earthlyignore
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ tests/output
*.rej
.direnv
junit.xml
junit-go.xml
ansible-lint.xml
output
37 changes: 37 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,37 @@ ARG --global REGISTRY=ghcr.io/vexxhost/atmosphere
lint:
BUILD +lint.ansible-lint
BUILD +lint.markdownlint
BUILD +lint.image-manifest

lint.helm:
FROM alpine:3
RUN mkdir -p /output
COPY --dir charts/ /src
FOR CHART IN $(ls /src)
FOR VERSION IN $(seq 22 28)
COPY (+lint.helm.chart/junit.xml --CHART ${CHART} --VERSION "1.${VERSION}.0") /output/junit-helm-${CHART}-1-${VERSION}-0.xml
END
END
SAVE ARTIFACT /output AS LOCAL output

lint.helm.chart:
FROM alpine:3
RUN apk add --no-cache git helm python3
RUN helm plugin install https://github.com/melmorabity/helm-kubeconform
RUN mkdir -p /cache /output
ARG --required CHART
COPY --dir charts/${CHART} /src
ARG --required VERSION
RUN \
--mount=type=cache,target=/cache \
helm kubeconform /src \
--cache /cache \
--schema-location default \
--schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \
--ignore-missing-schemas \
--kube-version ${VERSION} \
--output junit 2> /output/junit.xml
SAVE ARTIFACT /output/junit.xml

lint.markdownlint:
FROM davidanson/markdownlint-cli2
Expand Down Expand Up @@ -50,6 +81,12 @@ unit.go:
SAVE ARTIFACT /src/junit-go.xml AS LOCAL junit-go.xml
END

build.collection:
FROM registry.gitlab.com/pipeline-components/ansible-lint:latest
COPY . /src
RUN ansible-galaxy collection build /src
SAVE ARTIFACT /code/*.tar.gz AS LOCAL dist/

go.build:
FROM golang:1.21
WORKDIR /src
Expand Down
40 changes: 30 additions & 10 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ pipeline {
REGISTRY = "${env.BRANCH_NAME == 'main' ? PROD_REGISTRY : TEST_REGISTRY}"

EARTHLY_CI = 'true'
EARTHLY_OUTPUT = 'true'
EARTHLY_BUILD_ARGS = "REGISTRY=${REGISTRY}"
}

stages {
// template all helm charts during lint stage to catch early failure
stage('lint') {
environment {
EARTHLY_OUTPUT = 'true'
}

parallel {
stage('ansible-lint') {
agent {
Expand All @@ -40,6 +37,22 @@ pipeline {
}
}

stage('helm') {
agent {
label 'earthly'
}

steps {
sh 'earthly +lint.helm'
}

post {
always {
junit testResults: 'output/junit-helm-*.xml', allowEmptyResults: true
}
}
}

stage('markdownlint') {
agent {
label 'earthly'
Expand Down Expand Up @@ -94,7 +107,16 @@ pipeline {

stage('build') {
parallel {
// build-collection
stage('collection') {
agent {
label 'earthly'
}

steps {
sh 'earthly +build.collection'
archiveArtifacts artifacts: 'dist/**'
}
}

stage('images') {
agent {
Expand All @@ -103,6 +125,8 @@ pipeline {

steps {
script {
env.EARTHLY_OUTPUT = 'false'

if (env.BRANCH_NAME == 'main') {
docker.withRegistry('https://ghcr.io', 'github-packages-token') {
sh 'earthly --push +images'
Expand All @@ -112,11 +136,7 @@ pipeline {
}
}

script {
env.EARTHLY_OUTPUT = 'true'
sh 'earthly +pin-images'
}

sh 'earthly +pin-images'
sh 'earthly +scan-images'
stash name: 'src-with-pinned-images', includes: '**'
}
Expand Down
4 changes: 0 additions & 4 deletions ansible-lint.xml

This file was deleted.

6 changes: 3 additions & 3 deletions molecule/aio/group_vars/all/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ceph_conf_overrides:
- section: global
option: mon allow pool size one
value: true
- section: global
option: osd crush chooseleaf type
value: 0
- section: mon
option: auth allow insecure global id reclaim
value: false
- section: mon
option: allow pool size one
value: true

kubernetes_keepalived_interface: br-mgmt

Expand Down

0 comments on commit 1a6c121

Please sign in to comment.