Skip to content

Commit

Permalink
Add envy to make sure environmental variables are correct (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
omnicolor authored Apr 3, 2023
1 parent 0eb3fb8 commit 79721a0
Show file tree
Hide file tree
Showing 5 changed files with 301 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ APP_URL=http://localhost
AVATAR_DATA_PATH=data/Avatar/
CAPERS_DATA_PATH=data/Capers/
CYBERPUNK_DATA_PATH=data/CyberpunkRed/
DND5E_DATA_PATH=data/Dnd5e/
EXPANSE_DATA_PATH=data/Expanse/
SHADOWRUN5E_DATA_PATH=data/Shadowrun5e/
SHADOWRUN6E_DATA_PATH=data/Shadowrun6e/
STAR_TREK_ADVENTURES_DATA_PATH=data/StarTrekAdventures/

DISCORD_CLIENT_ID=
Expand Down Expand Up @@ -47,6 +49,7 @@ MIX_PUSHER_APP_CLUSTER=us2

CACHE_DRIVER=file
QUEUE_CONNECTION=redis

SESSION_DRIVER=file
SESSION_LIFETIME=120

Expand All @@ -61,5 +64,7 @@ MAIL_PASSWORD=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

SENTRY_DSN=
SENTRY_ENVIRONMENT=
SENTRY_LARAVEL_DSN=
SENTRY_TRACES_SAMPLE_RATE=1.0
10 changes: 9 additions & 1 deletion .github/workflows/env.testing
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ APP_URL=https://commlink.digitaldarkness.com
AVATAR_DATA_PATH=data/Avatar/
CAPERS_DATA_PATH=data/Capers/
CYBERPUNK_DATA_PATH=data/Cyberpunkred/
DND5E_DATA_PATH=data/Dnd5e/
EXPANSE_DATA_PATH=data/Expanse/
SHADOWRUN5E_DATA_PATH=data/Shadowrun5e/
SHADOWRUN6E_DATA_PATH=data/Shadowrun6e/
STAR_TREK_ADVENTURES_DATA_PATH=data/StarTrekAdventures/

DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
DISCORD_TOKEN=
DISCORD_REDIRECT_URI=

SLACK_CLIENT_ID=
SLACK_CLIENT_SECRET=
SLACK_TOKEN=

LOG_CHANNEL=stack
Expand All @@ -34,6 +37,7 @@ BROADCAST_DRIVER=log

CACHE_DRIVER=file
QUEUE_CONNECTION=redis

SESSION_DRIVER=file
SESSION_LIFETIME=120

Expand All @@ -50,5 +54,9 @@ MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=commlink+github@digitaldarkness.com
MAIL_FROM_NAME="Commlink RPG Manager"

SENTRY_DSN=
SENTRY_ENVIRONMENT=
SENTRY_LARAVEL_DSN=
SENTRY_TRACES_SAMPLE_RATE=1.0

PENNANT_STORE=array
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
"roave/security-advisories": "dev-latest",
"spatie/laravel-ignition": "^2.0",
"squizlabs/php_codesniffer": "^3.6",
"vimeo/psalm": "^5.6"
"vimeo/psalm": "^5.6",
"worksome/envy": "^1.1"
},
"scripts": {
"all": [
Expand Down
136 changes: 135 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

150 changes: 150 additions & 0 deletions config/envy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<?php

declare(strict_types=1);

return [
/*
* Here, you should include any environment files that you want to keep
* in sync. For most projects, the `.env.example` file will suffice.
* However, you're free to include more as your project requires.
*/
'environment_files' => [
base_path('.env.example'),
],

/**
* Here you should list any config files/directories that you want to be
* included when looking for calls to `env`. Directories are searched
* recursively. Feel free to include unpublished vendor configs too.
*/
'config_files' => [
config_path(),
],

/**
* Comments like the one you're reading can be quite useful when trying
* to remember what an environment variable is used for. When set to
* true, we'll copy any comments we find in config over to .env.
*/
'display_comments' => false,

/**
* Some developers find it useful to have reference to where an environment
* variable is used. Enabling this option will display a comment above a
* linked .env variable with reference to the correct config file.
*/
'display_location_hints' => false,

/**
* Enabling this option will also insert any provided defaults in your .env file
* when updating. Note that only scalar (primitive) types will be copied over.
* Defaults that include spaces will be wrapped in quotes for you.
*
* Note that `exclude_calls_with_defaults` must be set to `false` for this
* to take effect.
*/
'display_default_values' => true,

/**
* When calling the `env` function, you can optionally provide a default as the
* second parameter. Envy will ignore any calls with a set default if this
* option is set to true. Otherwise, it will include them whilst syncing.
*/
'exclude_calls_with_defaults' => true,

/**
* Any environment variables that are added to exclusions will never be inserted
* into .env files. Our defaults are based on the base Laravel config files.
* Feel free to add or remove variables as required by your project needs.
*/
'exclusions' => [
// config/app.php
'ASSET_URL',

// config/broadcasting.php
'ABLY_KEY',
'PUSHER_APP_KEY',
'PUSHER_APP_SECRET',
'PUSHER_APP_ID',
'PUSHER_APP_CLUSTER',

// config/cache.php
'MEMCACHED_PERSISTENT_ID',
'MEMCACHED_USERNAME',
'MEMCACHED_PASSWORD',
'MEMCACHED_HOST',
'MEMCACHED_PORT',
'AWS_ACCESS_KEY_ID',
'AWS_SECRET_ACCESS_KEY',
'AWS_DEFAULT_REGION',
'DYNAMODB_CACHE_TABLE',
'DYNAMODB_ENDPOINT',

// config/database.php
'DATABASE_URL',
'DB_SOCKET',
'REDIS_CLIENT',
'REDIS_CLUSTER',
'REDIS_PREFIX',
'REDIS_URL',
'REDIS_DB',
'REDIS_CACHE_DB',
'MYSQL_ATTR_SSL_CA',

// config/filesystems.php
'AWS_ENDPOINT',
'AWS_URL',
'AWS_BUCKET',

// config/hashing.php
'BCRYPT_ROUNDS',

// config/logging.php
'PAPERTRAIL_URL',
'PAPERTRAIL_PORT',
'LOG_STDERR_FORMATTER',
'LOG_SLACK_WEBHOOK_URL',

// config/mail.php
'MAIL_SENDMAIL_PATH',
'MAIL_LOG_CHANNEL',
'MAIL_FROM_ADDRESS',
'MAIL_FROM_NAME',

// config/queue.php
'SQS_PREFIX',
'SQS_QUEUE',
'SQS_SUFFIX',
'REDIS_QUEUE',
'QUEUE_FAILED_DRIVER',

// config/sanctum.php
'SANCTUM_STATEFUL_DOMAINS',

// config/services.php
'MAILGUN_DOMAIN',
'MAILGUN_SECRET',
'MAILGUN_ENDPOINT',
'POSTMARK_TOKEN',

// config/session.php
'SESSION_CONNECTION',
'SESSION_STORE',
'SESSION_COOKIE',
'SESSION_DOMAIN',
'SESSION_SECURE_COOKIE',

// config/view.php
'VIEW_COMPILED_PATH',
],

/**
* Any environment variables that are added to inclusions will never be pruned from
* your .env files. By default, we include Laravel Mix variables. Feel free to
* add or remove environment variables to suit your project's requirements.
*/
'inclusions' => [
'MIX_PUSHER_APP_KEY',
'MIX_PUSHER_APP_CLUSTER',
],
];

0 comments on commit 79721a0

Please sign in to comment.