Skip to content

Commit

Permalink
Merge pull request #31 from qonto/yaml-lint
Browse files Browse the repository at this point in the history
Add Yaml linter
  • Loading branch information
vmercierfr authored Nov 2, 2023
2 parents 4b8178f + 8442150 commit c7f998a
Show file tree
Hide file tree
Showing 31 changed files with 151 additions and 99 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
name: build
run-name: building and publishing new release
on:
on: # yamllint disable-line rule:truthy
push:
# run only against tags
tags:
- "*"
permissions:
contents: write # allows the action to create a Github release
id-token: write # This is required for requesting the AWS JWT
contents: write # allows the action to create a Github release
id-token: write # This is required for requesting the AWS JWT

jobs:
build-publish:
Expand All @@ -21,7 +22,7 @@ jobs:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1 # ECR Public can only be logged into from the us-east-1 region
aws-region: us-east-1 # ECR Public can only be logged into from the us-east-1 region
role-to-assume: arn:aws:iam::202662887508:role/ecr-prometheus-rds-exporter
role-session-name: githubActions

Expand Down Expand Up @@ -52,7 +53,7 @@ jobs:
- name: Configure AWS credentials for helm chart
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1 # ECR Public can only be logged into from the us-east-1 region
aws-region: us-east-1 # ECR Public can only be logged into from the us-east-1 region
role-to-assume: arn:aws:iam::202662887508:role/ecr-prometheus-rds-exporter-chart
role-session-name: githubActions

Expand All @@ -62,7 +63,7 @@ jobs:
registry-type: public
mask-password: 'true'

- name: Downgrade Helm # 1.13.0 has bug that block push charts on OCI
- name: Downgrade Helm # 1.13.0 has bug that block push charts on OCI
run: |
curl -sSLo /tmp/helm.tar.gz "https://get.helm.sh/helm-v3.12.0-linux-amd64.tar.gz" && \
tar --strip-components=1 -C /tmp -xzvf /tmp/helm.tar.gz linux-amd64/helm && \
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: linter
on:
on: # yamllint disable-line rule:truthy
push:
branches:
- "*"
Expand Down Expand Up @@ -49,3 +50,12 @@ jobs:

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"

yamllint:
name: yamllint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Lint YAML files
run: yamllint . # YAML lint is already installed in ubuntu-latest
3 changes: 2 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: unittest
on:
on: # yamllint disable-line rule:truthy
push:
branches:
- "*"
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
run:
concurrency: 4
deadline: 2m
Expand Down
121 changes: 61 additions & 60 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
---
env:
- BUILD_INFO_PACKAGE_PATH=github.com/qonto/prometheus-rds-exporter/internal/infra/build
- DOCKER_REGISTRY=public.ecr.aws/qonto
Expand All @@ -8,11 +9,11 @@ builds:
- env:
- CGO_ENABLED=0
ldflags:
- '-s'
- '-w'
- '-X "{{ .Env.BUILD_INFO_PACKAGE_PATH }}.Version={{.Version}}"'
- '-X "{{ .Env.BUILD_INFO_PACKAGE_PATH }}.CommitSHA={{.Commit}}"'
- '-X "{{ .Env.BUILD_INFO_PACKAGE_PATH }}.Date={{.Date}}"'
- '-s'
- '-w'
- '-X "{{ .Env.BUILD_INFO_PACKAGE_PATH }}.Version={{.Version}}"'
- '-X "{{ .Env.BUILD_INFO_PACKAGE_PATH }}.CommitSHA={{.Commit}}"'
- '-X "{{ .Env.BUILD_INFO_PACKAGE_PATH }}.Date={{.Date}}"'
goos:
- linux
- darwin
Expand Down Expand Up @@ -58,8 +59,8 @@ archives:
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
- goos: windows
format: zip
files:
- src: configs/prometheus-rds-exporter/prometheus-rds-exporter.yaml
dst: prometheus-rds-exporter.yaml
Expand Down Expand Up @@ -105,61 +106,61 @@ changelog:
order: 9999

dockers:
- image_templates:
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Tag }}-amd64"
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}-amd64"
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}.{{ .Minor }}-amd64"
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:latest-amd64"
dockerfile: configs/goreleaser/Dockerfile
build_flag_templates:
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/qonto/prometheus-rds-exporter
- --label=org.opencontainers.image.source=https://github.com/qonto/prometheus-rds-exporter
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
- "--pull"
- "--platform=linux/amd64"
use: buildx
- image_templates:
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Tag }}-arm64"
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}-arm64"
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}.{{ .Minor }}-arm64"
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:latest-arm64"
dockerfile: configs/goreleaser/Dockerfile
build_flag_templates:
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/qonto/prometheus-rds-exporter
- --label=org.opencontainers.image.source=https://github.com/qonto/prometheus-rds-exporter
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
- "--pull"
- "--platform=linux/arm64"
use: buildx
goarch: arm64
- image_templates:
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Tag }}-amd64"
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}-amd64"
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}.{{ .Minor }}-amd64"
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:latest-amd64"
dockerfile: configs/goreleaser/Dockerfile
build_flag_templates:
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/qonto/prometheus-rds-exporter
- --label=org.opencontainers.image.source=https://github.com/qonto/prometheus-rds-exporter
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
- "--pull"
- "--platform=linux/amd64"
use: buildx
- image_templates:
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Tag }}-arm64"
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}-arm64"
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}.{{ .Minor }}-arm64"
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:latest-arm64"
dockerfile: configs/goreleaser/Dockerfile
build_flag_templates:
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/qonto/prometheus-rds-exporter
- --label=org.opencontainers.image.source=https://github.com/qonto/prometheus-rds-exporter
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
- "--pull"
- "--platform=linux/arm64"
use: buildx
goarch: arm64

docker_manifests:
- name_template: '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Tag }}'
image_templates:
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Tag }}-amd64'
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Tag }}-arm64'
- name_template: '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}'
image_templates:
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}-amd64'
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}-arm64'
- name_template: '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}.{{ .Minor }}'
image_templates:
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}.{{ .Minor }}-amd64'
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}.{{ .Minor }}-arm64'
- name_template: '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:latest'
image_templates:
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:latest-amd64'
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:latest-arm64'
- name_template: '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Tag }}'
image_templates:
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Tag }}-amd64'
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Tag }}-arm64'
- name_template: '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}'
image_templates:
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}-amd64'
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}-arm64'
- name_template: '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}.{{ .Minor }}'
image_templates:
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}.{{ .Minor }}-amd64'
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}.{{ .Minor }}-arm64'
- name_template: '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:latest'
image_templates:
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:latest-amd64'
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:latest-arm64'

release:
github:
Expand Down
1 change: 1 addition & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# https://github.com/DavidAnson/markdownlint

# MD013/line-length - Line length
Expand Down
9 changes: 7 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
Expand All @@ -16,8 +17,12 @@ repos:
- repo: https://github.com/Bahjat/pre-commit-golang
rev: v1.0.3
hooks:
- id: gofumpt # requires github.com/mvdan/gofumpt
- id: gofumpt # requires https://github.com/mvdan/gofumpt
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.37.0
hooks:
- id: markdownlint
- id: markdownlint # requires https://github.com/DavidAnson/markdownlint-cli2
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.32.0
hooks:
- id: yamllint # requires https://github.com/adrienverge/yamllint
12 changes: 12 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
extends: default

rules:
line-length:
max: 160
level: warning

ignore:
- dist/
- prometheus-rds-exporter.yaml
- configs/helm/templates/*.yaml # Helm templates are invalid due to Go template language
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ We use:

* [`markdownlint-cli2`](https://github.com/DavidAnson/markdownlint-cli2) for linting the Markdown documents.

* [`yamllint`](https://github.com/adrienverge/yamllint) for linting the YAML documents.

## Pull Request Checklist

* Branch from the `main` branch and, if needed, rebase to the current main branch before submitting your pull request. If it doesn't merge cleanly with main you may be asked to rebase your changes.
Expand Down
1 change: 1 addition & 0 deletions configs/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: v2
type: application

Expand Down
1 change: 1 addition & 0 deletions configs/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
1 change: 1 addition & 0 deletions configs/helm/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if .Values.ingress.enabled -}}
---
{{- $fullName := include "prometheus-rds-exporter.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
Expand Down
1 change: 1 addition & 0 deletions configs/helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: v1
kind: Service
metadata:
Expand Down
1 change: 1 addition & 0 deletions configs/helm/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if .Values.serviceAccount.create -}}
---
apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down
3 changes: 2 additions & 1 deletion configs/helm/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{- if .Values.serviceMonitor.enabled -}}
# CRD documentation available on https://github.com/prometheus-operator/prometheus-operator/blob/v0.68.0/Documentation/api.md#servicemonitor
---
# CRD documentation available on https://github.com/prometheus-operator/prometheus-operator/blob/v0.68.0/Documentation/api.md#servicemonitor
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
Expand Down
3 changes: 2 additions & 1 deletion configs/helm/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: deployment tests
templates:
- deployment.yaml
Expand Down
1 change: 1 addition & 0 deletions configs/helm/tests/serviceaccount_test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
---
suite: service account tests
templates:
- serviceaccount.yaml
Expand Down
1 change: 1 addition & 0 deletions configs/helm/tests/servicemonitor_test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
---
suite: service monitor tests
templates:
- servicemonitor.yaml
Expand Down
1 change: 1 addition & 0 deletions configs/helm/tests/values/with_additional_labels.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
additionalLabels:
label1: value1
label2: value2
1 change: 1 addition & 0 deletions configs/helm/tests/values/with_awsCredentialsSecret.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
---
awsCredentialsSecret: my_aws_credentials
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
---
priorityClassName: high-priority
1 change: 1 addition & 0 deletions configs/helm/tests/values/with_environment_variables.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
env:
variable1: value1
variable2: value2
1 change: 1 addition & 0 deletions configs/helm/tests/values/with_image_tag.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
image:
tag: "1.0"
1 change: 1 addition & 0 deletions configs/helm/tests/values/with_serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
serviceAccount:
annotations:
"eks.amazonaws.com/role-arn": "arn:aws:iam::012345678901:role/prometheus-rds-exporter"
1 change: 1 addition & 0 deletions configs/helm/tests/values/with_servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
serviceMonitor:
enabled: true
interval: 120s
Expand Down
Loading

0 comments on commit c7f998a

Please sign in to comment.