[bitnami/rails] Add Rails container VIB tests (#26122)

* [bitnami/rails] Add Rails container VIB tests

Signed-off-by: Michiel <michield@vmware.com>
This commit is contained in:
Michiel
2023-03-15 16:19:13 +01:00
committed by GitHub
parent b393a6e7ec
commit 39f3fc7e66
5 changed files with 88 additions and 3 deletions

10
.vib/rails/goss/goss.yaml Normal file
View File

@@ -0,0 +1,10 @@
gossfile:
# Goss tests exclusive to the current container
../../rails/goss/rails.yaml: {}
# Load scripts from .vib/common/goss/templates
../../common/goss/templates/check-binaries.yaml: {}
../../common/goss/templates/check-broken-symlinks.yaml: {}
../../common/goss/templates/check-ca-certs.yaml: {}
../../common/goss/templates/check-directories.yaml: {}
../../common/goss/templates/check-linked-libraries.yaml: {}
../../common/goss/templates/check-sed-in-place.yaml: {}

View File

@@ -0,0 +1,24 @@
command:
# A new Rails project can be created
check-project:
timeout: 120000
exec: "rails new /app && cd /app && timeout 10s rails s -p 4000 || true"
exit-status: 0
stdout:
- Listening
check-app-version:
# The `APP_VERSION` environment variable returns the version in the format of
# Major.Minor.Patch-Build, such as 1.2.3-4 while the `rails -v` command returns
# the version in the format of Major.Minor.Patch.Build, such as 1.2.3.4 so we
# need to convert the environment variable before comparing the two versions
exec: {{ .Vars.version.bin_name }} {{ .Vars.version.flag }} | sed '/^[0-9]\+\.[0-9]\+\.[0-9]\+$/ s/$/-0/' | sed "s/\.\([0-9]\)$/-\1/"
exit-status: 0
stdout:
- {{ .Env.APP_VERSION }}
check-installed-gems:
exec: gem list
exit-status: 0
stdout:
{{ range $module := .Vars.modules }}
- {{ $module }}
{{ end }}

19
.vib/rails/goss/vars.yaml Normal file
View File

@@ -0,0 +1,19 @@
binaries:
- gosu
- mysql
- node
- python
- rails
- ruby
directories:
- mode: "0775"
paths:
- /app
root_dir: /opt/bitnami
version:
bin_name: rails
flag: --version
modules:
- sqlite3
- mysql
- pg

View File

@@ -3,7 +3,8 @@
"resources": {
"url": "{VIB_ENV_CONTAINER_URL}",
"path": "{VIB_ENV_PATH}"
}
},
"runtime_parameters": "Y29tbWFuZDogWyJ0YWlsIiwgIi1mIiwgIi9kZXYvbnVsbCJd"
},
"phases": {
"package": {
@@ -33,6 +34,21 @@
},
"verify": {
"actions": [
{
"action_id": "goss",
"params": {
"resources": {
"path": "/.vib"
},
"tests_file": "rails/goss/goss.yaml",
"vars_file": "rails/goss/vars.yaml",
"remote": {
"pod": {
"workload": "deploy-rails"
}
}
}
},
{
"action_id": "trivy",
"params": {
@@ -93,4 +109,4 @@
]
}
}
}
}

View File

@@ -3,7 +3,8 @@
"resources": {
"url": "{SHA_ARCHIVE}",
"path": "{VIB_ENV_PATH}"
}
},
"runtime_parameters": "Y29tbWFuZDogWyJ0YWlsIiwgIi1mIiwgIi9kZXYvbnVsbCJd"
},
"phases": {
"package": {
@@ -29,6 +30,21 @@
},
"verify": {
"actions": [
{
"action_id": "goss",
"params": {
"resources": {
"path": "/.vib"
},
"tests_file": "rails/goss/goss.yaml",
"vars_file": "rails/goss/vars.yaml",
"remote": {
"pod": {
"workload": "deploy-rails"
}
}
}
},
{
"action_id": "trivy",
"params": {