Skip to content

Commit ee3d325

Browse files
authored
Replace dotenv with a built-in solution (#352)
1 parent 51ae7fb commit ee3d325

20 files changed

+237
-92
lines changed

.env.example

Lines changed: 0 additions & 2 deletions
This file was deleted.

.env.test

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,47 @@ on:
2222
name: build
2323

2424
jobs:
25-
build:
26-
uses: yiisoft/actions/.github/workflows/codeception.yml@master
27-
with:
28-
extensions: fileinfo, intl
29-
os: >-
30-
['ubuntu-latest', 'windows-latest']
31-
php: >-
32-
['8.1', '8.2', '8.3']
25+
codeception:
26+
name: PHP ${{ matrix.php }}-${{ matrix.os }}
27+
28+
env:
29+
key: cache-v1
30+
APP_C3: true
31+
APP_ENV: test
32+
APP_DEBUG: false
33+
34+
runs-on: ${{ matrix.os }}
35+
36+
strategy:
37+
matrix:
38+
os:
39+
- ubuntu-latest
40+
- windows-latest
41+
php:
42+
- "8.1"
43+
- "8.2"
44+
- "8.3"
45+
46+
steps:
47+
- name: Checkout.
48+
uses: actions/checkout@v4
49+
50+
- name: Install PHP with extensions.
51+
uses: shivammathur/setup-php@v2
52+
with:
53+
coverage: false
54+
extensions: fileinfo, intl
55+
ini-values: date.timezone='UTC'
56+
php-version: ${{ matrix.php }}
57+
58+
- name: Install Composer dependencies
59+
uses: ramsey/composer-install@v3
60+
61+
- name: Run tests with codeception with code coverage with shell bash.
62+
if: matrix.os == 'ubuntu-latest'
63+
run: vendor/bin/codecept run
64+
65+
- name: Run tests with codeception with code coverage with shell powershell.
66+
if: matrix.os == 'windows-latest'
67+
run: vendor/bin/codecept run
68+
shell: powershell

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ exec: ## Run a command within the existing container.
2929
run: ## Run a command within a temporary container.
3030
docker compose -f docker/compose.yml -f docker/compose.dev.yml run --rm --entrypoint $(CMD) app $(RUN_ARGS)
3131

32+
run-test: ## Run a command in testing environment.
33+
docker compose -f docker/compose.yml -f docker/compose.test.yml run --rm --entrypoint $(CMD) app $(RUN_ARGS)
34+
3235
shell: CMD="/bin/sh" ## Get into container shell.
3336
shell: exec
3437

@@ -39,7 +42,7 @@ composer: CMD="composer" ## Run Composer.
3942
composer: run
4043

4144
codecept: CMD="./vendor/bin/codecept" ## Run Codeception.
42-
codecept: run
45+
codecept: run-test
4346

4447
psalm: CMD="./vendor/bin/psalm" ## Run Psalm.
4548
psalm: run

autoload.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

codeception.yml

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
namespace: App\Tests
22
support_namespace: Support
33
paths:
4-
tests: tests
5-
output: runtime/tests/_output
6-
data: tests/Support/Data
7-
support: tests/Support
8-
envs: tests/_envs
4+
tests: tests
5+
output: runtime/tests/_output
6+
data: tests/Support/Data
7+
support: tests/Support
8+
envs: tests/_envs
99
actor_suffix: Tester
1010
extensions:
11-
enabled:
12-
- Codeception\Extension\RunFailed
11+
enabled:
12+
- Codeception\Extension\RunFailed
1313
settings:
14-
suite_class: \PHPUnit_Framework_TestSuite
15-
memory_limit: 1024M
16-
colors: true
14+
suite_class: \PHPUnit_Framework_TestSuite
15+
memory_limit: 1024M
16+
colors: true
1717
coverage:
18-
enabled: true
19-
whitelist:
20-
include:
21-
- src/*
22-
exclude:
23-
- src/Asset/*
24-
- src/Installer.php
25-
params:
26-
- .env
27-
- .env.test
18+
enabled: true
19+
whitelist:
20+
include:
21+
- src/*
22+
exclude:
23+
- src/Asset/*
24+
- src/Installer.php
25+
bootstrap: bootstrap.php

composer.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,21 @@
3535
"test": "codecept run",
3636
"test-watch": "phpunit-watcher watch",
3737
"post-install-cmd": [
38-
"App\\Installer::postUpdate",
39-
"App\\Installer::copyEnvFile"
38+
"App\\Installer::postUpdate"
4039
],
4140
"post-update-cmd": [
42-
"App\\Installer::postUpdate",
43-
"App\\Installer::copyEnvFile"
44-
],
45-
"post-create-project-cmd": [
46-
"App\\Installer::copyEnvFile"
41+
"App\\Installer::postUpdate"
4742
]
4843
},
4944
"require": {
5045
"php": "^8.1",
46+
"ext-filter": "*",
5147
"ext-intl": "*",
5248
"httpsoft/http-message": "^1.1",
5349
"psr/container": "^2.0",
5450
"psr/http-message": "^1.1|^2.0",
5551
"psr/http-server-handler": "^1.0",
5652
"symfony/console": "^6.0",
57-
"vlucas/phpdotenv": "^5.3",
5853
"yiisoft/aliases": "^3.0",
5954
"yiisoft/assets": "^4.0",
6055
"yiisoft/cache": "^3.0",

configuration.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
declare(strict_types=1);
44

5+
use App\Environment;
6+
57
return [
68
'config-plugin' => [
79
'params' => 'common/params.php',
@@ -38,19 +40,19 @@
3840
'bootstrap-console' => '$bootstrap',
3941
],
4042
'config-plugin-environments' => [
41-
'dev' => [
43+
Environment::DEV => [
4244
'params' => [
4345
'environments/dev/params.php',
4446
],
4547
],
46-
'prod' => [
48+
Environment::TEST => [
4749
'params' => [
48-
'environments/prod/params.php',
50+
'environments/test/params.php',
4951
],
5052
],
51-
'test' => [
53+
Environment::PROD => [
5254
'params' => [
53-
'environments/test/params.php',
55+
'environments/prod/params.php',
5456
],
5557
],
5658
],

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ RUN --mount=type=cache,target=/tmp/cache \
4646
SH
4747

4848
FROM base AS prod
49-
ENV YII_ENV=prod
49+
ENV APP_ENV=prod
5050

5151
COPY --from=prod-builder --chown=www-data:www-data /app /app
5252
USER www-data

docker/compose.dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ services:
99
GID: ${GID}
1010
environment:
1111
XDEBUG_MODE: "${XDEBUG_MODE:-develop}"
12-
YII_ENV: "${YII_ENV:-dev}"
13-
YII_DEBUG: ${YII_DEBUG:-true}
12+
APP_ENV: "${APP_ENV:-dev}"
13+
APP_DEBUG: ${APP_DEBUG:-true}
1414
SERVER_NAME: ":80"
1515
restart: unless-stopped
1616
ports:

0 commit comments

Comments
 (0)