Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add yaml-lint GitHub Workflow #368

Merged
merged 4 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-push.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Publish container images in quay.io

# yamllint disable-line rule:truthy
on:
push:
branches:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
skip: .git,go.mod,go.sum,vendor
# kubebuilder latest release has a label with name kuberentes
# TODO: remove this in next kubebuilder update as this is fixed
# in kubebuilder master
# in kubebuilder master
# https://github.com/kubernetes-sigs/kubebuilder/pull/2964
ignore_words_list: kuberentes
check_filenames: true
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: golangci-lint
# yamllint disable-line rule:truthy
on:
push:
branches:
Expand Down
20 changes: 17 additions & 3 deletions .github/workflows/kind-deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Test deploying controller

# yamllint disable-line rule:truthy
on:
pull_request:
branches:
Expand Down Expand Up @@ -33,14 +34,27 @@ jobs:
tags: quay.io/csiaddons/k8s-controller:${{ env.TAG }}

- name: push image to kind cluster
run: kind load docker-image quay.io/csiaddons/k8s-controller:${{ env.TAG }} --name=chart-testing
run: >
kind
load docker-image quay.io/csiaddons/k8s-controller:${{ env.TAG }}
--name=chart-testing

- name: Deploy the controller and CRDs
run: make deploy TAG=${{ env.TAG }}

- name: Wait for running controller pod
run: kubectl -n csi-addons-system wait pods -l app.kubernetes.io/name=csi-addons --for=condition=Ready=True
run: >
kubectl
-n csi-addons-system
wait pods
-l app.kubernetes.io/name=csi-addons
--for=condition=Ready=True

- name: Log the status of the failed controller pod
if: ${{ failure() }}
run: kubectl -n csi-addons-system describe pods -l app.kubernetes.io/name=csi-addons ; false
run: >
kubectl
-n csi-addons-system
describe pods
-l app.kubernetes.io/name=csi-addons
; false
21 changes: 17 additions & 4 deletions .github/workflows/tag-release.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
---
name: Build and release versioned container images

# yamllint disable-line rule:truthy
on:
create

jobs:
tag_bundle:
name: Build and release the bundle container-image
if: github.repository == 'csi-addons/kubernetes-csi-addons' && github.ref_type == 'tag'
if: >
github.repository == 'csi-addons/kubernetes-csi-addons'
&&
github.ref_type == 'tag'
runs-on: ubuntu-latest
steps:
- name: Check out the repo
Expand Down Expand Up @@ -41,7 +45,10 @@ jobs:

tag_controller:
name: Build and release the controller container-image
if: github.repository == 'csi-addons/kubernetes-csi-addons' && github.ref_type == 'tag'
if: >
github.repository == 'csi-addons/kubernetes-csi-addons'
&&
github.ref_type == 'tag'
runs-on: ubuntu-latest
steps:
- name: Check out the repo
Expand Down Expand Up @@ -71,7 +78,10 @@ jobs:

tag_sidecar:
name: Build and release the sidecar container-image
if: github.repository == 'csi-addons/kubernetes-csi-addons' && github.ref_type == 'tag'
if: >
github.repository == 'csi-addons/kubernetes-csi-addons'
&&
github.ref_type == 'tag'
runs-on: ubuntu-latest
steps:
- name: Check out the repo
Expand Down Expand Up @@ -101,7 +111,10 @@ jobs:

publish_release:
name: Publish a release based on the tag
if: github.repository == 'csi-addons/kubernetes-csi-addons' && github.ref_type == 'tag'
if: >
github.repository == 'csi-addons/kubernetes-csi-addons'
&&
github.ref_type == 'tag'
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-build.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Test building container images

# yamllint disable-line rule:truthy
on:
pull_request:
branches:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-golang.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Run Golang tests

# yamllint disable-line rule:truthy
on:
pull_request:
branches:
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Yaml Lint
# yamllint disable-line rule:truthy
on:
push:
pull_request:

jobs:
yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: yaml-lint
uses: ibiqlik/action-yamllint@v3
with:
config_file: .yamllint.yaml
23 changes: 23 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
extends: default

ignore:
- .git/
# bundle/ contains generated contents
- bundle/
# vendor/ are maintained elsewhere
- vendor/

rules:
document-start:
ignore:
- config/manager/
- deploy/
indentation:
ignore:
- config/
- deploy/
line-length:
ignore:
- config/
- deploy/
11 changes: 7 additions & 4 deletions config/certmanager/certificate.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# The following manifests contain a self-signed issuer CR and a certificate CR.
# More document can be found at https://docs.cert-manager.io
# WARNING: Targets CertManager v1.0. Check https://cert-manager.io/docs/installation/upgrading/ for breaking changes.
Expand All @@ -12,14 +13,16 @@ spec:
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
# this name should match the one appeared in kustomizeconfig.yaml
name: serving-cert
namespace: system
spec:
# $(SERVICE_NAME) and $(SERVICE_NAMESPACE) will be substituted by kustomize
dnsNames:
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local
issuerRef:
kind: Issuer
name: selfsigned-issuer
secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize
# this secret will not be prefixed, since it's not managed by kustomize
secretName: webhook-server-cert
5 changes: 3 additions & 2 deletions config/certmanager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# Adds namespace to all resources.
namespace: csi-addons-system

Expand All @@ -9,7 +10,7 @@ namespace: csi-addons-system
namePrefix: csi-addons-

resources:
- certificate.yaml
- certificate.yaml

configurations:
- kustomizeconfig.yaml
- kustomizeconfig.yaml
25 changes: 13 additions & 12 deletions config/certmanager/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# This configuration is for teaching kustomize how to update name ref and var substitution
---
# This configuration is for teaching kustomize how to update name ref and var substitution
nameReference:
- kind: Issuer
group: cert-manager.io
fieldSpecs:
- kind: Certificate
- kind: Issuer
group: cert-manager.io
path: spec/issuerRef/name
fieldSpecs:
- kind: Certificate
group: cert-manager.io
path: spec/issuerRef/name

varReference:
- kind: Certificate
group: cert-manager.io
path: spec/commonName
- kind: Certificate
group: cert-manager.io
path: spec/dnsNames
- kind: Certificate
group: cert-manager.io
path: spec/commonName
- kind: Certificate
group: cert-manager.io
path: spec/dnsNames
42 changes: 23 additions & 19 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
---
# yamllint disable rule:comments rule:comments-indentation
#
# This kustomization.yaml is not intended to be run by itself,
# since it depends on service name and namespace that are out of this kustomize package.
# It should be run by config/default
resources:
- bases/csiaddons.openshift.io_csiaddonsnodes.yaml
- bases/csiaddons.openshift.io_reclaimspacecronjobs.yaml
- bases/csiaddons.openshift.io_reclaimspacejobs.yaml
- bases/csiaddons.openshift.io_networkfences.yaml
- bases/replication.storage.openshift.io_volumereplications.yaml
- bases/replication.storage.openshift.io_volumereplicationclasses.yaml
- bases/csiaddons.openshift.io_csiaddonsnodes.yaml
- bases/csiaddons.openshift.io_reclaimspacecronjobs.yaml
- bases/csiaddons.openshift.io_reclaimspacejobs.yaml
- bases/csiaddons.openshift.io_networkfences.yaml
- bases/replication.storage.openshift.io_volumereplications.yaml
- bases/replication.storage.openshift.io_volumereplicationclasses.yaml
# yamllint disable-line rule:comments
#+kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
#- patches/webhook_in_csiaddonsnodes.yaml
#- patches/webhook_in_reclaimspacejobs.yaml
#- patches/webhook_in_volumereplications.yaml
#- patches/webhook_in_volumereplicationclasses.yaml
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
#- patches/webhook_in_csiaddonsnodes.yaml
#- patches/webhook_in_reclaimspacejobs.yaml
#- patches/webhook_in_volumereplications.yaml
#- patches/webhook_in_volumereplicationclasses.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
#- patches/cainjection_in_csiaddonsnodes.yaml
#- patches/cainjection_in_reclaimspacejobs.yaml
#- patches/cainjection_in_volumereplications.yaml
#- patches/cainjection_in_volumereplicationclasses.yaml
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
#- patches/cainjection_in_csiaddonsnodes.yaml
#- patches/cainjection_in_reclaimspacejobs.yaml
#- patches/cainjection_in_volumereplications.yaml
#- patches/cainjection_in_volumereplicationclasses.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
configurations:
- kustomizeconfig.yaml
- kustomizeconfig.yaml
25 changes: 13 additions & 12 deletions config/crd/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
---
# This file is for teaching kustomize how to substitute name and namespace reference in CRD
nameReference:
- kind: Service
version: v1
fieldSpecs:
- kind: CustomResourceDefinition
- kind: Service
version: v1
group: apiextensions.k8s.io
path: spec/conversion/webhook/clientConfig/service/name
fieldSpecs:
- kind: CustomResourceDefinition
version: v1
group: apiextensions.k8s.io
path: spec/conversion/webhook/clientConfig/service/name

namespace:
- kind: CustomResourceDefinition
version: v1
group: apiextensions.k8s.io
path: spec/conversion/webhook/clientConfig/service/namespace
create: false
- kind: CustomResourceDefinition
version: v1
group: apiextensions.k8s.io
path: spec/conversion/webhook/clientConfig/service/namespace
create: false

varReference:
- path: metadata/annotations
- path: metadata/annotations
1 change: 1 addition & 0 deletions config/crd/patches/cainjection_in_csiaddonsnodes.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# The following patch adds a directive for certmanager to inject CA into the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
1 change: 1 addition & 0 deletions config/crd/patches/cainjection_in_networkfences.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# The following patch adds a directive for certmanager to inject CA into the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
1 change: 1 addition & 0 deletions config/crd/patches/cainjection_in_reclaimspacejobs.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# The following patch adds a directive for certmanager to inject CA into the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# The following patch adds a directive for certmanager to inject CA into the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
1 change: 1 addition & 0 deletions config/crd/patches/cainjection_in_volumereplications.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# The following patch adds a directive for certmanager to inject CA into the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
3 changes: 2 additions & 1 deletion config/crd/patches/webhook_in_csiaddonsnodes.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# The following patch enables a conversion webhook for the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand All @@ -13,4 +14,4 @@ spec:
name: webhook-service
path: /convert
conversionReviewVersions:
- v1
- v1
3 changes: 2 additions & 1 deletion config/crd/patches/webhook_in_networkfences.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# The following patch enables a conversion webhook for the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand All @@ -13,4 +14,4 @@ spec:
name: webhook-service
path: /convert
conversionReviewVersions:
- v1
- v1
3 changes: 2 additions & 1 deletion config/crd/patches/webhook_in_reclaimspacejobs.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# The following patch enables a conversion webhook for the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand All @@ -13,4 +14,4 @@ spec:
name: webhook-service
path: /convert
conversionReviewVersions:
- v1
- v1
Loading