Skip to content

Commit

Permalink
chore: Integrate yamllint into the project (#747)
Browse files Browse the repository at this point in the history
The initial config does not change many defaults and mostly relies on
the upstream config. The only changes are to the sequence style,
quoting and allowed truthy values that accomodate for GHA.
  • Loading branch information
webknjaz authored Jan 9, 2025
1 parent 900829c commit 1c9823e
Show file tree
Hide file tree
Showing 12 changed files with 541 additions and 360 deletions.
240 changes: 142 additions & 98 deletions .github/.container-structure-test-config.yaml
Original file line number Diff line number Diff line change
@@ -1,101 +1,145 @@
schemaVersion: '2.0.0'
---

schemaVersion: 2.0.0

commandTests:
- name: "git"
command: "git"
args: ["--version"]
expectedOutput: ["^git version 2\\.[0-9]+\\.[0-9]+\\n$"]

- name: "pre-commit"
command: "pre-commit"
args: ["-V"]
expectedOutput: ["^pre-commit ([0-9]+\\.){2}[0-9]+\\n$"]

- name: "gcc"
command: "gcc"
args: ["--version"]
expectedOutput: ["^gcc \\(Alpine 12\\."]

- name: "checkov"
command: "checkov"
args: ["--version"]
expectedOutput: ["^([0-9]+\\.){2}[0-9]+\\n$"]

- name: "infracost"
command: "infracost"
args: ["--version"]
expectedOutput: ["^Infracost v([0-9]+\\.){2}[0-9]+"]

- name: "opentofu"
command: "tofu"
args: ["-version"]
expectedOutput: ["^OpenTofu v([0-9]+\\.){2}[0-9]+\\n"]

- name: "terraform"
command: "terraform"
args: ["-version"]
expectedOutput: ["^Terraform v([0-9]+\\.){2}[0-9]+\\n"]

- name: "terraform-docs"
command: "terraform-docs"
args: ["--version"]
expectedOutput: ["^terraform-docs version v([0-9]+\\.){2}[0-9]+ [a-z0-9]+"]

- name: "terragrunt"
command: "terragrunt"
args: ["--version"]
expectedOutput: ["^terragrunt version v([0-9]+\\.){2}[0-9]+\\n$"]

- name: "terrascan"
command: "terrascan"
args: [ "version" ]
expectedOutput: [ "^version: v([0-9]+\\.){2}[0-9]+\\n$" ]

- name: "tflint"
command: "tflint"
args: [ "--version" ]
expectedOutput: [ "TFLint version ([0-9]+\\.){2}[0-9]+\\n" ]

- name: "tfsec"
command: "tfsec"
args: [ "--version" ]
expectedOutput: [ "([0-9]+\\.){2}[0-9]+\\n$" ]

- name: "trivy"
command: "trivy"
args: [ "--version" ]
expectedOutput: [ "Version: ([0-9]+\\.){2}[0-9]+\\n" ]

- name: "tfupdate"
command: "tfupdate"
args: [ "--version" ]
expectedOutput: [ "([0-9]+\\.){2}[0-9]+\\n$" ]

- name: "hcledit"
command: "hcledit"
args: [ "version" ]
expectedOutput: [ "([0-9]+\\.){2}[0-9]+\\n$" ]

- name: "entrypoint.sh"
envVars:
- key: "USERID"
value: "1000:1000"
command: "/entrypoint.sh"
args: [ "-V" ]
expectedError: ["^ERROR: uid:gid 1000:1000 lacks permissions to //\\n$"]
exitCode: 1

- name: "su-exec"
command: "su-exec"
expectedOutput: ["^Usage: su-exec user-spec command \\[args\\]\\n$"]

- name: "ssh"
command: "ssh"
args: [ "-V" ]
expectedError: ["^OpenSSH_9\\.[0-9]+"]
- name: git
command: git
args:
- --version
expectedOutput:
- ^git version 2\.[0-9]+\.[0-9]+\n$

- name: pre-commit
command: pre-commit
args:
- -V
expectedOutput:
- ^pre-commit ([0-9]+\.){2}[0-9]+\n$

- name: gcc
command: gcc
args:
- --version
expectedOutput:
- ^gcc \(Alpine 12\.

- name: checkov
command: checkov
args:
- --version
expectedOutput:
- ^([0-9]+\.){2}[0-9]+\n$

- name: infracost
command: infracost
args:
- --version
expectedOutput:
- ^Infracost v([0-9]+\.){2}[0-9]+

- name: opentofu
command: tofu
args:
- --version
expectedOutput:
- ^OpenTofu v([0-9]+\.){2}[0-9]+\n

- name: terraform
command: terraform
args:
- --version
expectedOutput:
- ^Terraform v([0-9]+\.){2}[0-9]+\n

- name: terraform-docs
command: terraform-docs
args:
- --version
expectedOutput:
- ^terraform-docs version v([0-9]+\.){2}[0-9]+ [a-z0-9]+

- name: terragrunt
command: terragrunt
args:
- --version
expectedOutput:
- ^terragrunt version v([0-9]+\.){2}[0-9]+\n$

- name: terrascan
command: terrascan
args:
- version
expectedOutput:
- >-
^version: v([0-9]+\.){2}[0-9]+\n$
- name: tflint
command: tflint
args:
- --version
expectedOutput:
- TFLint version ([0-9]+\.){2}[0-9]+\n

- name: tfsec
command: tfsec
args:
- --version
expectedOutput:
- ([0-9]+\.){2}[0-9]+\n$

- name: trivy
command: trivy
args:
- --version
expectedOutput:
- >-
Version: ([0-9]+\.){2}[0-9]+\n
- name: tfupdate
command: tfupdate
args:
- --version
expectedOutput:
- ([0-9]+\.){2}[0-9]+\n$

- name: hcledit
command: hcledit
args:
- version
expectedOutput:
- ([0-9]+\.){2}[0-9]+\n$

- name: entrypoint.sh
envVars:
- key: USERID
value: 1000:1000
command: /entrypoint.sh
args:
- -V
expectedError:
- >-
^ERROR: uid:gid 1000:1000 lacks permissions to //\n$
exitCode: 1

- name: su-exec
command: su-exec
expectedOutput:
- >-
^Usage: su-exec user-spec command \[args\]\n$
- name: ssh
command: ssh
args:
- -V
expectedError:
- ^OpenSSH_9\.[0-9]+

fileExistenceTests:
- name: 'terrascan init'
path: '/root/.terrascan/pkg/policies/opa/rego/github/github_repository/privateRepoEnabled.rego'
shouldExist: true
uid: 0
gid: 0
- name: terrascan init
# yamllint disable-line rule:line-length
path: >-
/root/.terrascan/pkg/policies/opa/rego/github/github_repository/privateRepoEnabled.rego
shouldExist: true
uid: 0
gid: 0
8 changes: 6 additions & 2 deletions .github/.dive-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
---

rules:
# If the efficiency is measured below X%, mark as failed.
# Expressed as a ratio between 0-1.
lowestEfficiency: 0.981

# If the amount of wasted space is at least X or larger than X, mark as failed.
# If the amount of wasted space is at least X or larger than X, mark
# as failed.
# Expressed in B, KB, MB, and GB.
highestWastedBytes: 32MB

# If the amount of wasted space makes up for X% or more of the image, mark as failed.
# If the amount of wasted space makes up for X% or more of the image,
# mark as failed.
# Note: the base image layer is NOT included in the total image size.
# Expressed as a ratio between 0-1; fails if the threshold is met or crossed.
highestUserWastedPercent: 0.036
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
---

github: [antonbabenko]
custom: https://www.paypal.me/antonbabenko
Loading

0 comments on commit 1c9823e

Please sign in to comment.