Package: geomancy
Geomancy makes it easy to check and validate environments, such as development,
testing and production.Environment checks and tests are helpful for testing the correct setting
of environment variables, the installation and versions of installed
executables, the state of external dependencies, like LaTeX packages, or cloud
resources, or for checking environments that use the12-factorprinciples.FeaturesCapabilitiesValidation of layered and combined environmentsLayered environments could include acommonorbaseenvironment, with
additional checks for settings oftest,developmentandproductionenvironments.In the following checks file, the existence of an environment file and a secrets
file can be checked based on the$ENVenvironment variable. (See thedocker environment variable parameter expansion rules)checks:Environment:desc:Check environment variables in different deploymentsCheckEnvFile:desc:Check the existence of the environment filecheckPath:"deployments/${ENV}/.env"CheckSecretsFile:desc:Check the existence of the secrets filecheckPath:"deployments/${ENV}/.secrets"This check file can be used to check multiple environments:# check "dev" environment$geo-edeployments/base/.env-edeployments/dev/.envchecks.yaml
...# check "test" environment$geo-edeployments/base/.env-edeployments/test/.envchecks.yaml
...In this case,deployments/dev/.envis anenvironment filethat setsENV=dev,deployments/test/.envis anenvironment filethat setsENV=test.Full environment file supportof the dockerenv file syntaxEnvironment files are loaded using the-e/--envoption,
which can be layered for different environments.# Run checks for 'dev' environment$geo-edeployments/base/.env-edeployments/dev/.envcheck
...# Run checks for 'test' environment$geo-ebase.env-etest.envrun--echo"Test environment"Concurrent checks with multiple threadsto quickly probe
I/O bound resourcesThe following example concurrently checks that the 3 AWS S3 buckets are
accessible using thecurrent credentialsand are secured.This example is in yaml format, and checks can be formatted in toml format
as well.AWS:TemplateS3:checkS3:myproject-cfn-templatesStaticS3:checkS3:myproject-staticMediaS3:checkS3:myproject-mediaLoad checks in multiple formatsIncludingyaml(e.g..geomancy.yaml)checks:Environment:desc:Check environment variables common to all development environmentsPath:decs:Search paths for executablescheckEnv:$PATHortoml(e.g..geomancy.toml)[checks.Environment]desc="Check environment variables common to all development environments"[checks.Environment.Path]desc="Search paths for executables"checkEnv="$PATH"ortomlwith each check on 1 line (e.g..geomancy.toml)[Checks.Environment]Path={checkEnv="$PATH",desc="Search paths for executables"}orpyproject.toml[tool.geomancy.checks.Environment]desc="Check environment variables common to all development environments"[tool.geomancy.checks.Environment.Path]desc="Search paths for executables"checkEnv="$PATH"Available ChecksOperating systemsmeet the minimum required
  versions
  (checkOS)The following shows an example in yaml format. Checks can be formatted in
toml format as well.OperatingSystem:desc:Check the minimum operating system versionssubchecks:anycheckMacOS:desc:MacOS 10.9 or later (released 2013)checkOS:"macOS>=10.9"checkLinuxOS:desc:Linux 4.0 or later (released 2015)checkOS:"Linux>=3.0"checkWindows:desc:Windows 10 or later (released 2015)checkOS:"Windows>=10"Environment variablesare properly set and
  have valid values with regular expressions
  (checkEnv)The following shows an example in yaml format. Checks can be formatted in
toml format as well.Username:desc:The current usernamecheckEnv:"$USER"regex:"[a-z_][a-z0-9_-]*[$]?"Pathsexist and they're the right type
  (checkPath)The following shows an example in yaml format. Checks can be formatted in
toml format as well.PyprojectToml:desc:A project's pyprojectfilecheckPath:./pyproject.tomltype:fileExecutablesare available and meet minimum
  or correct versions
  (checkExec)The following shows an example in yaml format. Checks can be formatted in
toml format as well.Python:desc:Python interpreter (version 3.11 or higher)checkExec:"python3>=3.11"Python packagesare available minimum or
  correct versions
  (checkPythonPkg)The following shows an example in yaml format. Checks can be formatted in
toml format as well.PythonPackages:geomancy:desc:Geomancy python packagecheckPythonPkg:"geomancy>=0.1"Group checksand specify
  conditional (all or any) pass criteria
  (Groups of Checks)The following shows an example with thechecksgroup containing 2 groups,OperatingSystem,Environment.TheOperatingSystemgroup contains 3 checks:checkMacOS,checkLinuxOS,checkWindows, and theOperatingSystemgroup check
passes if any of these 3 checks pass (subchecks: any)TheEnvironmentgroup contains 1 check,Path, and 1 group,Username,
which itself contains 2 checks:UnixUsernameandWindowsUsername.This example is in yaml format, and checks can be formatted in toml format
as well.checks:OperatingSystem:desc:Check the minimum operating system versionssubchecks:anycheckMacOS:desc:MacOS 10.9 or later (released 2013)checkOS:"macOS>=10.9"checkLinuxOS:desc:Linux 4.0 or later (released 2015)checkOS:"Linux>=3.0"checkWindows:desc:Windows 10 or later (released 2015)checkOS:"Windows>=10"Environment:desc:Check environment variables common to all development environmentsPath:decs:Paths to search for executablescheckEnv:$PATHUsername:subchecks:anyUnixUsername:# Username on linux and macOSdesc:The current usernamecheckEnv:$USERregex:"[a-z_][a-z0-9_-]*[$]?"WindowsUsername:# Username on Windowsdesc:The current usernamecheckEnv:$USERNAMEregex:"[a-z_][a-z0-9_-]*[$]?"AWSresources exist and are securely setup
  (AWS checks)The following shows an example in yaml format. Checks can be formatted in
toml format as well.AWS:IAM:desc:Check the default authentication and security settingscheckIAM:TemplatesS3Bucket:desc:Check the bucket for cloudformation templatescheckS3:"myproject-cfn-templates"QuickstartCreate a.geomancy.yamlfile with checks. Seeexamples/geomancy.yamlfor an example of all checks.Environment:desc:Check environment variables common to all development environmentsUsername:desc:The current usernamecheckEnv:"$USER"regex:"[a-z_][a-z0-9_-]*[$]?"Paths:desc:Checks the existence of needed files and directoriessubchecks:"any"# at least one of the files must be presentGeomancy:desc:Check for the 'geomancy.toml' filecheckPath:examples/geomancy.tomltype:filePyproject:desc:Check for 'pyproject.toml' filecheckPath:examples/pyproject.tomltype:fileExecutables:desc:Check the availability of commands and their versionsPython:desc:Python interpreter ver 3.11 or highercheckExec:python3>=3.11Usegeoto run the checks.[✔]test.yaml...passed[✔]Environment...passed[✔]Checkenvironmentvariable'$USER'...passed[✔]Paths...passed[✔]Checkpath'examples/geomancy.toml'...passed[✔]Checkpath'examples/pyproject.toml'...passed[✔]Executables...passed[✔]Checkexecutable'python3>=3.11'...passed=================================8passedin0.50s==================================(By default,geomancywill search.geomancy.y[a]ml,geomancy.y[a]ml.geomancy.toml,geomancy.tomlandpyproject.toml.)DocumentationFor full documentation please seehttps://geomancy.readthedocs.io/en/latest.Bugs or RequestsPlease use theGitHub issue trackerto submit bugs or request features.Similar projectsThe following projects share some of the same goals in different contexts:EnvalidAWS ConfigLicenseCopyright Justin Lorieau and others, 2023.Distributed under the terms of theMIT license.
geomancy is free and open source software.